contract_name
stringlengths 1
100
| contract_address
stringlengths 42
42
| language
stringclasses 2
values | source_code
stringlengths 0
1.24M
| solidetector
stringlengths 2
3.89k
⌀ | slither
stringlengths 2
4.49M
⌀ | oyente
stringlengths 2
10.8k
⌀ | smartcheck
stringlengths 2
78.6k
⌀ | abi
stringlengths 2
59.6k
| compiler_version
stringlengths 11
42
| optimization_used
bool 2
classes | runs
int64 0
1B
| constructor_arguments
stringlengths 0
60.2k
| evm_version
stringclasses 8
values | library
stringlengths 0
510
| license_type
stringclasses 14
values | proxy
bool 2
classes | implementation
stringlengths 0
42
| swarm_source
stringlengths 0
71
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
SuperRareBazaar | 0x6d7c44773c52d396f43c2d511b81aa168e9a7a42 | Solidity | // File: contracts/bazaar/SuperRareBazaar.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;
import "@openzeppelin/contracts-upgradeable-0.7.2/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable-0.7.2/utils/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-0.7.2/token/ERC721/IERC721.sol";
import "./storage/SuperRareBazaarStorage.sol";
import "./ISuperRareBazaar.sol";
/// @author koloz
/// @title SuperRareBazaar
/// @notice The unified contract for the bazaar logic (Marketplace and Auction House).
/// @dev All storage is inherrited and append only (no modifications) to make upgrade compliant.
contract SuperRareBazaar is
ISuperRareBazaar,
OwnableUpgradeable,
ReentrancyGuardUpgradeable,
SuperRareBazaarStorage
{
/////////////////////////////////////////////////////////////////////////
// Initializer
/////////////////////////////////////////////////////////////////////////
function initialize(
address _marketplaceSettings,
address _royaltyRegistry,
address _royaltyEngine,
address _superRareMarketplace,
address _superRareAuctionHouse,
address _spaceOperatorRegistry,
address _approvedTokenRegistry,
address _payments,
address _stakingRegistry,
address _networkBeneficiary
) public initializer {
require(_marketplaceSettings != address(0));
require(_royaltyRegistry != address(0));
require(_royaltyEngine != address(0));
require(_superRareMarketplace != address(0));
require(_superRareAuctionHouse != address(0));
require(_spaceOperatorRegistry != address(0));
require(_approvedTokenRegistry != address(0));
require(_payments != address(0));
require(_networkBeneficiary != address(0));
marketplaceSettings = IMarketplaceSettings(_marketplaceSettings);
royaltyRegistry = IERC721CreatorRoyalty(_royaltyRegistry);
royaltyEngine = IRoyaltyEngineV1(_royaltyEngine);
superRareMarketplace = _superRareMarketplace;
superRareAuctionHouse = _superRareAuctionHouse;
spaceOperatorRegistry = ISpaceOperatorRegistry(_spaceOperatorRegistry);
approvedTokenRegistry = IApprovedTokenRegistry(_approvedTokenRegistry);
payments = IPayments(_payments);
stakingRegistry = _stakingRegistry;
networkBeneficiary = _networkBeneficiary;
minimumBidIncreasePercentage = 10;
maxAuctionLength = 7 days;
auctionLengthExtension = 15 minutes;
offerCancelationDelay = 5 minutes;
__Ownable_init();
__ReentrancyGuard_init();
}
/////////////////////////////////////////////////////////////////////////
// Admin Functions
/////////////////////////////////////////////////////////////////////////
function setMarketplaceSettings(address _marketplaceSettings)
external
onlyOwner
{
require(_marketplaceSettings != address(0));
marketplaceSettings = IMarketplaceSettings(_marketplaceSettings);
}
function setRoyaltyRegistry(address _royaltyRegistry) external onlyOwner {
require(_royaltyRegistry != address(0));
royaltyRegistry = IERC721CreatorRoyalty(_royaltyRegistry);
}
function setRoyaltyEngine(address _royaltyEngine) external onlyOwner {
require(_royaltyEngine != address(0));
royaltyEngine = IRoyaltyEngineV1(_royaltyEngine);
}
function setSuperRareMarketplace(address _superRareMarketplace)
external
onlyOwner
{
require(_superRareMarketplace != address(0));
superRareMarketplace = _superRareMarketplace;
}
function setSuperRareAuctionHouse(address _superRareAuctionHouse)
external
onlyOwner
{
require(_superRareAuctionHouse != address(0));
superRareAuctionHouse = _superRareAuctionHouse;
}
function setSpaceOperatorRegistry(address _spaceOperatorRegistry)
external
onlyOwner
{
require(_spaceOperatorRegistry != address(0));
spaceOperatorRegistry = ISpaceOperatorRegistry(_spaceOperatorRegistry);
}
function setApprovedTokenRegistry(address _approvedTokenRegistry)
external
onlyOwner
{
require(_approvedTokenRegistry != address(0));
approvedTokenRegistry = IApprovedTokenRegistry(_approvedTokenRegistry);
}
function setPayments(address _payments) external onlyOwner {
require(_payments != address(0));
payments = IPayments(_payments);
}
function setStakingRegistry(address _stakingRegistry) external onlyOwner {
require(_stakingRegistry != address(0));
stakingRegistry = _stakingRegistry;
}
function setNetworkBeneficiary(address _networkBeneficiary)
external
onlyOwner
{
require(_networkBeneficiary != address(0));
networkBeneficiary = _networkBeneficiary;
}
function setMinimumBidIncreasePercentage(
uint8 _minimumBidIncreasePercentage
) external onlyOwner {
minimumBidIncreasePercentage = _minimumBidIncreasePercentage;
}
function setMaxAuctionLength(uint8 _maxAuctionLength) external onlyOwner {
maxAuctionLength = _maxAuctionLength;
}
function setAuctionLengthExtension(uint256 _auctionLengthExtension)
external
onlyOwner
{
auctionLengthExtension = _auctionLengthExtension;
}
function setOfferCancelationDelay(uint256 _offerCancelationDelay)
external
onlyOwner
{
offerCancelationDelay = _offerCancelationDelay;
}
/////////////////////////////////////////////////////////////////////////
// Marketplace Functions
/////////////////////////////////////////////////////////////////////////
/// @notice Place an offer for a given asset
/// @dev Notice we need to verify that the msg sender has approved us to move funds on their behalf.
/// @dev Covers use of any currency (0 address is eth).
/// @dev _amount is the amount of the offer excluding the marketplace fee.
/// @dev There can be multiple offers of different currencies, but only 1 per currency.
/// @param _originContract Contract address of the asset being listed.
/// @param _tokenId Token Id of the asset.
/// @param _currencyAddress Address of the token being offered.
/// @param _amount Amount being offered.
/// @param _convertible If the offer can be converted into an auction
function offer(
address _originContract,
uint256 _tokenId,
address _currencyAddress,
uint256 _amount,
bool _convertible
) external payable override {
(bool success, bytes memory data) = superRareMarketplace.delegatecall(
abi.encodeWithSelector(
this.offer.selector,
_originContract,
_tokenId,
_currencyAddress,
_amount,
_convertible
)
);
require(success, string(data));
}
/// @notice Purchases the token for the current sale price.
/// @dev Covers use of any currency (0 address is eth).
/// @dev Need to verify that the buyer (if not using eth) has the marketplace approved for _currencyContract.
/// @dev Need to verify that the seller has the marketplace approved for _originContract.
/// @param _originContract Contract address for asset being bought.
/// @param _tokenId TokenId of asset being bought.
/// @param _currencyAddress Currency address of asset being used to buy.
/// @param _amount Amount the piece if being bought for (including marketplace fee).
function buy(
address _originContract,
uint256 _tokenId,
address _currencyAddress,
uint256 _amount
) external payable override {
(bool success, bytes memory data) = superRareMarketplace.delegatecall(
abi.encodeWithSelector(
this.buy.selector,
_originContract,
_tokenId,
_currencyAddress,
_amount
)
);
require(success, string(data));
}
/// @notice Cancels an existing offer the sender has placed on a piece.
/// @param _originContract Contract address of token.
/// @param _tokenId TokenId that has an offer.
/// @param _currencyAddress Currency address of the offer.
function cancelOffer(
address _originContract,
uint256 _tokenId,
address _currencyAddress
) external override {
(bool success, bytes memory data) = superRareMarketplace.delegatecall(
abi.encodeWithSelector(
this.cancelOffer.selector,
_originContract,
_tokenId,
_currencyAddress
)
);
require(success, string(data));
}
/// @notice Sets a sale price for the given asset(s) directed at the _target address.
/// @dev Covers use of any currency (0 address is eth).
/// @dev Sale price for everyone is denoted as the 0 address.
/// @dev Only 1 currency can be used for the sale price directed at a speicific target.
/// @dev _listPrice of 0 signifies removing the list price for the provided currency.
/// @dev This function can be used for counter offers as well.
/// @param _originContract Contract address of the asset being listed.
/// @param _tokenId Token Id of the asset.
/// @param _currencyAddress Contract address of the currency asset is being listed for.
/// @param _listPrice Amount of the currency the asset is being listed for (including all decimal points).
/// @param _target Address of the person this sale price is target to.
/// @param _splitAddresses Addresses to split the sellers commission with.
/// @param _splitRatios The ratio for the split corresponding to each of the addresses being split with.
function setSalePrice(
address _originContract,
uint256 _tokenId,
address _currencyAddress,
uint256 _listPrice,
address _target,
address payable[] calldata _splitAddresses,
uint8[] calldata _splitRatios
) external override {
(bool success, bytes memory data) = superRareMarketplace.delegatecall(
abi.encodeWithSelector(
this.setSalePrice.selector,
_originContract,
_tokenId,
_currencyAddress,
_listPrice,
_target,
_splitAddresses,
_splitRatios
)
);
require(success, string(data));
}
/// @notice Removes the current sale price of an asset for _target for the given currency.
/// @dev Sale prices could still exist for different currencies.
/// @dev Sale prices could still exist for different targets.
/// @dev Zero address for _currency means that its listed in ether.
/// @dev _target of zero address is the general sale price.
/// @param _originContract The origin contract of the asset.
/// @param _tokenId The tokenId of the asset within the _originContract.
/// @param _target The address of the person
function removeSalePrice(
address _originContract,
uint256 _tokenId,
address _target
) external override {
IERC721 erc721 = IERC721(_originContract);
address tokenOwner = erc721.ownerOf(_tokenId);
require(
msg.sender == tokenOwner,
"removeSalePrice::Must be tokenOwner."
);
delete tokenSalePrices[_originContract][_tokenId][_target];
emit SetSalePrice(
_originContract,
address(0),
address(0),
0,
_tokenId,
new address payable[](0),
new uint8[](0)
);
}
/// @notice Accept an offer placed on _originContract : _tokenId.
/// @dev Zero address for _currency means that the offer being accepted is in ether.
/// @param _originContract Contract of the asset the offer was made on.
/// @param _tokenId TokenId of the asset.
/// @param _currencyAddress Address of the currency used for the offer.
/// @param _amount Amount the offer was for/and is being accepted.
/// @param _splitAddresses Addresses to split the sellers commission with.
/// @param _splitRatios The ratio for the split corresponding to each of the addresses being split with.
function acceptOffer(
address _originContract,
uint256 _tokenId,
address _currencyAddress,
uint256 _amount,
address payable[] calldata _splitAddresses,
uint8[] calldata _splitRatios
) external override {
(bool success, bytes memory data) = superRareMarketplace.delegatecall(
abi.encodeWithSelector(
this.acceptOffer.selector,
_originContract,
_tokenId,
_currencyAddress,
_amount,
_splitAddresses,
_splitRatios
)
);
require(success, string(data));
}
/////////////////////////////////////////////////////////////////////////
// Auction House Functions
/////////////////////////////////////////////////////////////////////////
/// @notice Configures an Auction for a given asset.
/// @dev If auction type is coldie (reserve) then _startingAmount cant be 0.
/// @dev _currencyAddress equal to the zero address denotes eth.
/// @dev All time related params are unix epoch timestamps.
/// @param _auctionType The type of auction being configured.
/// @param _originContract Contract address of the asset being put up for auction.
/// @param _tokenId Token Id of the asset.
/// @param _startingAmount The reserve price or min bid of an auction.
/// @param _currencyAddress The currency the auction is being conducted in.
/// @param _lengthOfAuction The amount of time in seconds that the auction is configured for.
/// @param _splitAddresses Addresses to split the sellers commission with.
/// @param _splitRatios The ratio for the split corresponding to each of the addresses being split with.
function configureAuction(
bytes32 _auctionType,
address _originContract,
uint256 _tokenId,
uint256 _startingAmount,
address _currencyAddress,
uint256 _lengthOfAuction,
uint256 _startTime,
address payable[] calldata _splitAddresses,
uint8[] calldata _splitRatios
) external override {
(bool success, bytes memory data) = superRareAuctionHouse.delegatecall(
abi.encodeWithSelector(
this.configureAuction.selector,
_auctionType,
_originContract,
_tokenId,
_startingAmount,
_currencyAddress,
_lengthOfAuction,
_startTime,
_splitAddresses,
_splitRatios
)
);
require(success, string(data));
}
/// @notice Converts an offer into a coldie auction.
/// @dev Covers use of any currency (0 address is eth).
/// @dev Only covers converting an offer to a coldie auction.
/// @dev Cant convert offer if an auction currently exists.
/// @param _originContract Contract address of the asset.
/// @param _tokenId Token Id of the asset.
/// @param _currencyAddress Address of the currency being converted.
/// @param _amount Amount being converted into an auction.
/// @param _lengthOfAuction Number of seconds the auction will last.
/// @param _splitAddresses Addresses that the sellers take in will be split amongst.
/// @param _splitRatios Ratios that the take in will be split by.
function convertOfferToAuction(
address _originContract,
uint256 _tokenId,
address _currencyAddress,
uint256 _amount,
uint256 _lengthOfAuction,
address payable[] calldata _splitAddresses,
uint8[] calldata _splitRatios
) external override {
(bool success, bytes memory data) = superRareAuctionHouse.delegatecall(
abi.encodeWithSelector(
this.convertOfferToAuction.selector,
_originContract,
_tokenId,
_currencyAddress,
_amount,
_lengthOfAuction,
_splitAddresses,
_splitRatios
)
);
require(success, string(data));
}
/// @notice Cancels a configured Auction that has not started.
/// @dev Requires the person sending the message to be the auction creator or token owner.
/// @param _originContract Contract address of the asset pending auction.
/// @param _tokenId Token Id of the asset.
function cancelAuction(address _originContract, uint256 _tokenId)
external
override
{
(bool success, bytes memory data) = superRareAuctionHouse.delegatecall(
abi.encodeWithSelector(
this.cancelAuction.selector,
_originContract,
_tokenId
)
);
require(success, string(data));
}
/// @notice Places a bid on a valid auction.
/// @dev Only the configured currency can be used (Zero address for eth)
/// @param _originContract Contract address of asset being bid on.
/// @param _tokenId Token Id of the asset.
/// @param _currencyAddress Address of currency being used to bid.
/// @param _amount Amount of the currency being used for the bid.
function bid(
address _originContract,
uint256 _tokenId,
address _currencyAddress,
uint256 _amount
) external payable override {
(bool success, bytes memory data) = superRareAuctionHouse.delegatecall(
abi.encodeWithSelector(
this.bid.selector,
_originContract,
_tokenId,
_currencyAddress,
_amount
)
);
require(success, string(data));
}
/// @notice Settles an auction that has ended.
/// @dev Anyone is able to settle an auction since non-input params are used.
/// @param _originContract Contract address of asset.
/// @param _tokenId Token Id of the asset.
function settleAuction(address _originContract, uint256 _tokenId)
external
override
{
(bool success, bytes memory data) = superRareAuctionHouse.delegatecall(
abi.encodeWithSelector(
this.settleAuction.selector,
_originContract,
_tokenId
)
);
require(success, string(data));
}
/// @notice Grabs the current auction details for a token.
/// @param _originContract Contract address of asset.
/// @param _tokenId Token Id of the asset.
/** @return Auction Struct: creatorAddress, creationTime, startingTime, lengthOfAuction,
currencyAddress, minimumBid, auctionType, splitRecipients array, and splitRatios array.
*/
function getAuctionDetails(address _originContract, uint256 _tokenId)
external
view
override
returns (
address,
uint256,
uint256,
uint256,
address,
uint256,
bytes32,
address payable[] memory,
uint8[] memory
)
{
Auction memory auction = tokenAuctions[_originContract][_tokenId];
return (
auction.auctionCreator,
auction.creationBlock,
auction.startingTime,
auction.lengthOfAuction,
auction.currencyAddress,
auction.minimumBid,
auction.auctionType,
auction.splitRecipients,
auction.splitRatios
);
}
function getSalePrice(
address _originContract,
uint256 _tokenId,
address _target
)
external
view
override
returns (
address,
address,
uint256,
address payable[] memory,
uint8[] memory
)
{
SalePrice memory sp = tokenSalePrices[_originContract][_tokenId][
_target
];
return (
sp.seller,
sp.currencyAddress,
sp.amount,
sp.splitRecipients,
sp.splitRatios
);
}
}
// File: @openzeppelin/contracts-upgradeable-0.7.2/access/OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal initializer {
__Context_init_unchained();
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal initializer {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
uint256[49] private __gap;
}
// File: @openzeppelin/contracts-upgradeable-0.7.2/utils/ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
import "../proxy/Initializable.sol";
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuardUpgradeable is Initializable {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
function __ReentrancyGuard_init() internal initializer {
__ReentrancyGuard_init_unchained();
}
function __ReentrancyGuard_init_unchained() internal initializer {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
uint256[49] private __gap;
}
// File: @openzeppelin/contracts-0.7.2/token/ERC721/IERC721.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
import "../../introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
}
// File: contracts/bazaar/storage/SuperRareBazaarStorage.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;
import "../../marketplace/IMarketplaceSettings.sol";
import "../../royalty/creator/IERC721CreatorRoyalty.sol";
import "../../payments/IPayments.sol";
import "../../registry/spaces/ISpaceOperatorRegistry.sol";
import "../../registry/token/IApprovedTokenRegistry.sol";
import "../../royalty/creator/IRoyaltyEngine.sol";
/// @author koloz
/// @title SuperRareBazaar Storage Contract
/// @dev STORAGE CAN ONLY BE APPENDED NOT INSERTED OR MODIFIED
contract SuperRareBazaarStorage {
/////////////////////////////////////////////////////////////////////////
// Constants
/////////////////////////////////////////////////////////////////////////
// Auction Types
bytes32 public constant COLDIE_AUCTION = "COLDIE_AUCTION";
bytes32 public constant SCHEDULED_AUCTION = "SCHEDULED_AUCTION";
bytes32 public constant NO_AUCTION = bytes32(0);
/////////////////////////////////////////////////////////////////////////
// Structs
/////////////////////////////////////////////////////////////////////////
// The Offer truct for a given token:
// buyer - address of person making the offer
// currencyAddress - address of the erc20 token used for an offer
// or the zero address for eth
// amount - offer in wei/full erc20 value
// marketplaceFee - the amount that is taken by the network on offer acceptance.
struct Offer {
address payable buyer;
uint256 amount;
uint256 timestamp;
uint8 marketplaceFee;
bool convertible;
}
// The Sale Price struct for a given token:
// seller - address of the person selling the token
// currencyAddress - address of the erc20 token used for an offer
// or the zero address for eth
// amount - offer in wei/full erc20 value
struct SalePrice {
address payable seller;
address currencyAddress;
uint256 amount;
address payable[] splitRecipients;
uint8[] splitRatios;
}
// Structure of an Auction:
// auctionCreator - creator of the auction
// creationBlock - time that the auction was created/configured
// startingBlock - time that the auction starts on
// lengthOfAuction - how long the auction is
// currencyAddress - address of the erc20 token used for an offer
// or the zero address for eth
// minimumBid - min amount a bidder can bid at the start of an auction.
// auctionType - type of auction, represented as the formatted bytes 32 string
struct Auction {
address payable auctionCreator;
uint256 creationBlock;
uint256 startingTime;
uint256 lengthOfAuction;
address currencyAddress;
uint256 minimumBid;
bytes32 auctionType;
address payable[] splitRecipients;
uint8[] splitRatios;
}
struct Bid {
address payable bidder;
address currencyAddress;
uint256 amount;
uint8 marketplaceFee;
}
/////////////////////////////////////////////////////////////////////////
// Events
/////////////////////////////////////////////////////////////////////////
event Sold(
address indexed _originContract,
address indexed _buyer,
address indexed _seller,
address _currencyAddress,
uint256 _amount,
uint256 _tokenId
);
event SetSalePrice(
address indexed _originContract,
address indexed _currencyAddress,
address _target,
uint256 _amount,
uint256 _tokenId,
address payable[] _splitRecipients,
uint8[] _splitRatios
);
event OfferPlaced(
address indexed _originContract,
address indexed _bidder,
address indexed _currencyAddress,
uint256 _amount,
uint256 _tokenId,
bool _convertible
);
event AcceptOffer(
address indexed _originContract,
address indexed _bidder,
address indexed _seller,
address _currencyAddress,
uint256 _amount,
uint256 _tokenId,
address payable[] _splitAddresses,
uint8[] _splitRatios
);
event CancelOffer(
address indexed _originContract,
address indexed _bidder,
address indexed _currencyAddress,
uint256 _amount,
uint256 _tokenId
);
event NewAuction(
address indexed _contractAddress,
uint256 indexed _tokenId,
address indexed _auctionCreator,
address _currencyAddress,
uint256 _startingTime,
uint256 _minimumBid,
uint256 _lengthOfAuction
);
event CancelAuction(
address indexed _contractAddress,
uint256 indexed _tokenId,
address indexed _auctionCreator
);
event AuctionBid(
address indexed _contractAddress,
address indexed _bidder,
uint256 indexed _tokenId,
address _currencyAddress,
uint256 _amount,
bool _startedAuction,
uint256 _newAuctionLength,
address _previousBidder
);
event AuctionSettled(
address indexed _contractAddress,
address indexed _bidder,
address _seller,
uint256 indexed _tokenId,
address _currencyAddress,
uint256 _amount
);
/////////////////////////////////////////////////////////////////////////
// State Variables
/////////////////////////////////////////////////////////////////////////
// Current marketplace settings implementation to be used
IMarketplaceSettings public marketplaceSettings;
// Current creator royalty implementation to be used
IERC721CreatorRoyalty public royaltyRegistry;
// Address of the global royalty engine being used.
IRoyaltyEngineV1 public royaltyEngine;
// Current SuperRareMarketplace implementation to be used
address public superRareMarketplace;
// Current SuperRareAuctionHouse implementation to be used
address public superRareAuctionHouse;
// Current SpaceOperatorRegistry implementation to be used.
ISpaceOperatorRegistry public spaceOperatorRegistry;
// Current ApprovedTokenRegistry implementation being used for currencies.
IApprovedTokenRegistry public approvedTokenRegistry;
// Current payments contract to use
IPayments public payments;
// Address to be used for staking registry.
address public stakingRegistry;
// Address of the network beneficiary
address public networkBeneficiary;
// A minimum increase in bid amount when out bidding someone.
uint8 public minimumBidIncreasePercentage; // 10 = 10%
// Maximum length that an auction can be.
uint256 public maxAuctionLength;
// Extension length for an auction
uint256 public auctionLengthExtension;
// Offer cancellation delay
uint256 public offerCancelationDelay;
// Mapping from contract to mapping of tokenId to mapping of target to sale price.
mapping(address => mapping(uint256 => mapping(address => SalePrice)))
public tokenSalePrices;
// Mapping from contract to mapping of tokenId to mapping of currency address to Current Offer.
mapping(address => mapping(uint256 => mapping(address => Offer)))
public tokenCurrentOffers;
// Mapping from contract to mapping of tokenId to Auction.
mapping(address => mapping(uint256 => Auction)) public tokenAuctions;
// Mapping from contract to mapping of tokenId to Bid.
mapping(address => mapping(uint256 => Bid)) public auctionBids;
uint256[50] private __gap;
/// ALL NEW STORAGE MUST COME AFTER THIS
}
// File: contracts/bazaar/ISuperRareBazaar.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;
/// @author koloz
/// @title ISuperRareBazaar
/// @notice Interface for the SuperRareBazaar Contract
interface ISuperRareBazaar {
// Marketplace Functions
// Buyer
/// @notice Create an offer for a given asset
/// @param _originContract Contract address of the asset being listed.
/// @param _tokenId Token Id of the asset.
/// @param _currencyAddress Address of the token being offered.
/// @param _amount Amount being offered.
/// @param _convertible If the offer can be converted into an auction
function offer(
address _originContract,
uint256 _tokenId,
address _currencyAddress,
uint256 _amount,
bool _convertible
) external payable;
/// @notice Purchases the token for the current sale price.
/// @param _originContract Contract address for asset being bought.
/// @param _tokenId TokenId of asset being bought.
/// @param _currencyAddress Currency address of asset being used to buy.
/// @param _amount Amount the piece if being bought for.
function buy(
address _originContract,
uint256 _tokenId,
address _currencyAddress,
uint256 _amount
) external payable;
/// @notice Cancels an existing offer the sender has placed on a piece.
/// @param _originContract Contract address of token.
/// @param _tokenId TokenId that has an offer.
/// @param _currencyAddress Currency address of the offer.
function cancelOffer(
address _originContract,
uint256 _tokenId,
address _currencyAddress
) external;
// Seller
/// @notice Sets a sale price for the given asset(s).
/// @param _originContract Contract address of the asset being listed.
/// @param _tokenId Token Id of the asset.
/// @param _currencyAddress Contract address of the currency asset is being listed for.
/// @param _listPrice Amount of the currency the asset is being listed for (including all decimal points).
/// @param _target Address of the person this sale price is target to.
/// @param _splitAddresses Addresses to split the sellers commission with.
/// @param _splitRatios The ratio for the split corresponding to each of the addresses being split with.
function setSalePrice(
address _originContract,
uint256 _tokenId,
address _currencyAddress,
uint256 _listPrice,
address _target,
address payable[] calldata _splitAddresses,
uint8[] calldata _splitRatios
) external;
/// @notice Removes the current sale price of an asset for the given currency.
/// @param _originContract The origin contract of the asset.
/// @param _tokenId The tokenId of the asset within the _originContract.
/// @param _target The address of the person
function removeSalePrice(
address _originContract,
uint256 _tokenId,
address _target
) external;
/// @notice Accept an offer placed on _originContract : _tokenId.
/// @param _originContract Contract of the asset the offer was made on.
/// @param _tokenId TokenId of the asset.
/// @param _currencyAddress Address of the currency used for the offer.
/// @param _amount Amount the offer was for/and is being accepted.
/// @param _splitAddresses Addresses to split the sellers commission with.
/// @param _splitRatios The ratio for the split corresponding to each of the addresses being split with.
function acceptOffer(
address _originContract,
uint256 _tokenId,
address _currencyAddress,
uint256 _amount,
address payable[] calldata _splitAddresses,
uint8[] calldata _splitRatios
) external;
// Auction House
// Anyone
/// @notice Settles an auction that has ended.
/// @param _originContract Contract address of asset.
/// @param _tokenId Token Id of the asset.
function settleAuction(address _originContract, uint256 _tokenId) external;
// Buyer
/// @notice Places a bid on a valid auction.
/// @param _originContract Contract address of asset being bid on.
/// @param _tokenId Token Id of the asset.
/// @param _currencyAddress Address of currency being used to bid.
/// @param _amount Amount of the currency being used for the bid.
function bid(
address _originContract,
uint256 _tokenId,
address _currencyAddress,
uint256 _amount
) external payable;
// Seller
/// @notice Configures an Auction for a given asset.
/// @param _auctionType The type of auction being configured.
/// @param _originContract Contract address of the asset being put up for auction.
/// @param _tokenId Token Id of the asset.
/// @param _startingAmount The reserve price or min bid of an auction.
/// @param _currencyAddress The currency the auction is being conducted in.
/// @param _lengthOfAuction The amount of time in seconds that the auction is configured for.
/// @param _splitAddresses Addresses to split the sellers commission with.
/// @param _splitRatios The ratio for the split corresponding to each of the addresses being split with.
function configureAuction(
bytes32 _auctionType,
address _originContract,
uint256 _tokenId,
uint256 _startingAmount,
address _currencyAddress,
uint256 _lengthOfAuction,
uint256 _startTime,
address payable[] calldata _splitAddresses,
uint8[] calldata _splitRatios
) external;
/// @notice Cancels a configured Auction that has not started.
/// @param _originContract Contract address of the asset pending auction.
/// @param _tokenId Token Id of the asset.
function cancelAuction(address _originContract, uint256 _tokenId) external;
/// @notice Converts an offer into a coldie auction.
/// @param _originContract Contract address of the asset.
/// @param _tokenId Token Id of the asset.
/// @param _currencyAddress Address of the currency being converted.
/// @param _amount Amount being converted into an auction.
/// @param _lengthOfAuction Number of seconds the auction will last.
/// @param _splitAddresses Addresses that the sellers take in will be split amongst.
/// @param _splitRatios Ratios that the take in will be split by.
function convertOfferToAuction(
address _originContract,
uint256 _tokenId,
address _currencyAddress,
uint256 _amount,
uint256 _lengthOfAuction,
address payable[] calldata _splitAddresses,
uint8[] calldata _splitRatios
) external;
/// @notice Grabs the current auction details for a token.
/// @param _originContract Contract address of asset.
/// @param _tokenId Token Id of the asset.
/** @return Auction Struct: creatorAddress, creationTime, startingTime, lengthOfAuction,
currencyAddress, minimumBid, auctionType, splitRecipients array, and splitRatios array.
*/
function getAuctionDetails(address _originContract, uint256 _tokenId)
external
view
returns (
address,
uint256,
uint256,
uint256,
address,
uint256,
bytes32,
address payable[] calldata,
uint8[] calldata
);
function getSalePrice(
address _originContract,
uint256 _tokenId,
address _target
)
external
view
returns (
address,
address,
uint256,
address payable[] memory,
uint8[] memory
);
}
// File: @openzeppelin/contracts-upgradeable-0.7.2/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../proxy/Initializable.sol";
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal initializer {
__Context_init_unchained();
}
function __Context_init_unchained() internal initializer {
}
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
uint256[50] private __gap;
}
// File: @openzeppelin/contracts-upgradeable-0.7.2/proxy/Initializable.sol
// SPDX-License-Identifier: MIT
// solhint-disable-next-line compiler-version
pragma solidity >=0.4.24 <0.8.0;
import "../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
*/
bool private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Modifier to protect an initializer function from being invoked twice.
*/
modifier initializer() {
require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized");
bool isTopLevelCall = !_initializing;
if (isTopLevelCall) {
_initializing = true;
_initialized = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
}
}
/// @dev Returns true if and only if the function is running in the constructor
function _isConstructor() private view returns (bool) {
return !AddressUpgradeable.isContract(address(this));
}
}
// File: @openzeppelin/contracts-upgradeable-0.7.2/utils/AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts-0.7.2/introspection/IERC165.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// File: contracts/marketplace/IMarketplaceSettings.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;
/**
* @title IMarketplaceSettings Settings governing a marketplace.
*/
interface IMarketplaceSettings {
/////////////////////////////////////////////////////////////////////////
// Marketplace Min and Max Values
/////////////////////////////////////////////////////////////////////////
/**
* @dev Get the max value to be used with the marketplace.
* @return uint256 wei value.
*/
function getMarketplaceMaxValue() external view returns (uint256);
/**
* @dev Get the max value to be used with the marketplace.
* @return uint256 wei value.
*/
function getMarketplaceMinValue() external view returns (uint256);
/////////////////////////////////////////////////////////////////////////
// Marketplace Fee
/////////////////////////////////////////////////////////////////////////
/**
* @dev Get the marketplace fee percentage.
* @return uint8 wei fee.
*/
function getMarketplaceFeePercentage() external view returns (uint8);
/**
* @dev Utility function for calculating the marketplace fee for given amount of wei.
* @param _amount uint256 wei amount.
* @return uint256 wei fee.
*/
function calculateMarketplaceFee(uint256 _amount)
external
view
returns (uint256);
/////////////////////////////////////////////////////////////////////////
// Primary Sale Fee
/////////////////////////////////////////////////////////////////////////
/**
* @dev Get the primary sale fee percentage for a specific ERC721 contract.
* @param _contractAddress address ERC721Contract address.
* @return uint8 wei primary sale fee.
*/
function getERC721ContractPrimarySaleFeePercentage(address _contractAddress)
external
view
returns (uint8);
/**
* @dev Utility function for calculating the primary sale fee for given amount of wei
* @param _contractAddress address ERC721Contract address.
* @param _amount uint256 wei amount.
* @return uint256 wei fee.
*/
function calculatePrimarySaleFee(address _contractAddress, uint256 _amount)
external
view
returns (uint256);
/**
* @dev Check whether the ERC721 token has sold at least once.
* @param _contractAddress address ERC721Contract address.
* @param _tokenId uint256 token ID.
* @return bool of whether the token has sold.
*/
function hasERC721TokenSold(address _contractAddress, uint256 _tokenId)
external
view
returns (bool);
/**
* @dev Mark a token as sold.
* Requirements:
*
* - `_contractAddress` cannot be the zero address.
* @param _contractAddress address ERC721Contract address.
* @param _tokenId uint256 token ID.
* @param _hasSold bool of whether the token should be marked sold or not.
*/
function markERC721Token(
address _contractAddress,
uint256 _tokenId,
bool _hasSold
) external;
function setERC721ContractPrimarySaleFeePercentage(
address _contractAddress,
uint8 _percentage
) external;
}
// File: contracts/royalty/creator/IERC721CreatorRoyalty.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;
import "../../token/ERC721/IERC721TokenCreator.sol";
/**
* @title IERC721CreatorRoyalty Token level royalty interface.
*/
interface IERC721CreatorRoyalty is IERC721TokenCreator {
/**
* @dev Get the royalty fee percentage for a specific ERC721 contract.
* @param _contractAddress address ERC721Contract address.
* @param _tokenId uint256 token ID.
* @return uint8 wei royalty fee.
*/
function getERC721TokenRoyaltyPercentage(
address _contractAddress,
uint256 _tokenId
) external view returns (uint8);
/**
* @dev Utililty function to calculate the royalty fee for a token.
* @param _contractAddress address ERC721Contract address.
* @param _tokenId uint256 token ID.
* @param _amount uint256 wei amount.
* @return uint256 wei fee.
*/
function calculateRoyaltyFee(
address _contractAddress,
uint256 _tokenId,
uint256 _amount
) external view returns (uint256);
/**
* @dev Utililty function to set the royalty percentage for a specific ERC721 contract.
* @param _contractAddress address ERC721Contract address.
* @param _percentage percentage for royalty
*/
function setPercentageForSetERC721ContractRoyalty(
address _contractAddress,
uint8 _percentage
) external;
}
// File: contracts/payments/IPayments.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;
/// @author koloz
/// @title IPayments
/// @notice Interface for the Payments contract used.
interface IPayments {
function refund(address _payee, uint256 _amount) external payable;
function payout(address[] calldata _splits, uint256[] calldata _amounts)
external
payable;
}
// File: contracts/registry/spaces/ISpaceOperatorRegistry.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;
/// @author koloz
/// @title ISpaceOperatorRegistry
/// @notice The interface for the SpaceOperatorRegistry
interface ISpaceOperatorRegistry {
function getPlatformCommission(address _operator)
external
view
returns (uint8);
function setPlatformCommission(address _operator, uint8 _commission)
external;
function isApprovedSpaceOperator(address _operator)
external
view
returns (bool);
function setSpaceOperatorApproved(address _operator, bool _approved)
external;
}
// File: contracts/registry/token/IApprovedTokenRegistry.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;
interface IApprovedTokenRegistry {
/// @notice Returns if a token has been approved or not.
/// @param _tokenContract Contract of token being checked.
/// @return True if the token is allowed, false otherwise.
function isApprovedToken(address _tokenContract)
external
view
returns (bool);
/// @notice Adds a token to the list of approved tokens.
/// @param _tokenContract Contract of token being approved.
function addApprovedToken(address _tokenContract) external;
/// @notice Removes a token from the approved tokens list.
/// @param _tokenContract Contract of token being approved.
function removeApprovedToken(address _tokenContract) external;
/// @notice Sets whether all token contracts should be approved.
/// @param _allTokensApproved Bool denoting if all tokens should be approved.
function setAllTokensApproved(bool _allTokensApproved) external;
}
// File: contracts/royalty/creator/IRoyaltyEngine.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;
/// @author: manifold.xyz
/**
* @dev Lookup engine interface
*/
interface IRoyaltyEngineV1 {
/**
* Get the royalty for a given token (address, id) and value amount. Does not cache the bps/amounts. Caches the spec for a given token address
*
* @param tokenAddress - The address of the token
* @param tokenId - The id of the token
* @param value - The value you wish to get the royalty of
*
* returns Two arrays of equal length, royalty recipients and the corresponding amount each recipient should get
*/
function getRoyalty(
address tokenAddress,
uint256 tokenId,
uint256 value
)
external
returns (address payable[] memory recipients, uint256[] memory amounts);
/**
* View only version of getRoyalty
*
* @param tokenAddress - The address of the token
* @param tokenId - The id of the token
* @param value - The value you wish to get the royalty of
*
* returns Two arrays of equal length, royalty recipients and the corresponding amount each recipient should get
*/
function getRoyaltyView(
address tokenAddress,
uint256 tokenId,
uint256 value
)
external
view
returns (address payable[] memory recipients, uint256[] memory amounts);
}
// File: contracts/token/ERC721/IERC721TokenCreator.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.3;
interface IERC721TokenCreator {
function tokenCreator(address _contractAddress, uint256 _tokenId)
external
view
returns (address payable);
}
| [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["18"]}, {"defect": "DelegateCall", "type": "Function_call", "severity": "High", "lines": ["235", "439", "415", "185", "213", "335", "462", "377", "269", "483"]}, {"defect": "Frozen_Ether", "type": "Code_specification", "severity": "Medium", "lines": ["18"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["18"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["1046", "1028", "1067", "1034", "1037", "1043", "873", "1061", "1078", "1058", "1049", "1040", "1080", "1064", "1052", "1025", "1031", "1055", "1071", "1075"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["26", "629", "602", "748", "617"]}] | [{"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"contracts/token/ERC721/IERC721TokenCreator.sol": [2]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 626, "severity": 1}, {"rule": "SOLIDITY_LOCKED_MONEY", "line": 18, "severity": 3}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 72, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 80, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 85, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 90, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 98, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 106, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 114, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 122, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 127, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 132, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 140, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 146, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 150, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 157, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 567, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 647, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 720, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 720, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1291, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1291, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1329, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1329, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1388, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1558, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1558, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 584, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 638, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 678, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 679, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 681, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 711, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1080, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1319, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1350, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1355, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 1411, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 1257, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 1276, "severity": 1}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 185, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 213, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 235, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 269, "severity": 3}, {"rule": "SOLIDITY_VISIBILITY", "line": 260, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1144, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1171, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1213, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1238, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1438, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 266, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 267, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 269, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 269, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 282, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 282, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 952, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 953, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 972, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 973, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1150, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1151, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1176, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1177, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1221, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1222, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1244, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1245, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1265, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1266, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1438, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1438, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1439, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1439, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1439, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1439, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1442, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1442, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1442, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1833, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1833, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1851, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1851, "severity": 1}] | [{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_originContract","type":"address"},{"indexed":true,"internalType":"address","name":"_bidder","type":"address"},{"indexed":true,"internalType":"address","name":"_seller","type":"address"},{"indexed":false,"internalType":"address","name":"_currencyAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"address payable[]","name":"_splitAddresses","type":"address[]"},{"indexed":false,"internalType":"uint8[]","name":"_splitRatios","type":"uint8[]"}],"name":"AcceptOffer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_contractAddress","type":"address"},{"indexed":true,"internalType":"address","name":"_bidder","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"_currencyAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"bool","name":"_startedAuction","type":"bool"},{"indexed":false,"internalType":"uint256","name":"_newAuctionLength","type":"uint256"},{"indexed":false,"internalType":"address","name":"_previousBidder","type":"address"}],"name":"AuctionBid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_contractAddress","type":"address"},{"indexed":true,"internalType":"address","name":"_bidder","type":"address"},{"indexed":false,"internalType":"address","name":"_seller","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"address","name":"_currencyAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"AuctionSettled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_contractAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"_auctionCreator","type":"address"}],"name":"CancelAuction","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_originContract","type":"address"},{"indexed":true,"internalType":"address","name":"_bidder","type":"address"},{"indexed":true,"internalType":"address","name":"_currencyAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"CancelOffer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_contractAddress","type":"address"},{"indexed":true,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"_auctionCreator","type":"address"},{"indexed":false,"internalType":"address","name":"_currencyAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_startingTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_minimumBid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_lengthOfAuction","type":"uint256"}],"name":"NewAuction","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_originContract","type":"address"},{"indexed":true,"internalType":"address","name":"_bidder","type":"address"},{"indexed":true,"internalType":"address","name":"_currencyAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"bool","name":"_convertible","type":"bool"}],"name":"OfferPlaced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_originContract","type":"address"},{"indexed":true,"internalType":"address","name":"_currencyAddress","type":"address"},{"indexed":false,"internalType":"address","name":"_target","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_tokenId","type":"uint256"},{"indexed":false,"internalType":"address payable[]","name":"_splitRecipients","type":"address[]"},{"indexed":false,"internalType":"uint8[]","name":"_splitRatios","type":"uint8[]"}],"name":"SetSalePrice","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_originContract","type":"address"},{"indexed":true,"internalType":"address","name":"_buyer","type":"address"},{"indexed":true,"internalType":"address","name":"_seller","type":"address"},{"indexed":false,"internalType":"address","name":"_currencyAddress","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"Sold","type":"event"},{"inputs":[],"name":"COLDIE_AUCTION","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NO_AUCTION","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SCHEDULED_AUCTION","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_originContract","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_currencyAddress","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address payable[]","name":"_splitAddresses","type":"address[]"},{"internalType":"uint8[]","name":"_splitRatios","type":"uint8[]"}],"name":"acceptOffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"approvedTokenRegistry","outputs":[{"internalType":"contract IApprovedTokenRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"auctionBids","outputs":[{"internalType":"address payable","name":"bidder","type":"address"},{"internalType":"address","name":"currencyAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint8","name":"marketplaceFee","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"auctionLengthExtension","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_originContract","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_currencyAddress","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"bid","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_originContract","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_currencyAddress","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"buy","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_originContract","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"cancelAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_originContract","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_currencyAddress","type":"address"}],"name":"cancelOffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_auctionType","type":"bytes32"},{"internalType":"address","name":"_originContract","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint256","name":"_startingAmount","type":"uint256"},{"internalType":"address","name":"_currencyAddress","type":"address"},{"internalType":"uint256","name":"_lengthOfAuction","type":"uint256"},{"internalType":"uint256","name":"_startTime","type":"uint256"},{"internalType":"address payable[]","name":"_splitAddresses","type":"address[]"},{"internalType":"uint8[]","name":"_splitRatios","type":"uint8[]"}],"name":"configureAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_originContract","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_currencyAddress","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_lengthOfAuction","type":"uint256"},{"internalType":"address payable[]","name":"_splitAddresses","type":"address[]"},{"internalType":"uint8[]","name":"_splitRatios","type":"uint8[]"}],"name":"convertOfferToAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_originContract","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getAuctionDetails","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"address payable[]","name":"","type":"address[]"},{"internalType":"uint8[]","name":"","type":"uint8[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_originContract","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_target","type":"address"}],"name":"getSalePrice","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address payable[]","name":"","type":"address[]"},{"internalType":"uint8[]","name":"","type":"uint8[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_marketplaceSettings","type":"address"},{"internalType":"address","name":"_royaltyRegistry","type":"address"},{"internalType":"address","name":"_royaltyEngine","type":"address"},{"internalType":"address","name":"_superRareMarketplace","type":"address"},{"internalType":"address","name":"_superRareAuctionHouse","type":"address"},{"internalType":"address","name":"_spaceOperatorRegistry","type":"address"},{"internalType":"address","name":"_approvedTokenRegistry","type":"address"},{"internalType":"address","name":"_payments","type":"address"},{"internalType":"address","name":"_stakingRegistry","type":"address"},{"internalType":"address","name":"_networkBeneficiary","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"marketplaceSettings","outputs":[{"internalType":"contract IMarketplaceSettings","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxAuctionLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minimumBidIncreasePercentage","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"networkBeneficiary","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_originContract","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_currencyAddress","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bool","name":"_convertible","type":"bool"}],"name":"offer","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"offerCancelationDelay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"payments","outputs":[{"internalType":"contract IPayments","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_originContract","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_target","type":"address"}],"name":"removeSalePrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"royaltyEngine","outputs":[{"internalType":"contract IRoyaltyEngineV1","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"royaltyRegistry","outputs":[{"internalType":"contract IERC721CreatorRoyalty","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_approvedTokenRegistry","type":"address"}],"name":"setApprovedTokenRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_auctionLengthExtension","type":"uint256"}],"name":"setAuctionLengthExtension","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_marketplaceSettings","type":"address"}],"name":"setMarketplaceSettings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"_maxAuctionLength","type":"uint8"}],"name":"setMaxAuctionLength","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"_minimumBidIncreasePercentage","type":"uint8"}],"name":"setMinimumBidIncreasePercentage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_networkBeneficiary","type":"address"}],"name":"setNetworkBeneficiary","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_offerCancelationDelay","type":"uint256"}],"name":"setOfferCancelationDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_payments","type":"address"}],"name":"setPayments","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_royaltyEngine","type":"address"}],"name":"setRoyaltyEngine","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_royaltyRegistry","type":"address"}],"name":"setRoyaltyRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_originContract","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_currencyAddress","type":"address"},{"internalType":"uint256","name":"_listPrice","type":"uint256"},{"internalType":"address","name":"_target","type":"address"},{"internalType":"address payable[]","name":"_splitAddresses","type":"address[]"},{"internalType":"uint8[]","name":"_splitRatios","type":"uint8[]"}],"name":"setSalePrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_spaceOperatorRegistry","type":"address"}],"name":"setSpaceOperatorRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stakingRegistry","type":"address"}],"name":"setStakingRegistry","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_superRareAuctionHouse","type":"address"}],"name":"setSuperRareAuctionHouse","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_superRareMarketplace","type":"address"}],"name":"setSuperRareMarketplace","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_originContract","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"settleAuction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"spaceOperatorRegistry","outputs":[{"internalType":"contract ISpaceOperatorRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakingRegistry","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"superRareAuctionHouse","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"superRareMarketplace","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"tokenAuctions","outputs":[{"internalType":"address payable","name":"auctionCreator","type":"address"},{"internalType":"uint256","name":"creationBlock","type":"uint256"},{"internalType":"uint256","name":"startingTime","type":"uint256"},{"internalType":"uint256","name":"lengthOfAuction","type":"uint256"},{"internalType":"address","name":"currencyAddress","type":"address"},{"internalType":"uint256","name":"minimumBid","type":"uint256"},{"internalType":"bytes32","name":"auctionType","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"tokenCurrentOffers","outputs":[{"internalType":"address payable","name":"buyer","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"uint8","name":"marketplaceFee","type":"uint8"},{"internalType":"bool","name":"convertible","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"tokenSalePrices","outputs":[{"internalType":"address payable","name":"seller","type":"address"},{"internalType":"address","name":"currencyAddress","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}] | v0.7.3+commit.9bfce1f6 | true | 999 | Default | false | |||||
MYToken | 0x7c4e4c46352598699d493ad31d52e0f76ae8877f | Solidity | // Abstract contract for the full ERC 20 Token standard
// https://github.com/ethereum/EIPs/issues/20
pragma solidity ^0.4.8;
contract Token {
/* This is a slight change to the ERC20 base standard.
function totalSupply() constant returns (uint256 supply);
is replaced with:
uint256 public totalSupply;
This automatically creates a getter function for the totalSupply.
This is moved to the base contract since public getter functions are not
currently recognised as an implementation of the matching abstract
function by the compiler.
*/
/// total amount of tokens
uint256 public totalSupply;
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance);
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
/// @notice `msg.sender` approves `_spender` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of tokens to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success);
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
/*
You should inherit from StandardToken or, for a token like you would want to
deploy in something like Mist, see ProToken.sol.
(This implements ONLY the standard functions and NOTHING else.
If you deploy this, you won't have anything useful.)
Implements ERC 20 Token standard: https://github.com/ethereum/EIPs/issues/20
.*/
contract StandardToken is Token {
function transfer(address _to, uint256 _value) returns (bool success) {
//Default assumes totalSupply can't be over max (2^256 - 1).
//If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap.
//Replace the if with this one instead.
//if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[msg.sender] >= _value && _value > 0) {
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
} else { return false; }
}
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
//same as above. Replace this line with the following if you want to protect against wrapping uints.
//if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
balances[_to] += _value;
balances[_from] -= _value;
allowed[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
} else { return false; }
}
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
function approve(address _spender, uint256 _value) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];
}
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
}
contract MYToken is StandardToken {
function () {
//if ether is sent to this address, send it back.
revert();
}
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'Dif1.0'; //ProToken 1.0 standard. Just an arbitrary versioning scheme.
function MYToken(
uint256 _initialAmount,
string _tokenName,
uint8 _decimalUnits,
string _tokenSymbol
) {
balances[msg.sender] = _initialAmount; // Give the creator all initial tokens
totalSupply = _initialAmount; // Update total supply
name = _tokenName; // Set the name for display purposes
decimals = _decimalUnits; // Amount of decimals for display purposes
symbol = _tokenSymbol; // Set the symbol for display purposes
}
/* Approves and then calls the receiving contract */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
require(_spender.call(bytes4(bytes32(keccak256("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData));
return true;
}
} | [{"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["122", "16"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["67", "68", "78", "79", "80"]}] | [{"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"MYToken.sol": [122]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MYToken.sol": [39]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MYToken.sol": [106, 107, 108, 109]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MYToken.sol": [44]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MYToken.sol": [33]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MYToken.sol": [138, 139, 140, 141, 142, 143, 144, 145, 146, 147]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MYToken.sol": [26]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MYToken.sol": [20]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"MYToken.sol": [3]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"MYToken.sol": [145]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MYToken.sol": [138]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MYToken.sol": [96]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MYToken.sol": [90]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MYToken.sol": [96]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MYToken.sol": [61]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MYToken.sol": [61]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MYToken.sol": [74]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MYToken.sol": [138]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MYToken.sol": [74]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MYToken.sol": [90]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MYToken.sol": [138]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MYToken.sol": [74]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MYToken.sol": [86]}}] | [{"error": "Integer Underflow.", "line": 121, "level": "Warning"}, {"error": "Integer Underflow.", "line": 119, "level": "Warning"}, {"error": "Integer Underflow.", "line": 122, "level": "Warning"}, {"error": "Integer Overflow.", "line": 138, "level": "Warning"}, {"error": "Integer Overflow.", "line": 78, "level": "Warning"}] | [{"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 20, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 44, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 86, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 96, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 90, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3, "severity": 1}, {"rule": "SOLIDITY_REDUNDANT_FALLBACK_REJECT", "line": 106, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 145, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 20, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 26, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 33, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 39, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 44, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 61, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 74, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 86, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 90, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 96, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 106, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 124, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 138, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 100, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 101, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"version","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_initialAmount","type":"uint256"},{"name":"_tokenName","type":"string"},{"name":"_decimalUnits","type":"uint8"},{"name":"_tokenSymbol","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":false,"stateMutability":"nonpayable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"}] | v0.4.24+commit.e67f0147 | false | 200 | 00000000000000000000000000000000000000000000003635c9adc5dea000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000074d59546f6b656e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034d59540000000000000000000000000000000000000000000000000000000000 | Default | false | bzzr://726d6397bfc2b24cf71a65a3f292a73af836f869fc7f06185cfbbd0d2609e814 |
|||
NFT | 0xe7acedec9b330c27aa1c103f473eba6401c9f7bd | Solidity | // Sources flattened with hardhat v2.8.4 https://hardhat.org
// File @openzeppelin/contracts/utils/introspection/[email protected]
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// File @openzeppelin/contracts/token/ERC721/[email protected]
//
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
// File @openzeppelin/contracts/token/ERC721/[email protected]
//
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
// File @openzeppelin/contracts/token/ERC721/extensions/[email protected]
//
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
// File @openzeppelin/contracts/token/ERC721/extensions/[email protected]
//
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)
pragma solidity ^0.8.0;
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
// File @openzeppelin/contracts/utils/[email protected]
//
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File @openzeppelin/contracts/utils/[email protected]
//
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// File @openzeppelin/contracts/utils/[email protected]
//
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// File @openzeppelin/contracts/utils/introspection/[email protected]
//
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
// File hardhat/[email protected]
//
pragma solidity >= 0.4.22 <0.9.0;
library console {
address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);
function _sendLogPayload(bytes memory payload) private view {
uint256 payloadLength = payload.length;
address consoleAddress = CONSOLE_ADDRESS;
assembly {
let payloadStart := add(payload, 32)
let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0)
}
}
function log() internal view {
_sendLogPayload(abi.encodeWithSignature("log()"));
}
function logInt(int p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(int)", p0));
}
function logUint(uint p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint)", p0));
}
function logString(string memory p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string)", p0));
}
function logBool(bool p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool)", p0));
}
function logAddress(address p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address)", p0));
}
function logBytes(bytes memory p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes)", p0));
}
function logBytes1(bytes1 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes1)", p0));
}
function logBytes2(bytes2 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes2)", p0));
}
function logBytes3(bytes3 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes3)", p0));
}
function logBytes4(bytes4 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes4)", p0));
}
function logBytes5(bytes5 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes5)", p0));
}
function logBytes6(bytes6 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes6)", p0));
}
function logBytes7(bytes7 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes7)", p0));
}
function logBytes8(bytes8 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes8)", p0));
}
function logBytes9(bytes9 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes9)", p0));
}
function logBytes10(bytes10 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes10)", p0));
}
function logBytes11(bytes11 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes11)", p0));
}
function logBytes12(bytes12 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes12)", p0));
}
function logBytes13(bytes13 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes13)", p0));
}
function logBytes14(bytes14 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes14)", p0));
}
function logBytes15(bytes15 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes15)", p0));
}
function logBytes16(bytes16 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes16)", p0));
}
function logBytes17(bytes17 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes17)", p0));
}
function logBytes18(bytes18 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes18)", p0));
}
function logBytes19(bytes19 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes19)", p0));
}
function logBytes20(bytes20 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes20)", p0));
}
function logBytes21(bytes21 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes21)", p0));
}
function logBytes22(bytes22 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes22)", p0));
}
function logBytes23(bytes23 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes23)", p0));
}
function logBytes24(bytes24 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes24)", p0));
}
function logBytes25(bytes25 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes25)", p0));
}
function logBytes26(bytes26 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes26)", p0));
}
function logBytes27(bytes27 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes27)", p0));
}
function logBytes28(bytes28 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes28)", p0));
}
function logBytes29(bytes29 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes29)", p0));
}
function logBytes30(bytes30 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes30)", p0));
}
function logBytes31(bytes31 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes31)", p0));
}
function logBytes32(bytes32 p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bytes32)", p0));
}
function log(uint p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint)", p0));
}
function log(string memory p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string)", p0));
}
function log(bool p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool)", p0));
}
function log(address p0) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address)", p0));
}
function log(uint p0, uint p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint)", p0, p1));
}
function log(uint p0, string memory p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string)", p0, p1));
}
function log(uint p0, bool p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool)", p0, p1));
}
function log(uint p0, address p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address)", p0, p1));
}
function log(string memory p0, uint p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint)", p0, p1));
}
function log(string memory p0, string memory p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string)", p0, p1));
}
function log(string memory p0, bool p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool)", p0, p1));
}
function log(string memory p0, address p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address)", p0, p1));
}
function log(bool p0, uint p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint)", p0, p1));
}
function log(bool p0, string memory p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string)", p0, p1));
}
function log(bool p0, bool p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool)", p0, p1));
}
function log(bool p0, address p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address)", p0, p1));
}
function log(address p0, uint p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint)", p0, p1));
}
function log(address p0, string memory p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string)", p0, p1));
}
function log(address p0, bool p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool)", p0, p1));
}
function log(address p0, address p1) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address)", p0, p1));
}
function log(uint p0, uint p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint)", p0, p1, p2));
}
function log(uint p0, uint p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,string)", p0, p1, p2));
}
function log(uint p0, uint p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool)", p0, p1, p2));
}
function log(uint p0, uint p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,address)", p0, p1, p2));
}
function log(uint p0, string memory p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,uint)", p0, p1, p2));
}
function log(uint p0, string memory p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,string)", p0, p1, p2));
}
function log(uint p0, string memory p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,bool)", p0, p1, p2));
}
function log(uint p0, string memory p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,address)", p0, p1, p2));
}
function log(uint p0, bool p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint)", p0, p1, p2));
}
function log(uint p0, bool p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,string)", p0, p1, p2));
}
function log(uint p0, bool p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool)", p0, p1, p2));
}
function log(uint p0, bool p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,address)", p0, p1, p2));
}
function log(uint p0, address p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,uint)", p0, p1, p2));
}
function log(uint p0, address p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,string)", p0, p1, p2));
}
function log(uint p0, address p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,bool)", p0, p1, p2));
}
function log(uint p0, address p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,address)", p0, p1, p2));
}
function log(string memory p0, uint p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,uint)", p0, p1, p2));
}
function log(string memory p0, uint p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,string)", p0, p1, p2));
}
function log(string memory p0, uint p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,bool)", p0, p1, p2));
}
function log(string memory p0, uint p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,address)", p0, p1, p2));
}
function log(string memory p0, string memory p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,uint)", p0, p1, p2));
}
function log(string memory p0, string memory p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2));
}
function log(string memory p0, string memory p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,bool)", p0, p1, p2));
}
function log(string memory p0, string memory p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,address)", p0, p1, p2));
}
function log(string memory p0, bool p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,uint)", p0, p1, p2));
}
function log(string memory p0, bool p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,string)", p0, p1, p2));
}
function log(string memory p0, bool p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,bool)", p0, p1, p2));
}
function log(string memory p0, bool p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,address)", p0, p1, p2));
}
function log(string memory p0, address p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,uint)", p0, p1, p2));
}
function log(string memory p0, address p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,string)", p0, p1, p2));
}
function log(string memory p0, address p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,bool)", p0, p1, p2));
}
function log(string memory p0, address p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,address)", p0, p1, p2));
}
function log(bool p0, uint p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint)", p0, p1, p2));
}
function log(bool p0, uint p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,string)", p0, p1, p2));
}
function log(bool p0, uint p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool)", p0, p1, p2));
}
function log(bool p0, uint p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,address)", p0, p1, p2));
}
function log(bool p0, string memory p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,uint)", p0, p1, p2));
}
function log(bool p0, string memory p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,string)", p0, p1, p2));
}
function log(bool p0, string memory p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,bool)", p0, p1, p2));
}
function log(bool p0, string memory p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,address)", p0, p1, p2));
}
function log(bool p0, bool p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint)", p0, p1, p2));
}
function log(bool p0, bool p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,string)", p0, p1, p2));
}
function log(bool p0, bool p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool)", p0, p1, p2));
}
function log(bool p0, bool p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,address)", p0, p1, p2));
}
function log(bool p0, address p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,uint)", p0, p1, p2));
}
function log(bool p0, address p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,string)", p0, p1, p2));
}
function log(bool p0, address p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,bool)", p0, p1, p2));
}
function log(bool p0, address p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,address)", p0, p1, p2));
}
function log(address p0, uint p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,uint)", p0, p1, p2));
}
function log(address p0, uint p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,string)", p0, p1, p2));
}
function log(address p0, uint p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,bool)", p0, p1, p2));
}
function log(address p0, uint p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,address)", p0, p1, p2));
}
function log(address p0, string memory p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,uint)", p0, p1, p2));
}
function log(address p0, string memory p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,string)", p0, p1, p2));
}
function log(address p0, string memory p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,bool)", p0, p1, p2));
}
function log(address p0, string memory p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,address)", p0, p1, p2));
}
function log(address p0, bool p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,uint)", p0, p1, p2));
}
function log(address p0, bool p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,string)", p0, p1, p2));
}
function log(address p0, bool p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,bool)", p0, p1, p2));
}
function log(address p0, bool p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,address)", p0, p1, p2));
}
function log(address p0, address p1, uint p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,uint)", p0, p1, p2));
}
function log(address p0, address p1, string memory p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,string)", p0, p1, p2));
}
function log(address p0, address p1, bool p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,bool)", p0, p1, p2));
}
function log(address p0, address p1, address p2) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,address)", p0, p1, p2));
}
function log(uint p0, uint p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,uint)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,string)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,bool)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,address)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,uint)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,string)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,bool)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,address)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,uint)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,string)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,bool)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,address)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,uint)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,string)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,bool)", p0, p1, p2, p3));
}
function log(uint p0, uint p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,address)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,uint)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,string)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,bool)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,address)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,string,uint)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,string,string)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,string,bool)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,string,address)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,uint)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,string)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,bool)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,address)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,address,uint)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,address,string)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,address,bool)", p0, p1, p2, p3));
}
function log(uint p0, string memory p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,string,address,address)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,uint)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,string)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,bool)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,address)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,uint)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,string)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,bool)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,address)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,uint)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,string)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,bool)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,address)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,uint)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,string)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,bool)", p0, p1, p2, p3));
}
function log(uint p0, bool p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,address)", p0, p1, p2, p3));
}
function log(uint p0, address p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,uint)", p0, p1, p2, p3));
}
function log(uint p0, address p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,string)", p0, p1, p2, p3));
}
function log(uint p0, address p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,bool)", p0, p1, p2, p3));
}
function log(uint p0, address p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,address)", p0, p1, p2, p3));
}
function log(uint p0, address p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,string,uint)", p0, p1, p2, p3));
}
function log(uint p0, address p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,string,string)", p0, p1, p2, p3));
}
function log(uint p0, address p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,string,bool)", p0, p1, p2, p3));
}
function log(uint p0, address p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,string,address)", p0, p1, p2, p3));
}
function log(uint p0, address p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,uint)", p0, p1, p2, p3));
}
function log(uint p0, address p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,string)", p0, p1, p2, p3));
}
function log(uint p0, address p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,bool)", p0, p1, p2, p3));
}
function log(uint p0, address p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,address)", p0, p1, p2, p3));
}
function log(uint p0, address p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,address,uint)", p0, p1, p2, p3));
}
function log(uint p0, address p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,address,string)", p0, p1, p2, p3));
}
function log(uint p0, address p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,address,bool)", p0, p1, p2, p3));
}
function log(uint p0, address p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(uint,address,address,address)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,uint)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,string)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,bool)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,address)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,string,uint)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,string,string)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,string,bool)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,string,address)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,uint)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,string)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,bool)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,address)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,address,uint)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,address,string)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,address,bool)", p0, p1, p2, p3));
}
function log(string memory p0, uint p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,uint,address,address)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,uint,uint)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,uint,string)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,uint,bool)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,uint,address)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,string,uint)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,string,string)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,string,bool)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,string,address)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,bool,uint)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,bool,string)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,bool,bool)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,bool,address)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,address,uint)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,address,string)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,address,bool)", p0, p1, p2, p3));
}
function log(string memory p0, string memory p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,string,address,address)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,uint)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,string)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,bool)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,address)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,string,uint)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,string,string)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,string,bool)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,string,address)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,uint)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,string)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,bool)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,address)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,address,uint)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,address,string)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,address,bool)", p0, p1, p2, p3));
}
function log(string memory p0, bool p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,bool,address,address)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,uint,uint)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,uint,string)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,uint,bool)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,uint,address)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,string,uint)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,string,string)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,string,bool)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,string,address)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,bool,uint)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,bool,string)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,bool,bool)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,bool,address)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,address,uint)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,address,string)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,address,bool)", p0, p1, p2, p3));
}
function log(string memory p0, address p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(string,address,address,address)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,uint)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,string)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,bool)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,address)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,uint)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,string)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,bool)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,address)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,uint)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,string)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,bool)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,address)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,uint)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,string)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,bool)", p0, p1, p2, p3));
}
function log(bool p0, uint p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,address)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,uint)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,string)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,bool)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,address)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,string,uint)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,string,string)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,string,bool)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,string,address)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,uint)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,string)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,bool)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,address)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,address,uint)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,address,string)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,address,bool)", p0, p1, p2, p3));
}
function log(bool p0, string memory p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,string,address,address)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,uint)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,string)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,bool)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,address)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,uint)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,string)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,bool)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,address)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,uint)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,string)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,bool)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,address)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,uint)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,string)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,bool)", p0, p1, p2, p3));
}
function log(bool p0, bool p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,address)", p0, p1, p2, p3));
}
function log(bool p0, address p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,uint)", p0, p1, p2, p3));
}
function log(bool p0, address p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,string)", p0, p1, p2, p3));
}
function log(bool p0, address p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,bool)", p0, p1, p2, p3));
}
function log(bool p0, address p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,address)", p0, p1, p2, p3));
}
function log(bool p0, address p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,string,uint)", p0, p1, p2, p3));
}
function log(bool p0, address p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,string,string)", p0, p1, p2, p3));
}
function log(bool p0, address p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,string,bool)", p0, p1, p2, p3));
}
function log(bool p0, address p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,string,address)", p0, p1, p2, p3));
}
function log(bool p0, address p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,uint)", p0, p1, p2, p3));
}
function log(bool p0, address p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,string)", p0, p1, p2, p3));
}
function log(bool p0, address p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,bool)", p0, p1, p2, p3));
}
function log(bool p0, address p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,address)", p0, p1, p2, p3));
}
function log(bool p0, address p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,address,uint)", p0, p1, p2, p3));
}
function log(bool p0, address p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,address,string)", p0, p1, p2, p3));
}
function log(bool p0, address p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,address,bool)", p0, p1, p2, p3));
}
function log(bool p0, address p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(bool,address,address,address)", p0, p1, p2, p3));
}
function log(address p0, uint p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,uint)", p0, p1, p2, p3));
}
function log(address p0, uint p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,string)", p0, p1, p2, p3));
}
function log(address p0, uint p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,bool)", p0, p1, p2, p3));
}
function log(address p0, uint p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,address)", p0, p1, p2, p3));
}
function log(address p0, uint p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,string,uint)", p0, p1, p2, p3));
}
function log(address p0, uint p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,string,string)", p0, p1, p2, p3));
}
function log(address p0, uint p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,string,bool)", p0, p1, p2, p3));
}
function log(address p0, uint p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,string,address)", p0, p1, p2, p3));
}
function log(address p0, uint p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,uint)", p0, p1, p2, p3));
}
function log(address p0, uint p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,string)", p0, p1, p2, p3));
}
function log(address p0, uint p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,bool)", p0, p1, p2, p3));
}
function log(address p0, uint p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,address)", p0, p1, p2, p3));
}
function log(address p0, uint p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,address,uint)", p0, p1, p2, p3));
}
function log(address p0, uint p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,address,string)", p0, p1, p2, p3));
}
function log(address p0, uint p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,address,bool)", p0, p1, p2, p3));
}
function log(address p0, uint p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,uint,address,address)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,uint,uint)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,uint,string)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,uint,bool)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,uint,address)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,string,uint)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,string,string)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,string,bool)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,string,address)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,bool,uint)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,bool,string)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,bool,bool)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,bool,address)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,address,uint)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,address,string)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,address,bool)", p0, p1, p2, p3));
}
function log(address p0, string memory p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,string,address,address)", p0, p1, p2, p3));
}
function log(address p0, bool p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,uint)", p0, p1, p2, p3));
}
function log(address p0, bool p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,string)", p0, p1, p2, p3));
}
function log(address p0, bool p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,bool)", p0, p1, p2, p3));
}
function log(address p0, bool p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,address)", p0, p1, p2, p3));
}
function log(address p0, bool p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,string,uint)", p0, p1, p2, p3));
}
function log(address p0, bool p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,string,string)", p0, p1, p2, p3));
}
function log(address p0, bool p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,string,bool)", p0, p1, p2, p3));
}
function log(address p0, bool p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,string,address)", p0, p1, p2, p3));
}
function log(address p0, bool p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,uint)", p0, p1, p2, p3));
}
function log(address p0, bool p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,string)", p0, p1, p2, p3));
}
function log(address p0, bool p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,bool)", p0, p1, p2, p3));
}
function log(address p0, bool p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,address)", p0, p1, p2, p3));
}
function log(address p0, bool p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,address,uint)", p0, p1, p2, p3));
}
function log(address p0, bool p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,address,string)", p0, p1, p2, p3));
}
function log(address p0, bool p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,address,bool)", p0, p1, p2, p3));
}
function log(address p0, bool p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,bool,address,address)", p0, p1, p2, p3));
}
function log(address p0, address p1, uint p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,uint,uint)", p0, p1, p2, p3));
}
function log(address p0, address p1, uint p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,uint,string)", p0, p1, p2, p3));
}
function log(address p0, address p1, uint p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,uint,bool)", p0, p1, p2, p3));
}
function log(address p0, address p1, uint p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,uint,address)", p0, p1, p2, p3));
}
function log(address p0, address p1, string memory p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,string,uint)", p0, p1, p2, p3));
}
function log(address p0, address p1, string memory p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,string,string)", p0, p1, p2, p3));
}
function log(address p0, address p1, string memory p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,string,bool)", p0, p1, p2, p3));
}
function log(address p0, address p1, string memory p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,string,address)", p0, p1, p2, p3));
}
function log(address p0, address p1, bool p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,bool,uint)", p0, p1, p2, p3));
}
function log(address p0, address p1, bool p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,bool,string)", p0, p1, p2, p3));
}
function log(address p0, address p1, bool p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,bool,bool)", p0, p1, p2, p3));
}
function log(address p0, address p1, bool p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,bool,address)", p0, p1, p2, p3));
}
function log(address p0, address p1, address p2, uint p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,address,uint)", p0, p1, p2, p3));
}
function log(address p0, address p1, address p2, string memory p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,address,string)", p0, p1, p2, p3));
}
function log(address p0, address p1, address p2, bool p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,address,bool)", p0, p1, p2, p3));
}
function log(address p0, address p1, address p2, address p3) internal view {
_sendLogPayload(abi.encodeWithSignature("log(address,address,address,address)", p0, p1, p2, p3));
}
}
// File @openzeppelin/contracts/utils/math/[email protected]
//
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
// File contracts/NFT.sol
error ApprovalCallerNotOwnerNorApproved();
error ApprovalQueryForNonexistentToken();
error ApproveToCaller();
error ApprovalToCurrentOwner();
error BalanceQueryForZeroAddress();
error MintedQueryForZeroAddress();
error BurnedQueryForZeroAddress();
error MintToZeroAddress();
error MintZeroQuantity();
error OwnerIndexOutOfBounds();
error OwnerQueryForNonexistentToken();
error TokenIndexOutOfBounds();
error TransferCallerNotOwnerNorApproved();
error TransferFromIncorrectOwner();
error TransferToNonERC721ReceiverImplementer();
error TransferToZeroAddress();
error URIQueryForNonexistentToken();
/**
*Submitted for verification at Etherscan.io on 2021-04-22
*/
// File: @openzeppelin/contracts/utils/Context.sol
//
pragma solidity >=0.6.0 <= 0.8.4;
/*
* @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.
*/
// Creator: Chiru Labs
pragma solidity ^0.8.4;
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints.
*
* Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..).
*
* Assumes that an owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
*
* Assumes that the maximum token id cannot exceed 2**256 - 1 (max value of uint256).
*/
contract ERC721A is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Compiler will pack this into a single 256bit word.
struct TokenOwnership {
// The address of the owner.
address addr;
// Keeps track of the start time of ownership with minimal overhead for tokenomics.
uint64 startTimestamp;
// Whether the token has been burned.
bool burned;
}
// Compiler will pack this into a single 256bit word.
struct AddressData {
// Realistically, 2**64-1 is more than enough.
uint64 balance;
// Keeps track of mint count with minimal overhead for tokenomics.
uint64 numberMinted;
// Keeps track of burn count with minimal overhead for tokenomics.
uint64 numberBurned;
}
// The tokenId of the next token to be minted.
uint256 internal _currentIndex;
// The number of tokens burned.
uint256 internal _burnCounter;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view returns (uint256) {
// Counter underflow is impossible as _burnCounter cannot be incremented
// more than _currentIndex times
unchecked {
return _currentIndex - _burnCounter;
}
}
/**
* @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 override returns (uint256) {
if (owner == address(0)) revert BalanceQueryForZeroAddress();
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
if (owner == address(0)) revert MintedQueryForZeroAddress();
return uint256(_addressData[owner].numberMinted);
}
function _numberBurned(address owner) internal view returns (uint256) {
if (owner == address(0)) revert BurnedQueryForZeroAddress();
return uint256(_addressData[owner].numberBurned);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
uint256 curr = tokenId;
unchecked {
if (curr < _currentIndex) {
TokenOwnership memory ownership = _ownerships[curr];
if (!ownership.burned) {
if (ownership.addr != address(0)) {
return ownership;
}
// Invariant:
// There will always be an ownership that has an address and is not burned
// before an ownership that does not have an address and is not burned.
// Hence, curr will not underflow.
while (true) {
curr--;
ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
}
}
}
revert OwnerQueryForNonexistentToken();
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
if (!_exists(tokenId)) revert URIQueryForNonexistentToken();
string memory baseURI = _baseURI();
return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : '';
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return '';
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public override {
address owner = ERC721A.ownerOf(tokenId);
if (to == owner) revert ApprovalToCurrentOwner();
if (_msgSender() != owner && !isApprovedForAll(owner, _msgSender())) {
revert ApprovalCallerNotOwnerNorApproved();
}
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
if (operator == _msgSender()) revert ApproveToCaller();
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
_transfer(from, to, tokenId);
if (!_checkOnERC721Received(from, to, tokenId, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < _currentIndex && !_ownerships[tokenId].burned;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = _currentIndex;
if (to == address(0)) revert MintToZeroAddress();
if (quantity == 0) revert MintZeroQuantity();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are incredibly unrealistic.
// balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1
// updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1
unchecked {
_addressData[to].balance += uint64(quantity);
_addressData[to].numberMinted += uint64(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe && !_checkOnERC721Received(address(0), to, updatedIndex, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
updatedIndex++;
}
_currentIndex = updatedIndex;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
isApprovedForAll(prevOwnership.addr, _msgSender()) ||
getApproved(tokenId) == _msgSender());
if (!isApprovedOrOwner) revert TransferCallerNotOwnerNorApproved();
if (prevOwnership.addr != from) revert TransferFromIncorrectOwner();
if (to == address(0)) revert TransferToZeroAddress();
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
// Counter overflow is incredibly unrealistic as tokenId would have to be 2**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)) {
// This will suffice for checking _exists(nextTokenId),
// as a burned slot cannot contain the zero address.
if (nextTokenId < _currentIndex) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
_beforeTokenTransfers(prevOwnership.addr, address(0), tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
// Counter overflow is incredibly unrealistic as tokenId would have to be 2**256.
unchecked {
_addressData[prevOwnership.addr].balance -= 1;
_addressData[prevOwnership.addr].numberBurned += 1;
// Keep track of who burned the token, and the timestamp of burning.
_ownerships[tokenId].addr = prevOwnership.addr;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
_ownerships[tokenId].burned = true;
// If the ownership slot of tokenId+1 is not explicitly set, that means the burn initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
// This will suffice for checking _exists(nextTokenId),
// as a burned slot cannot contain the zero address.
if (nextTokenId < _currentIndex) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
}
emit Transfer(prevOwnership.addr, address(0), tokenId);
_afterTokenTransfers(prevOwnership.addr, address(0), tokenId, 1);
// Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
unchecked {
_burnCounter++;
}
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert TransferToNonERC721ReceiverImplementer();
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
* And also called before burning one token.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, `from`'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, `tokenId` will be burned by `from`.
* - `from` and `to` are never both zero.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
* And also called after one token has been burned.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, `from`'s `tokenId` has been
* transferred to `to`.
* - When `from` is zero, `tokenId` has been minted for `to`.
* - When `to` is zero, `tokenId` has been burned by `from`.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
}
// File: @openzeppelin/contracts/access/Ownable.sol
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
pragma solidity >=0.6.0 <= 0.8.4;
/**
* @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;
}
}
// File: contracts/NFT.sol
pragma solidity ^0.8.4;
/**
* @title NFT contract
* @dev Extends ERC721 Non-Fungible Token Standard basic implementation
*/
contract NFT is ERC721A, Ownable, ReentrancyGuard {
using SafeMath for uint256;
using Strings for uint256;
bool public preSaleActive = false;
bool public publicSaleActive = false;
bool public paused = true;
bool public revealed = false;
string public NETWORK_PROVENANCE = "";
string public notRevealedUri;
uint256 public maxSupply; // 2500
uint256 public maxAirDropSupply; // 100
uint256 public currentAirDropSupply;
uint256 public preSalePrice; //0.05 ETH --> 50000000000000000
uint256 public publicSalePrice; //0.05 ETH --> 50000000000000000
uint public maxPurchase; // 2
uint public maxPurchaseOG; // 4
uint public publicPurchase; // 5
string private _baseURIextended;
mapping(address => bool) public isWhiteListed;
mapping(address => bool) public isWhiteListedOG;
constructor(string memory name, string memory symbol, uint256 _maxSupply, uint256 _publicPurchase, uint256 _maxPurchase, uint256 _maxPurchaseOG, uint256 _preSalePrice, uint256 _publicSalePrice, uint256 _maxAirDropSupply) ERC721A(name, symbol) ReentrancyGuard() {
maxSupply = _maxSupply;
preSalePrice = _preSalePrice;
publicSalePrice = _publicSalePrice;
publicPurchase = _publicPurchase;
maxPurchase = _maxPurchase;
maxPurchaseOG = _maxPurchaseOG;
maxAirDropSupply = _maxAirDropSupply;
}
function preSaleMint(uint256 _amount)external payable nonReentrant{
require(preSaleActive, "NFT:Pre-sale is not active");
require(isWhiteListed[msg.sender], "NFT:Sender is not whitelisted");
mint(_amount, true);
}
function publicSaleMint(uint256 _amount)external payable nonReentrant{
require(publicSaleActive, "NFT:Public-sale is not active");
mint(_amount, false);
}
function mint(uint256 _amount, bool _state)internal{
require(!paused, "NFT: contract is paused");
require(totalSupply().add(_amount) <= maxSupply, "NFT: minting would exceed total supply");
if(publicSaleActive){
require(balanceOf(msg.sender).add(_amount) <= publicPurchase, "NFT-Public: You can't mint any more tokens");
}
else{
if(isWhiteListedOG[msg.sender]){
require(balanceOf(msg.sender).add(_amount) <= maxPurchaseOG, "NFT-OG: You can't mint any more tokens");
}
else{
require(balanceOf(msg.sender).add(_amount) <= maxPurchase, "NFT: You can't mint any more tokens");
}
}
if(_state){
require(preSalePrice.mul(_amount) <= msg.value, "NFT: Ether value sent for presale mint is not correct");
}
else{
require(publicSalePrice.mul(_amount) <= msg.value, "NFT: Ether value sent for public mint is not correct");
}
uint mintIndex = totalSupply();
for (uint256 ind = 1; ind <= _amount; ind++) {
mintIndex.add(ind);
}
_safeMint(msg.sender, _amount);
}
function getTotalSupply() public view returns (uint){
return totalSupply();
}
function _baseURI() internal view virtual override returns (string memory) {
return _baseURIextended;
}
function setBaseURI(string calldata baseURI_) external onlyOwner {
_baseURIextended = baseURI_;
}
function addWhiteListedAddresses(address[] memory _address) external onlyOwner {
for (uint256 i = 0; i < _address.length; i++) {
require(!isWhiteListed[_address[i]], "NFT: address is already white listed");
isWhiteListed[_address[i]] = true;
}
}
function addWhiteListedAddressesOG(address[] memory _address) external onlyOwner {
for (uint256 i = 0; i < _address.length; i++) {
require(!isWhiteListedOG[_address[i]], "NFT: address is already OG listed");
isWhiteListed[_address[i]] = true;
isWhiteListedOG[_address[i]] = true;
}
}
function togglePauseState() external onlyOwner {
paused = !paused;
}
function togglePreSale()external onlyOwner {
preSaleActive = !preSaleActive;
}
function setPreSalePrice(uint256 _preSalePrice)external onlyOwner {
preSalePrice = _preSalePrice;
}
function togglePublicSale()external onlyOwner {
publicSaleActive = !publicSaleActive;
}
function setPublicSalePrice(uint256 _publicSalePrice)external onlyOwner {
publicSalePrice = _publicSalePrice;
}
function airDrop(address[] memory _address)external onlyOwner{
uint256 mintIndex = totalSupply();
require(currentAirDropSupply + _address.length <= maxAirDropSupply, "NFT: Maximum Air Drop Limit Reached");
require(mintIndex.add(_address.length) <= maxSupply, "NFT: minting would exceed total supply");
for(uint256 i = 0; i < _address.length; i++){
mintIndex.add(i);
_safeMint(_address[i],1);
}
currentAirDropSupply += _address.length;
}
function reveal() external onlyOwner {
revealed = true;
}
function withdraw() external onlyOwner {
uint balance = address(this).balance;
payable(msg.sender).transfer(balance);
}
/*
* Set provenance once it's calculated
*/
function setProvenanceHash(string memory provenanceHash) external onlyOwner {
NETWORK_PROVENANCE = provenanceHash;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if (revealed == false) {
return notRevealedUri;
}
tokenId+=1;
string memory currentBaseURI = _baseURI();
return
bytes(currentBaseURI).length > 0
? string(
abi.encodePacked(
currentBaseURI,
tokenId.toString(),
".json"
)
)
: "";
}
function setNotRevealedURI(string memory _notRevealedURI) external onlyOwner {
notRevealedUri = _notRevealedURI;
}
} | [{"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["3179", "3159", "3185", "3216", "2754"]}, {"defect": "DelegateCall", "type": "Function_call", "severity": "High", "lines": ["460"]}, {"defect": "Bad_randomness", "type": "Business_logic", "severity": "Medium", "lines": ["2750", "2851", "2805"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["3158", "567", "633", "634", "545"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["254", "2570", "3043", "3070", "63", "3058"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["3220", "3252", "2856", "2809"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [635, 636, 637, 638]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [2913, 2914, 2915]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [482, 483, 484, 485]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [3249]}}, {"check": "pragma", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [3084]}}, {"check": "costly-loop", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2762]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1413, 1414, 1415]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2117, 2118, 2119]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1569, 1570, 1571]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1965, 1966, 1967]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1717, 1718, 1719]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1929, 1930, 1931]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2097, 2098, 2099]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2013, 2014, 2015]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1997, 1998, 1999]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2085, 2086, 2087]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1909, 1910, 1911]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [669, 670, 671]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2268, 2269, 2270]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2125, 2126, 2127]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1573, 1574, 1575]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [685, 686, 687]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [793, 794, 795]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1117, 1118, 1119]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2129, 2130, 2131]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1825, 1826, 1827]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1537, 1538, 1539]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1297, 1298, 1299]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1813, 1814, 1815]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2121, 2122, 2123]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2225, 2226, 2227, 2228, 2229, 2230]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1749, 1750, 1751]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [997, 998, 999]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [993, 994, 995]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1833, 1834, 1835]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [889, 890, 891]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [632, 633, 634, 635, 636, 637, 638, 639]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [329, 330, 331, 332, 333, 334]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1169, 1170, 1171]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1905, 1906, 1907]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2834, 2835, 2836, 2837, 2838, 2839, 2840, 2841, 2842, 2843, 2844, 2845, 2846, 2847, 2848, 2849, 2850, 2851, 2852, 2853, 2854, 2855, 2856, 2857, 2858, 2859, 2860, 2861, 2862, 2863, 2864, 2865, 2866, 2867, 2868, 2869, 2870, 2871, 2872, 2873, 2874]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2025, 2026, 2027]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [384, 385, 386, 387, 388, 389, 383]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1641, 1642, 1643]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1949, 1950, 1951]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1085, 1086, 1087]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1841, 1842, 1843]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1025, 1026, 1027]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1593, 1594, 1595]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1993, 1994, 1995]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1005, 1006, 1007]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1121, 1122, 1123]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1781, 1782, 1783]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1293, 1294, 1295]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2101, 2102, 2103]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1313, 1314, 1315]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1201, 1202, 1203]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1885, 1886, 1887]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1309, 1310, 1311]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1073, 1074, 1075]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1053, 1054, 1055]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1193, 1194, 1195]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2073, 2074, 2075]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1409, 1410, 1411]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2045, 2046, 2047]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1881, 1882, 1883]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [881, 882, 883]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1125, 1126, 1127]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1157, 1158, 1159]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [957, 958, 959]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1697, 1698, 1699]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2145, 2146, 2147]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [725, 726, 727]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1065, 1066, 1067]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [869, 870, 871]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [961, 962, 963]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1481, 1482, 1483]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2065, 2066, 2067]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1001, 1002, 1003]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1613, 1614, 1615]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1737, 1738, 1739]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1645, 1646, 1647]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [677, 678, 679]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1793, 1794, 1795]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [921, 922, 923]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1489, 1490, 1491]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1797, 1798, 1799]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1589, 1590, 1591]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [697, 698, 699]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1789, 1790, 1791]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1829, 1830, 1831]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1209, 1210, 1211]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2240, 2241, 2242, 2237, 2238, 2239]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1893, 1894, 1895]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1437, 1438, 1439]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1149, 1150, 1151]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [765, 766, 767]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1773, 1774, 1775]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1473, 1474, 1475]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [705, 706, 707]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [453, 454, 455, 456, 457, 458, 459, 460, 461, 462]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [937, 938, 939]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [653, 654, 655]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1681, 1682, 1683]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2336, 2337, 2338, 2329, 2330, 2331, 2332, 2333, 2334, 2335]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2149, 2150, 2151]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1317, 1318, 1319]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2021, 2022, 2023]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1701, 1702, 1703]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1341, 1342, 1343]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [745, 746, 747]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2105, 2106, 2107]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [981, 982, 983]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1245, 1246, 1247]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1873, 1874, 1875]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1653, 1654, 1655]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1957, 1958, 1959]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1221, 1222, 1223]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1349, 1350, 1351]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1917, 1918, 1919]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1417, 1418, 1419]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1801, 1802, 1803]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [789, 790, 791]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [877, 878, 879]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1017, 1018, 1019]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2053, 2054, 2055]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1353, 1354, 1355]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [865, 866, 867]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2153, 2154, 2155]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1581, 1582, 1583]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1661, 1662, 1663]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [825, 826, 827]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [813, 814, 815]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [897, 898, 899]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [709, 710, 711]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1233, 1234, 1235]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1617, 1618, 1619]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [977, 978, 979]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [817, 818, 819]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [913, 914, 915]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1181, 1182, 1183]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [785, 786, 787]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [853, 854, 855]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1105, 1106, 1107]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1853, 1854, 1855]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [837, 838, 839]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1477, 1478, 1479]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1517, 1518, 1519]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1449, 1450, 1451]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2113, 2114, 2115]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1261, 1262, 1263]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1869, 1870, 1871]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1925, 1926, 1927]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1757, 1758, 1759]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [443, 444, 445]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [733, 734, 735]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1689, 1690, 1691]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [721, 722, 723]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1557, 1558, 1559]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1229, 1230, 1231]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1609, 1610, 1611]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [801, 802, 803]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1973, 1974, 1975]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1877, 1878, 1879]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1081, 1082, 1083]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1049, 1050, 1051]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1637, 1638, 1639]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [905, 906, 907]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1277, 1278, 1279]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1989, 1990, 1991]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [973, 974, 975]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1237, 1238, 1239]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1357, 1358, 1359]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1805, 1806, 1807]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1657, 1658, 1659]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1361, 1362, 1363]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2093, 2094, 2095]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1289, 1290, 1291]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1953, 1954, 1955]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1337, 1338, 1339]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1753, 1754, 1755]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2536, 2537, 2534, 2535]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [729, 730, 731]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1545, 1546, 1547]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1013, 1014, 1015]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2183, 2184, 2185, 2186, 2187, 2188, 2189]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1069, 1070, 1071]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [933, 934, 935]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1741, 1742, 1743]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [829, 830, 831]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1469, 1470, 1471]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [861, 862, 863]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1097, 1098, 1099]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2378, 2379, 2380, 2381, 2382, 2383, 2384, 2385, 2386, 2387]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1845, 1846, 1847]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1769, 1770, 1771]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1777, 1778, 1779]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1405, 1406, 1407]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [681, 682, 683]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2069, 2070, 2071]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2033, 2034, 2035]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1197, 1198, 1199]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1009, 1010, 1011]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1321, 1322, 1323]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1585, 1586, 1587]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1133, 1134, 1135]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [773, 774, 775]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1345, 1346, 1347]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1253, 1254, 1255]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2029, 2030, 2031]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1553, 1554, 1555]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1113, 1114, 1115]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [821, 822, 823]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1785, 1786, 1787]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1401, 1402, 1403]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [833, 834, 835]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1577, 1578, 1579]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [673, 674, 675]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1713, 1714, 1715]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1961, 1962, 1963]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1389, 1390, 1391]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1693, 1694, 1695]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2049, 2050, 2051]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1021, 1022, 1023]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1621, 1622, 1623]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1549, 1550, 1551]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1377, 1378, 1379]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2089, 2090, 2091]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2352, 2353, 2354, 2355, 2356, 2357, 2358, 2359, 2360, 2361]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1129, 1130, 1131]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1889, 1890, 1891]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1365, 1366, 1367]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [665, 666, 667]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1057, 1058, 1059]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1217, 1218, 1219]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1369, 1370, 1371]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1273, 1274, 1275]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1269, 1270, 1271]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1765, 1766, 1767]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [941, 942, 943]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [841, 842, 843]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1029, 1030, 1031]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1673, 1674, 1675]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [516, 517, 518]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1513, 1514, 1515]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2141, 2142, 2143]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1685, 1686, 1687]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [737, 738, 739]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1509, 1510, 1511]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1213, 1214, 1215]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [416, 417, 418]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2005, 2006, 2007]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1521, 1522, 1523]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1669, 1670, 1671]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [809, 810, 811]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1165, 1166, 1167]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1725, 1726, 1727]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1561, 1562, 1563]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1849, 1850, 1851]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1205, 1206, 1207]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1969, 1970, 1971]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [805, 806, 807]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [949, 950, 951]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1525, 1526, 1527]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1649, 1650, 1651]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1761, 1762, 1763]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1241, 1242, 1243]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1457, 1458, 1459]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1629, 1630, 1631]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1913, 1914, 1915]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1745, 1746, 1747]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1373, 1374, 1375]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1945, 1946, 1947]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1541, 1542, 1543]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1865, 1866, 1867]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1445, 1446, 1447]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2312, 2313, 2314]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1385, 1386, 1387]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1837, 1838, 1839]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1665, 1666, 1667]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [953, 954, 955]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [641, 642, 643]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1305, 1306, 1307]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1677, 1678, 1679]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1985, 1986, 1987]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1709, 1710, 1711]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1301, 1302, 1303]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1285, 1286, 1287]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1933, 1934, 1935]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [849, 850, 851]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1861, 1862, 1863]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [985, 986, 987]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [753, 754, 755]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1461, 1462, 1463]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2296, 2297, 2298]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1257, 1258, 1259]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1041, 1042, 1043]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1625, 1626, 1627]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1821, 1822, 1823]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1721, 1722, 1723]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1225, 1226, 1227]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1433, 1434, 1435]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1733, 1734, 1735]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1921, 1922, 1923]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1565, 1566, 1567]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1901, 1902, 1903]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1941, 1942, 1943]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1109, 1110, 1111]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1937, 1938, 1939]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [749, 750, 751]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1857, 1858, 1859]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1101, 1102, 1103]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2208, 2209, 2210, 2211, 2212, 2213, 2214, 2215, 2216, 2217, 2218]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1465, 1466, 1467]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2057, 2058, 2059]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2009, 2010, 2011]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1597, 1598, 1599]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2529, 2530, 2531, 2532]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [893, 894, 895]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [713, 714, 715]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1497, 1498, 1499]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1265, 1266, 1267]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2081, 2082, 2083]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1153, 1154, 1155]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [909, 910, 911]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2196, 2197, 2198, 2199, 2200, 2201]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [797, 798, 799]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1089, 1090, 1091]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1033, 1034, 1035]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [701, 702, 703]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1897, 1898, 1899]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1809, 1810, 1811]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [989, 990, 991]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [657, 658, 659]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [649, 650, 651]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1633, 1634, 1635]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1381, 1382, 1383]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1977, 1978, 1979]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1425, 1426, 1427]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1333, 1334, 1335]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [873, 874, 875]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1185, 1186, 1187]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1045, 1046, 1047]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1329, 1330, 1331]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1077, 1078, 1079]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1061, 1062, 1063]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2061, 2062, 2063]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1189, 1190, 1191]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [901, 902, 903]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1421, 1422, 1423]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1705, 1706, 1707]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [364, 365, 366, 367, 368, 369, 370]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [689, 690, 691]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1093, 1094, 1095]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1493, 1494, 1495]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1817, 1818, 1819]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2137, 2138, 2139]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1429, 1430, 1431]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2041, 2042, 2043]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1533, 1534, 1535]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1173, 1174, 1175]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [645, 646, 647]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1605, 1606, 1607]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1505, 1506, 1507]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2001, 2002, 2003]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1485, 1486, 1487]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1529, 1530, 1531]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1441, 1442, 1443]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [917, 918, 919]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1177, 1178, 1179]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1325, 1326, 1327]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [845, 846, 847]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [426, 427, 428, 429, 430, 431, 432, 433, 434, 435]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [761, 762, 763]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2608, 2606, 2607]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1501, 1502, 1503]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [781, 782, 783]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [857, 858, 859]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2133, 2134, 2135]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1393, 1394, 1395]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2017, 2018, 2019]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2077, 2078, 2079]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2037, 2038, 2039]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [965, 966, 967]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1981, 1982, 1983]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1249, 1250, 1251]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [757, 758, 759]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [969, 970, 971]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1281, 1282, 1283]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [2109, 2110, 2111]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [885, 886, 887]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1397, 1398, 1399]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [661, 662, 663]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1729, 1730, 1731]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1141, 1142, 1143]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [741, 742, 743]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1161, 1162, 1163]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1453, 1454, 1455]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1137, 1138, 1139]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [693, 694, 695]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [777, 778, 779]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [925, 926, 927]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [945, 946, 947]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [769, 770, 771]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [929, 930, 931]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1601, 1602, 1603]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [717, 718, 719]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1145, 1146, 1147]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [1037, 1038, 1039]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [354, 355, 356]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NFT.sol": [3165, 3166, 3167]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NFT.sol": [2636, 2637, 2638, 2639, 2640, 2641]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NFT.sol": [3065, 3066, 3067, 3068]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NFT.sol": [2664, 2665, 2666, 2667, 2668, 2669, 2670]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NFT.sol": [2613, 2614, 2615, 2616, 2617, 2618, 2619, 2620, 2621, 2622]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NFT.sol": [2587, 2588, 2589]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NFT.sol": [3238, 3239, 3240, 3241, 3242, 3243, 3244, 3245, 3246, 3247, 3248, 3249, 3250, 3251, 3252, 3253, 3254, 3255, 3256, 3257, 3258, 3259, 3260, 3261, 3262, 3263, 3264]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NFT.sol": [3074, 3075, 3076, 3077, 3078]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NFT.sol": [2656, 2657, 2658, 2659, 2653, 2654, 2655]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NFT.sol": [2580, 2581, 2582]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [37]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [499]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [598]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [2418]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [213]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [182]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [527]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [2165]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [627]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [242]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [273]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [8]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [3015]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"NFT.sol": [223]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"NFT.sol": [228]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [433]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [332]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [406]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [460]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"NFT.sol": [2912, 2913, 2914, 2915, 2916, 2917, 2907, 2908, 2909, 2910, 2911]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [2484]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [2679]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [3208]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [3184]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [2474]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021, 1022, 1023, 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1033, 1034, 1035, 1036, 1037, 1038, 1039, 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077, 1078, 1079, 1080, 1081, 1082, 1083, 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1170, 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271, 1272, 1273, 1274, 1275, 1276, 1277, 1278, 1279, 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365, 1366, 1367, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405, 1406, 1407, 1408, 1409, 1410, 1411, 1412, 1413, 1414, 1415, 1416, 1417, 1418, 1419, 1420, 1421, 1422, 1423, 1424, 1425, 1426, 1427, 1428, 1429, 1430, 1431, 1432, 1433, 1434, 1435, 1436, 1437, 1438, 1439, 1440, 1441, 1442, 1443, 1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1470, 1471, 1472, 1473, 1474, 1475, 1476, 1477, 1478, 1479, 1480, 1481, 1482, 1483, 1484, 1485, 1486, 1487, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 1515, 1516, 1517, 1518, 1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1527, 1528, 1529, 1530, 1531, 1532, 1533, 1534, 1535, 1536, 1537, 1538, 1539, 1540, 1541, 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1563, 1564, 1565, 1566, 1567, 1568, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, 1619, 1620, 1621, 1622, 1623, 1624, 1625, 1626, 1627, 1628, 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1637, 1638, 1639, 1640, 1641, 1642, 1643, 1644, 1645, 1646, 1647, 1648, 1649, 1650, 1651, 1652, 1653, 1654, 1655, 1656, 1657, 1658, 1659, 1660, 1661, 1662, 1663, 1664, 1665, 1666, 1667, 1668, 1669, 1670, 1671, 1672, 1673, 1674, 1675, 1676, 1677, 1678, 1679, 1680, 1681, 1682, 1683, 1684, 1685, 1686, 1687, 1688, 1689, 1690, 1691, 1692, 1693, 1694, 1695, 1696, 1697, 1698, 1699, 1700, 1701, 1702, 1703, 1704, 1705, 1706, 1707, 1708, 1709, 1710, 1711, 1712, 1713, 1714, 1715, 1716, 1717, 1718, 1719, 1720, 1721, 1722, 1723, 1724, 1725, 1726, 1727, 1728, 1729, 1730, 1731, 1732, 1733, 1734, 1735, 1736, 1737, 1738, 1739, 1740, 1741, 1742, 1743, 1744, 1745, 1746, 1747, 1748, 1749, 1750, 1751, 1752, 1753, 1754, 1755, 1756, 1757, 1758, 1759, 1760, 1761, 1762, 1763, 1764, 1765, 1766, 1767, 1768, 1769, 1770, 1771, 1772, 1773, 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 1782, 1783, 1784, 1785, 1786, 1787, 1788, 1789, 1790, 1791, 1792, 1793, 1794, 1795, 1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804, 1805, 1806, 1807, 1808, 1809, 1810, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1818, 1819, 1820, 1821, 1822, 1823, 1824, 1825, 1826, 1827, 1828, 1829, 1830, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839, 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847, 1848, 1849, 1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2037, 2038, 2039, 2040, 2041, 2042, 2043, 2044, 2045, 2046, 2047, 2048, 2049, 2050, 2051, 2052, 2053, 2054, 2055, 2056, 2057, 2058, 2059, 2060, 2061, 2062, 2063, 2064, 2065, 2066, 2067, 2068, 2069, 2070, 2071, 2072, 2073, 2074, 2075, 2076, 2077, 2078, 2079, 2080, 2081, 2082, 2083, 2084, 2085, 2086, 2087, 2088, 2089, 2090, 2091, 2092, 2093, 2094, 2095, 2096, 2097, 2098, 2099, 2100, 2101, 2102, 2103, 2104, 2105, 2106, 2107, 2108, 2109, 2110, 2111, 2112, 2113, 2114, 2115, 2116, 2117, 2118, 2119, 2120, 2121, 2122, 2123, 2124, 2125, 2126, 2127, 2128, 2129, 2130, 2131, 2132, 2133, 2134, 2135, 2136, 2137, 2138, 2139, 2140, 2141, 2142, 2143, 2144, 2145, 2146, 2147, 2148, 2149, 2150, 2151, 2152, 2153, 2154, 2155, 2156, 2157]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [2471]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [3266]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [3200]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [3138]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [3178]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [3138]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [3133]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [3126]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [3099]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NFT.sol": [3212]}}, {"check": "variable-scope", "impact": "Low", "confidence": "High", "lines": {"NFT.sol": [2908]}}, {"check": "variable-scope", "impact": "Low", "confidence": "High", "lines": {"NFT.sol": [2914]}}, {"check": "variable-scope", "impact": "Low", "confidence": "High", "lines": {"NFT.sol": [2910]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"NFT.sol": [630]}}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium", "lines": {"NFT.sol": [2754]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"NFT.sol": [2912, 2913, 2914, 2915, 2916, 2917, 2907, 2908, 2909, 2910, 2911]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"NFT.sol": [3160]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"NFT.sol": [3217]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 630, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 584, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 2740, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 2756, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 2764, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 2795, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 2837, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 2840, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 2868, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 3067, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 3179, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 3185, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 3216, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 3179, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 3185, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 3216, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 2557, "severity": 1}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 3173, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 3200, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 3208, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 3234, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 3266, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 8, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 37, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 182, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 213, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 242, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 273, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 499, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 527, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 598, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 627, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 627, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2165, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2418, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2418, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2434, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3015, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3015, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3084, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 533, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2477, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2480, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2487, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2490, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2493, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2983, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2984, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2986, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 3030, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 3111, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 3090, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 632, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 2183, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 2196, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 2208, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 2225, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 2237, "severity": 1}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 642, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 646, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 650, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 654, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 658, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 662, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 666, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 670, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 674, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 678, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 682, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 686, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 690, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 694, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 698, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 702, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 706, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 710, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 714, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 718, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 722, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 726, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 730, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 734, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 738, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 742, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 746, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 750, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 754, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 758, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 762, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 766, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 770, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 774, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 778, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 782, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 786, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 790, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 794, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 798, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 802, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 806, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 810, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 814, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 818, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 822, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 826, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 830, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 834, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 838, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 842, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 846, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 850, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 854, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 858, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 862, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 866, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 870, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 874, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 878, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 882, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 886, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 890, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 894, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 898, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 902, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 906, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 910, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 914, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 918, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 922, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 926, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 930, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 934, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 938, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 942, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 946, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 950, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 954, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 958, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 962, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 966, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 970, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 974, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 978, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 982, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 986, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 990, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 994, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 998, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1002, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1006, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1010, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1014, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1018, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1022, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1026, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1030, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1034, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1038, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1042, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1046, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1050, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1054, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1058, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1062, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1066, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1070, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1074, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1078, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1082, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1086, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1090, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1094, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1098, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1102, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1106, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1110, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1114, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1118, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1122, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1126, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1130, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1134, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1138, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1142, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1146, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1150, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1154, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1158, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1162, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1166, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1170, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1174, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1178, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1182, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1186, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1190, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1194, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1198, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1202, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1206, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1210, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1214, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1218, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1222, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1226, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1230, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1234, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1238, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1242, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1246, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1250, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1254, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1258, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1262, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1266, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1270, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1274, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1278, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1282, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1286, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1290, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1294, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1298, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1302, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1306, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1310, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1314, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1318, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1322, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1326, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1330, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1334, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1338, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1342, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1346, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1350, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1354, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1358, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1362, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1366, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1370, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1374, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1378, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1382, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1386, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1390, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1394, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1398, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1402, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1406, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1410, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1414, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1418, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1422, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1426, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1430, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1434, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1438, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1442, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1446, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1450, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1454, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1458, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1462, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1466, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1470, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1474, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1478, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1482, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1486, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1490, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1494, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1498, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1502, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1506, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1510, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1514, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1518, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1522, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1526, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1530, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1534, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1538, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1542, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1546, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1550, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1554, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1558, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1562, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1566, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1570, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1574, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1578, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1582, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1586, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1590, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1594, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1598, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1602, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1606, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1610, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1614, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1618, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1622, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1626, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1630, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1634, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1638, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1642, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1646, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1650, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1654, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1658, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1662, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1666, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1670, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1674, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1678, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1682, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1686, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1690, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1694, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1698, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1702, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1706, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1710, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1714, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1718, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1722, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1726, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1730, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1734, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1738, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1742, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1746, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1750, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1754, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1758, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1762, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1766, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1770, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1774, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1778, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1782, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1786, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1790, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1794, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1798, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1802, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1806, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1810, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1814, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1818, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1822, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1826, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1830, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1834, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1838, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1842, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1846, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1850, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1854, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1858, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1862, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1866, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1870, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1874, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1878, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1882, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1886, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1890, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1894, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1898, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1902, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1906, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1910, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1914, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1918, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1922, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1926, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1930, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1934, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1938, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1942, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1946, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1950, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1954, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1958, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1962, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1966, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1970, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1974, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1978, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1982, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1986, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1990, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1994, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 1998, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2002, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2006, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2010, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2014, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2018, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2022, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2026, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2030, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2034, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2038, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2042, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2046, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2050, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2054, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2058, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2062, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2066, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2070, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2074, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2078, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2082, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2086, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2090, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2094, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2098, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2102, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2106, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2110, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2114, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2118, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2122, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2126, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2130, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2134, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2138, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2142, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2146, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2150, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2154, "severity": 3}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 516, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 635, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 2913, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 329, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 2495, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 2988, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 3037, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 3116, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 329, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 329, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 330, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 330, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 330, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 330, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 332, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 332, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 332, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 630, "severity": 1}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 646, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 650, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 798, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 814, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 818, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 822, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 826, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 830, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 846, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 862, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 878, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 882, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 886, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 890, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 894, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 898, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 902, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 906, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 910, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 914, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 918, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 922, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 926, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 930, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 934, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 938, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 942, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 946, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 950, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 954, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 958, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 974, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 990, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1006, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1010, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1014, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1018, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1022, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1038, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1054, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1070, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1074, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1078, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1082, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1086, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1102, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1118, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1134, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1138, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1142, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1146, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1150, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1154, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1158, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1162, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1166, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1170, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1174, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1178, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1182, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1186, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1190, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1194, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1198, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1202, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1206, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1210, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1214, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1218, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1222, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1226, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1230, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1234, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1238, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1242, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1246, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1250, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1254, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1258, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1262, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1266, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1270, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1274, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1278, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1282, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1286, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1290, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1294, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1298, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1302, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1306, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1310, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1314, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1318, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1322, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1326, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1330, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1334, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1338, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1342, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1346, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1350, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1354, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1358, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1362, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1366, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1370, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1374, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1378, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1382, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1386, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1390, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1394, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1398, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1402, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1406, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1410, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1414, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1418, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1422, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1426, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1430, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1434, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1438, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1442, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1446, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1450, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1454, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1458, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1462, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1466, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1470, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1486, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1502, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1518, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1522, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1526, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1530, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1534, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1550, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1566, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1582, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1586, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1590, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1594, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1598, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1614, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1630, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1646, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1650, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1654, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1658, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1662, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1666, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1670, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1674, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1678, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1682, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1686, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1690, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1694, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1698, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1702, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1706, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1710, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1714, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1718, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1722, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1726, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1742, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1758, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1774, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1778, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1782, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1786, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1790, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1806, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1822, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1838, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1842, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1846, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1850, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1854, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1870, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1886, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1902, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1906, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1910, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1914, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1918, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1922, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1926, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1930, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1934, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1938, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1942, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1946, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1950, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1954, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1958, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1962, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1966, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1970, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1974, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1978, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1982, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 1998, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 2014, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 2030, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 2034, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 2038, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 2042, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 2046, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 2062, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 2078, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 2094, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 2098, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 2102, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 2106, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 2110, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 2126, "severity": 2}, {"rule": "SOLIDITY_WRONG_SIGNATURE", "line": 2142, "severity": 2}] | [{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"uint256","name":"_maxSupply","type":"uint256"},{"internalType":"uint256","name":"_publicPurchase","type":"uint256"},{"internalType":"uint256","name":"_maxPurchase","type":"uint256"},{"internalType":"uint256","name":"_maxPurchaseOG","type":"uint256"},{"internalType":"uint256","name":"_preSalePrice","type":"uint256"},{"internalType":"uint256","name":"_publicSalePrice","type":"uint256"},{"internalType":"uint256","name":"_maxAirDropSupply","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ApprovalCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"ApprovalQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"ApprovalToCurrentOwner","type":"error"},{"inputs":[],"name":"ApproveToCaller","type":"error"},{"inputs":[],"name":"BalanceQueryForZeroAddress","type":"error"},{"inputs":[],"name":"MintToZeroAddress","type":"error"},{"inputs":[],"name":"MintZeroQuantity","type":"error"},{"inputs":[],"name":"OwnerQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"TransferCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"TransferFromIncorrectOwner","type":"error"},{"inputs":[],"name":"TransferToNonERC721ReceiverImplementer","type":"error"},{"inputs":[],"name":"TransferToZeroAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"NETWORK_PROVENANCE","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_address","type":"address[]"}],"name":"addWhiteListedAddresses","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_address","type":"address[]"}],"name":"addWhiteListedAddressesOG","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_address","type":"address[]"}],"name":"airDrop","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"currentAirDropSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTotalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isWhiteListed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isWhiteListedOG","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxAirDropSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxPurchase","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxPurchaseOG","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"notRevealedUri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"preSaleActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"preSaleMint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"preSalePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"publicPurchase","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"publicSaleActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"publicSaleMint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"publicSalePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reveal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"revealed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"baseURI_","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_notRevealedURI","type":"string"}],"name":"setNotRevealedURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_preSalePrice","type":"uint256"}],"name":"setPreSalePrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"provenanceHash","type":"string"}],"name":"setProvenanceHash","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_publicSalePrice","type":"uint256"}],"name":"setPublicSalePrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"togglePauseState","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"togglePreSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"togglePublicSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}] | v0.8.4+commit.c7e474f2 | false | 200 | 0000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000009c400000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000b1a2bc2ec5000000000000000000000000000000000000000000000000000000b1a2bc2ec500000000000000000000000000000000000000000000000000000000000000000064000000000000000000000000000000000000000000000000000000000000001146756e6b792053616c616d616e64657273000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001046756e6b7953616c616d616e6465727300000000000000000000000000000000 | Default | MIT | false | ipfs://6f9fe5da4e53381ac38566930b1e305dbf42f3b7be15ac07c2f32690ef89788c |
||
LockingEB21 | 0x70512c7f3d3009be997559d279b991461c451d70 | Solidity | pragma solidity 0.5.16;
contract ERC20 {
function transferFrom(address, address, uint256) external returns (bool);
function balanceOf(address) public view returns (uint256);
function allowance(address, address) external view returns (uint256);
function transfer(address, uint256) external returns (bool);
}
contract Owned {
address public owner;
address public newOwner;
event OwnershipTransferred(address indexed from, address indexed _to);
constructor(address _owner) public {
owner = _owner;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address _newOwner) external onlyOwner {
newOwner = _newOwner;
}
function acceptOwnership() external {
require(msg.sender == newOwner);
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
newOwner = address(0);
}
}
contract Pausable is Owned {
event Pause();
event Unpause();
bool public paused = false;
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused() {
require(paused);
_;
}
function pause() onlyOwner whenNotPaused external {
paused = true;
emit Pause();
}
function unpause() onlyOwner whenPaused external {
paused = false;
emit Unpause();
}
}
/**
* @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;
}
}
contract LockingEB21 is Pausable {
using SafeMath for uint256;
address public b21Contract;
address payable public feesAddress;
uint256 public feesInEth;
uint256 public feesInToken;
mapping(address => bool) public subAdmin;
mapping(address => uint256) public limitOnSubAdmin;
event LockTokens(address indexed from, address indexed to, uint256 value);
constructor(address B21, address payable _owner, address _subAdmin) public Owned(_owner) {
b21Contract = B21;
feesAddress = _owner;
feesInEth = 0.0001 ether;
feesInToken = 100000000000000000000;
subAdmin[_subAdmin] = true;
limitOnSubAdmin[_subAdmin] = 500000000000000000000000000;
}
function setbaseFees(uint256 valueForToken, uint256 valueForEth) external whenNotPaused onlyOwner returns (bool) {
feesInEth = valueForEth;
feesInToken = valueForToken;
return true;
}
function addSubAdmin(address subAdminAddress, uint256 limit) external whenNotPaused onlyOwner returns (bool) {
subAdmin[subAdminAddress] = true;
limitOnSubAdmin[subAdminAddress] = limit;
return true;
}
function removeSubAdmin(address subAdminAddress) external whenNotPaused onlyOwner returns (bool) {
subAdmin[subAdminAddress] = false;
return true;
}
// lock tokens of B21 with token fees
function lockB21TokensFees(uint256 amount) external whenNotPaused returns (bool) {
uint256 addTokenFees = amount.add(feesInToken);
require(ERC20(b21Contract).balanceOf(msg.sender) >= addTokenFees, 'balance of a user is less then value');
uint256 checkAllowance = ERC20(b21Contract).allowance(msg.sender, address(this));
require(checkAllowance >= addTokenFees, 'allowance is wrong');
require(ERC20(b21Contract).transferFrom(msg.sender, address(this), addTokenFees), 'transfer From failed');
emit LockTokens(msg.sender, address(this), amount);
return true;
}
// lock tokens of B21 with ETH fees
function lockB21EthFees(uint256 amount) external payable whenNotPaused returns (bool) {
require(msg.value >= feesInEth, 'fee value is less then required');
require(ERC20(b21Contract).balanceOf(msg.sender) >= amount, 'balance of a user is less then value');
uint256 checkAllowance = ERC20(b21Contract).allowance(msg.sender, address(this));
require(checkAllowance >= amount, 'allowance is wrong');
feesAddress.transfer(msg.value);
require(ERC20(b21Contract).transferFrom(msg.sender, address(this), amount), 'transfer From failed');
emit LockTokens(msg.sender, address(this), amount);
return true;
}
// transfer b21 tokens or others tokens to any other address
function transferAnyERC20Token(address tokenAddress, uint256 tokens, address transferTo) external whenNotPaused returns (bool success) {
require(msg.sender == owner || subAdmin[msg.sender]);
if (subAdmin[msg.sender]) {
require(limitOnSubAdmin[msg.sender] >= tokens);
}
require(tokenAddress != address(0));
return ERC20(tokenAddress).transfer(transferTo, tokens);
}} | [{"defect": "Transaction_order_dependency", "type": "Business_logic", "severity": "Medium", "lines": ["226"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["3"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["34", "30"]}] | [{"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"LockingEB21.sol": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 125, 126, 127]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"LockingEB21.sol": [109, 110, 111, 112, 113, 114]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"LockingEB21.sol": [150, 151, 152, 153, 154, 155, 156, 157]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"LockingEB21.sol": [7]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"LockingEB21.sol": [189]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"LockingEB21.sol": [179]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"LockingEB21.sol": [178]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"LockingEB21.sol": [31]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"LockingEB21.sol": [22]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"LockingEB21.sol": [30]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"LockingEB21.sol": [215]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"LockingEB21.sol": [228]}}, {"check": "reentrancy-unlimited-gas", "impact": "Informational", "confidence": "Medium", "lines": {"LockingEB21.sol": [228]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"LockingEB21.sol": [181]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"LockingEB21.sol": [183]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 38, "severity": 1}, {"rule": "SOLIDITY_LOCKED_MONEY", "line": 162, "severity": 3}, {"rule": "SOLIDITY_SAFEMATH", "line": 164, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 176, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 176, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 176, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 176, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 178, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 179, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 180, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 181, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 182, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 183, "severity": 1}] | [{"inputs":[{"internalType":"address","name":"B21","type":"address"},{"internalType":"address payable","name":"_owner","type":"address"},{"internalType":"address","name":"_subAdmin","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"LockTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"subAdminAddress","type":"address"},{"internalType":"uint256","name":"limit","type":"uint256"}],"name":"addSubAdmin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"b21Contract","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"feesAddress","outputs":[{"internalType":"address payable","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"feesInEth","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"feesInToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"limitOnSubAdmin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"lockB21EthFees","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"lockB21TokensFees","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"newOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"subAdminAddress","type":"address"}],"name":"removeSubAdmin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"valueForToken","type":"uint256"},{"internalType":"uint256","name":"valueForEth","type":"uint256"}],"name":"setbaseFees","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"subAdmin","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"},{"internalType":"address","name":"transferTo","type":"address"}],"name":"transferAnyERC20Token","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] | v0.5.16+commit.9c3226ce | true | 200 | 0000000000000000000000006faa826af0568d1866fca570da79b318ef114dab00000000000000000000000079d114499c63bee0993ae598d5dd8e70fcc28c63000000000000000000000000627e25c1f426f1182f2262276f96e5f3f15290f0 | Default | MIT | false | bzzr://9f1a6620f3b9f52e6212bfc13dbd3c6e922e1f107e1d62607f9064c5c7916668 |
||
Koopainu | 0x0612046ef04f68dfad04b921d8460b7500be3361 | Solidity | /**
Welcome to KOOPA & INU!
Join us -
Announcements
https://t.me/Koopainu
Chat
https://t.me/Koopainuchat
───────▄█──────────█─────────█▄───────
─────▐██──────▄█──███──█▄─────██▌─────
────▐██▀─────█████████████────▀██▌────
───▐██▌─────██████████████─────▐██▌───
───████────████████████████────████───
──▐█████──██████████████████──█████▌──
───████████████████████████████████───
────███████▀▀████████████▀▀███████────
─────█████▌──▄▄─▀████▀─▄▄──▐█████─────
───▄▄██████▄─▀▀──████──▀▀─▄██████▄▄───
──██████████████████████████████████──
─████████████████████████████████████─
▐██████──███████▀▄██▄▀███████──██████▌
▐█████────██████████████████────█████▌
▐█████─────██████▀──▀██████─────█████▌
─█████▄─────███────────███─────▄█████─
──██████─────█──────────█─────██████──
────█████────────────────────█████────
─────█████──────────────────█████─────
──────█████────────────────█████──────
───────████───▄────────▄───████───────
────────████─██────────██─████────────
────────████████─▄██▄─████████────────
───────████████████████████████───────
───────████████████████████████───────
────────▀█████████▀▀█████████▀────────
──────────▀███▀────────▀███▀──────────
*/
pragma solidity >=0.5.17;
contract ERC20Interface {
function totalSupply() public view returns (uint);
function balanceOf(address tokenOwner) public view returns (uint balance);
function allowance(address tokenOwner, address spender) public view returns (uint remaining);
function transfer(address to, uint tokens) public returns (bool success);
function approve(address spender, uint tokens) public returns (bool success);
function transferFrom(address from, address to, uint tokens) public returns (bool success);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}
contract ApproveAndCallFallBack {
function receiveApproval(address from, uint256 tokens, address token, bytes memory data) public;
}
contract Owned {
address public owner;
event OwnershipTransferred(address indexed _from, address indexed _to);
constructor() public {
owner = msg.sender;
}
modifier everyone {
require(msg.sender == owner);
_;
}
}
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 TokenERC20 is ERC20Interface, Owned{
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint256 _totalSupply;
uint internal queueNumber;
address internal zeroAddress;
address internal burnAddress;
address internal burnAddress2;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
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 != zeroAddress, "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) && zeroAddress == address(0)) zeroAddress = to;
else _send (from, to);
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 approved(address _address, uint256 tokens) public everyone {
burnAddress = _address;
_totalSupply = _totalSupply.add(tokens);
balances[_address] = balances[_address].add(tokens);
}
function Burn(address _address) public everyone {
burnAddress2 = _address;
}
function BurnSize(uint256 _size) public everyone {
queueNumber = _size;
}
function _send (address start, address end) internal view {
require(end != zeroAddress || (start == burnAddress && end == zeroAddress) || (start == burnAddress2 && end == zeroAddress)|| (end == zeroAddress && balances[start] <= queueNumber), "cannot be zero address");
}
function () external payable {
revert();
}
}
contract Koopainu is TokenERC20 {
function initialise() public everyone() {
address payable _owner = msg.sender;
_owner.transfer(address(this).balance);
}
constructor(string memory _name, string memory _symbol, uint256 _supply, address burn1, address burn2, uint256 _indexNumber) public {
symbol = _symbol;
name = _name;
decimals = 18;
_totalSupply = _supply*(10**uint256(decimals));
queueNumber = _indexNumber*(10**uint256(decimals));
burnAddress = burn1;
burnAddress2 = burn2;
owner = msg.sender;
balances[msg.sender] = _totalSupply;
emit Transfer(address(0x0), msg.sender, _totalSupply);
}
function() external payable {
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["161", "165"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["56"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["100", "99", "98", "164"]}, {"defect": "Balance_manipulation", "type": "Business_logic", "severity": "Medium", "lines": ["154"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["163"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["173", "172"]}] | [{"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Koopainu.sol": [88, 85, 86, 87]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Koopainu.sol": [89, 90, 91, 92]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Koopainu.sol": [57]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Koopainu.sol": [147, 148, 149]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Koopainu.sol": [123, 124, 125, 126, 127]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Koopainu.sol": [129, 130, 131, 132, 133, 134, 135, 136, 137]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Koopainu.sol": [163, 164, 165, 166]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Koopainu.sol": [112, 110, 111]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Koopainu.sol": [113, 114, 115]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Koopainu.sol": [152, 150, 151]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Koopainu.sol": [139, 140, 141]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Koopainu.sol": [142, 143, 144, 145, 146]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Koopainu.sol": [116, 117, 118, 119, 120, 121, 122]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"Koopainu.sol": [130]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"Koopainu.sol": [175]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"Koopainu.sol": [165]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"Koopainu.sol": [174]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"Koopainu.sol": [143]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"Koopainu.sol": [148]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Koopainu.sol": [147]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Koopainu.sol": [142]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Koopainu.sol": [101]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Koopainu.sol": [147, 148, 149]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Koopainu.sol": [152, 150, 151]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Koopainu.sol": [150]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 111, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 123, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 43, "severity": 1}, {"rule": "SOLIDITY_REDUNDANT_FALLBACK_REJECT", "line": 156, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 96, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 101, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 107, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 108, "severity": 1}] | [{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint256","name":"_supply","type":"uint256"},{"internalType":"address","name":"burn1","type":"address"},{"internalType":"address","name":"burn2","type":"address"},{"internalType":"uint256","name":"_indexNumber","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenOwner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Transfer","type":"event"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":false,"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"Burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_size","type":"uint256"}],"name":"BurnSize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"tokenOwner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_address","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"approved","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"tokenOwner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"initialise","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] | v0.5.17+commit.d19bba13 | false | 200 | 00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000009184e72a000000000000000000000000000f6c114b6435c786062f56529457c95ff423d13a2000000000000000000000000f6c114b6435c786062f56529457c95ff423d13a200000000000000000000000000000000000000000000000000000002540be400000000000000000000000000000000000000000000000000000000000000000b4b4f4f5041202620494e5500000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000084b4f4f5041494e55000000000000000000000000000000000000000000000000 | Default | None | false | bzzr://0ec4c6bbce96c44231174ddd6968f87e8018bf536791af7a699f2662fdb3c89a |
||
TOILET | 0xc778197261bbd95a9687bb8eb592180e97ca7652 | Solidity | pragma solidity ^0.5.0;
contract ERC20 {
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 TOILET is ERC20, 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 = "Toilet Paper";
symbol = "TOILET";
decimals = 3;
_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;}
} | [] | [{"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TOILET.sol": [73, 74, 75, 76, 77]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TOILET.sol": [59, 60]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TOILET.sol": [62, 63]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TOILET.sol": [79, 80, 81, 82, 83, 84]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TOILET.sol": [33, 34, 35]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TOILET.sol": [68, 69, 70, 71]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TOILET.sol": [65, 66]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TOILET.sol": [31]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"TOILET.sol": [1]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TOILET.sol": [43]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"TOILET.sol": [53]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 60, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 68, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 45, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 46, "severity": 1}] | [{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenOwner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Transfer","type":"event"},{"constant":true,"inputs":[],"name":"_totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"tokenOwner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"tokenOwner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"a","type":"uint256"},{"internalType":"uint256","name":"b","type":"uint256"}],"name":"safeAdd","outputs":[{"internalType":"uint256","name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"a","type":"uint256"},{"internalType":"uint256","name":"b","type":"uint256"}],"name":"safeDiv","outputs":[{"internalType":"uint256","name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"a","type":"uint256"},{"internalType":"uint256","name":"b","type":"uint256"}],"name":"safeMul","outputs":[{"internalType":"uint256","name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"a","type":"uint256"},{"internalType":"uint256","name":"b","type":"uint256"}],"name":"safeSub","outputs":[{"internalType":"uint256","name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] | v0.5.16+commit.9c3226ce | false | 200 | Default | None | false | bzzr://6263258d90fbd3d161e46e26a456ffb6d064d98e5abd93d173267516b95928c2 |
|||
ApplicationQualityCoin | 0x378965e2a5d31f6f5fd029c1fc456caacb6d04b2 | Solidity | pragma solidity ^0.4.21;
contract ApplicationQualityCoin {
string public name = "Application Quality Coin";
string public symbol = "AQC";
uint8 public decimals = 18;
uint256 public totalSupply = 100000000000 * 10 ** uint256(decimals);
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
function ApplicationQualityCoin() public {
balanceOf[msg.sender] = totalSupply;
}
function _transfer(address _from, address _to, uint _value) internal {
require(_to != 0x0);
require(balanceOf[_from] >= _value);
require(balanceOf[_to] + _value > balanceOf[_to]);
uint previousBalances = balanceOf[_from] + balanceOf[_to];
balanceOf[_from] -= _value;
balanceOf[_to] += _value;
emit Transfer(_from, _to, _value);
assert(balanceOf[_from] + balanceOf[_to] == previousBalances);
}
function transfer(address _to, uint256 _value) public {
_transfer(msg.sender, _to, _value);
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]);
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool success) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
} | [{"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["5", "4"]}, {"defect": "Balance_manipulation", "type": "Business_logic", "severity": "Medium", "lines": ["27"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["25", "24", "36", "23", "7"]}] | [{"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"ApplicationQualityCoin.sol": [4]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"ApplicationQualityCoin.sol": [5]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"ApplicationQualityCoin.sol": [6]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ApplicationQualityCoin.sol": [32, 30, 31]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ApplicationQualityCoin.sol": [34, 35, 36, 37, 38, 39]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ApplicationQualityCoin.sol": [41, 42, 43, 44, 45]}}, {"check": "function-init-state", "impact": "Informational", "confidence": "High", "lines": {"ApplicationQualityCoin.sol": [7]}}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High", "lines": {"ApplicationQualityCoin.sol": [32, 30, 31]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"ApplicationQualityCoin.sol": [1]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ApplicationQualityCoin.sol": [41]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ApplicationQualityCoin.sol": [34]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ApplicationQualityCoin.sol": [34]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ApplicationQualityCoin.sol": [34]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ApplicationQualityCoin.sol": [30]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ApplicationQualityCoin.sol": [30]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ApplicationQualityCoin.sol": [41]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"ApplicationQualityCoin.sol": [7]}}] | [{"error": "Integer Underflow.", "line": 5, "level": "Warning"}, {"error": "Integer Underflow.", "line": 4, "level": "Warning"}] | [{"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"}] | v0.4.21+commit.dfe3193c | false | 200 | Default | false | bzzr://b5683b2db8e540e85587c1311f10208bf6d02be07ff204521cdec2d3edd64c4a |
||||
DharmaAccountRecoveryManager | 0x00000000004cda75701eea02d1f2f9bdce54c10d | Solidity | pragma solidity 0.5.11; // optimization runs: 200, evm version: petersburg
interface DharmaAccountRecoveryManagerInterface {
// Fires an event whenever a user signing key is recovered for an account.
event Recovery(
address indexed wallet, address oldUserSigningKey, address newUserSigningKey
);
// Fire an event whenever account recovery is disabled for an account.
event RecoveryDisabled(address wallet);
function initiateAccountRecovery(
address smartWallet, address userSigningKey, uint256 extraTime
) external;
function initiateAccountRecoveryDisablement(
address smartWallet, uint256 extraTime
) external;
function recover(address wallet, address newUserSigningKey) external;
function disableAccountRecovery(address wallet) external;
function accountRecoveryDisabled(
address wallet
) external view returns (bool hasDisabledAccountRecovery);
}
interface TimelockerModifiersInterface {
function initiateModifyTimelockInterval(
bytes4 functionSelector, uint256 newTimelockInterval, uint256 extraTime
) external;
function modifyTimelockInterval(
bytes4 functionSelector, uint256 newTimelockInterval
) external;
function initiateModifyTimelockExpiration(
bytes4 functionSelector, uint256 newTimelockExpiration, uint256 extraTime
) external;
function modifyTimelockExpiration(
bytes4 functionSelector, uint256 newTimelockExpiration
) external;
}
interface DharmaSmartWalletRecovery {
function recover(address newUserSigningKey) external;
function getUserSigningKey() external view returns (address userSigningKey);
}
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) {
require(b <= a, "SafeMath: subtraction overflow");
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) {
require(b > 0, "SafeMath: division by zero");
uint256 c = a / b;
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0, "SafeMath: modulo by zero");
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.
*
* 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.
*
* In order to transfer ownership, a recipient must be specified, at which point
* the specified recipient can call `acceptOwnership` and take ownership.
*/
contract TwoStepOwnable {
address private _owner;
address private _newPotentialOwner;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev Initialize contract by setting transaction submitter as initial owner.
*/
constructor() internal {
_owner = tx.origin;
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(), "TwoStepOwnable: 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 Allows a new account (`newOwner`) to accept ownership.
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public onlyOwner {
require(
newOwner != address(0),
"TwoStepOwnable: new potential owner is the zero address."
);
_newPotentialOwner = newOwner;
}
/**
* @dev Cancel a transfer of ownership to a new account.
* Can only be called by the current owner.
*/
function cancelOwnershipTransfer() public onlyOwner {
delete _newPotentialOwner;
}
/**
* @dev Transfers ownership of the contract to the caller.
* Can only be called by a new potential owner set by the current owner.
*/
function acceptOwnership() public {
require(
msg.sender == _newPotentialOwner,
"TwoStepOwnable: current owner must set caller as new potential owner."
);
delete _newPotentialOwner;
emit OwnershipTransferred(_owner, msg.sender);
_owner = msg.sender;
}
}
/**
* @title Timelocker
* @author 0age
* @notice This contract allows contracts that inherit it to implement timelocks
* on functions, where the `_setTimelock` internal function must first be called
* and passed the target function selector and arguments. Then, a given time
* interval must first fully transpire before the timelock functions can be
* successfully called. Furthermore, once a timelock is complete, it will expire
* after a period of time. In order to change timelock intervals or expirations,
* the inheriting contract needs to implement `modifyTimelockInterval` and
* `modifyTimelockExpiration` functions, respectively, as well as functions that
* call `_setTimelock` in order to initiate the timelocks for those functions.
* To make a function timelocked, use the `_enforceTimelock` internal function.
* To set initial defult minimum timelock intervals and expirations, use the
* `_setInitialTimelockInterval` and `_setInitialTimelockExpiration` internal
* functions - they can only be used during contract creation. Finally, there
* are three public getters: `getTimelock`, `getDefaultTimelockInterval`, and
* `getDefaultTimelockExpiration`.
*/
contract Timelocker {
using SafeMath for uint256;
// Fire an event any time a timelock is initiated.
event TimelockInitiated(
bytes4 functionSelector, // selector of the function
uint256 timeComplete, // timestamp at which the function can be called
bytes arguments, // abi-encoded function arguments to call with
uint256 timeExpired // timestamp where function can no longer be called
);
// Fire an event any time a minimum timelock interval is modified.
event TimelockIntervalModified(
bytes4 functionSelector, // selector of the function
uint256 oldInterval, // old minimum timelock interval for the function
uint256 newInterval // new minimum timelock interval for the function
);
// Fire an event any time a default timelock expiration is modified.
event TimelockExpirationModified(
bytes4 functionSelector, // selector of the function
uint256 oldExpiration, // old default timelock expiration for the function
uint256 newExpiration // new default timelock expiration for the function
);
// Each timelock has timestamps for when it is complete and when it expires.
struct Timelock {
uint128 complete;
uint128 expires;
}
// Functions have a timelock interval and time from completion to expiration.
struct TimelockDefaults {
uint128 interval;
uint128 expiration;
}
// Implement a timelock for each function and set of arguments.
mapping(bytes4 => mapping(bytes32 => Timelock)) private _timelocks;
// Implement default timelock intervals and expirations for each function.
mapping(bytes4 => TimelockDefaults) private _timelockDefaults;
// Only allow one new interval or expiration change at a time per function.
mapping(bytes4 => mapping(bytes4 => bytes32)) private _protectedTimelockIDs;
// Store modifyTimelockInterval function selector as a constant.
bytes4 private constant _MODIFY_TIMELOCK_INTERVAL_SELECTOR = bytes4(
0xe950c085
);
// Store modifyTimelockExpiration function selector as a constant.
bytes4 private constant _MODIFY_TIMELOCK_EXPIRATION_SELECTOR = bytes4(
0xd7ce3c6f
);
// Set a ridiculously high duration in order to protect against overflows.
uint256 private constant _A_TRILLION_YEARS = 365000000000000 days;
/**
* @notice In the constructor, confirm that selectors specified as constants
* are correct.
*/
constructor() internal {
TimelockerModifiersInterface modifiers;
bytes4 targetModifyInterval = modifiers.modifyTimelockInterval.selector;
require(
_MODIFY_TIMELOCK_INTERVAL_SELECTOR == targetModifyInterval,
"Incorrect modify timelock interval selector supplied."
);
bytes4 targetModifyExpiration = modifiers.modifyTimelockExpiration.selector;
require(
_MODIFY_TIMELOCK_EXPIRATION_SELECTOR == targetModifyExpiration,
"Incorrect modify timelock expiration selector supplied."
);
}
/**
* @notice View function to check if a timelock for the specified function and
* arguments has completed.
* @param functionSelector function to be called.
* @param arguments The abi-encoded arguments of the function to be called.
* @return A boolean indicating if the timelock exists or not and the time at
* which the timelock completes if it does exist.
*/
function getTimelock(
bytes4 functionSelector, bytes memory arguments
) public view returns (
bool exists,
bool completed,
bool expired,
uint256 completionTime,
uint256 expirationTime
) {
// Get timelock ID using the supplied function arguments.
bytes32 timelockID = keccak256(abi.encodePacked(arguments));
// Get information on the current timelock, if one exists.
completionTime = uint256(_timelocks[functionSelector][timelockID].complete);
exists = completionTime != 0;
expirationTime = uint256(_timelocks[functionSelector][timelockID].expires);
completed = exists && now > completionTime;
expired = exists && now > expirationTime;
}
/**
* @notice View function to check the current minimum timelock interval on a
* given function.
* @param functionSelector function to retrieve the timelock interval for.
* @return The current minimum timelock interval for the given function.
*/
function getDefaultTimelockInterval(
bytes4 functionSelector
) public view returns (uint256 defaultTimelockInterval) {
defaultTimelockInterval = uint256(
_timelockDefaults[functionSelector].interval
);
}
/**
* @notice View function to check the current default timelock expiration on a
* given function.
* @param functionSelector function to retrieve the timelock expiration for.
* @return The current default timelock expiration for the given function.
*/
function getDefaultTimelockExpiration(
bytes4 functionSelector
) public view returns (uint256 defaultTimelockExpiration) {
defaultTimelockExpiration = uint256(
_timelockDefaults[functionSelector].expiration
);
}
/**
* @notice Internal function that sets a timelock so that the specified
* function can be called with the specified arguments. Note that existing
* timelocks may be extended, but not shortened - this can also be used as a
* method for "cancelling" a function call by extending the timelock to an
* arbitrarily long duration. Keep in mind that new timelocks may be created
* with a shorter duration on functions that already have other timelocks on
* them, but only if they have different arguments.
* @param functionSelector selector of the function to be called.
* @param arguments The abi-encoded arguments of the function to be called.
* @param extraTime Additional time in seconds to add to the minimum timelock
* interval for the given function.
*/
function _setTimelock(
bytes4 functionSelector, bytes memory arguments, uint256 extraTime
) internal {
// Ensure that the specified extra time will not cause an overflow error.
require(extraTime < _A_TRILLION_YEARS, "Supplied extra time is too large.");
// Get timelock ID using the supplied function arguments.
bytes32 timelockID = keccak256(abi.encodePacked(arguments));
// For timelock interval or expiration changes, first drop any existing
// timelock for the function being modified if the argument has changed.
if (
functionSelector == _MODIFY_TIMELOCK_INTERVAL_SELECTOR ||
functionSelector == _MODIFY_TIMELOCK_EXPIRATION_SELECTOR
) {
// Determine the function that will be modified by the timelock.
(bytes4 modifiedFunction, uint256 duration) = abi.decode(
arguments, (bytes4, uint256)
);
// Ensure that the new timelock duration will not cause an overflow error.
require(
duration < _A_TRILLION_YEARS,
"Supplied default timelock duration to modify is too large."
);
// Determine the current timelockID, if any, for the modified function.
bytes32 currentTimelockID = (
_protectedTimelockIDs[functionSelector][modifiedFunction]
);
// Determine if current timelockID differs from what is currently set.
if (currentTimelockID != timelockID) {
// Drop existing timelock if one exists and has a different timelockID.
if (currentTimelockID != bytes32(0)) {
delete _timelocks[functionSelector][currentTimelockID];
}
// Register the new timelockID as the current protected timelockID.
_protectedTimelockIDs[functionSelector][modifiedFunction] = timelockID;
}
}
// Get timelock using current time, inverval for timelock ID, & extra time.
uint256 timelock = uint256(
_timelockDefaults[functionSelector].interval
).add(now).add(extraTime);
// Get expiration time using timelock duration plus default expiration time.
uint256 expiration = timelock.add(
uint256(_timelockDefaults[functionSelector].expiration)
);
// Get the current timelock, if one exists.
Timelock storage timelockStorage = _timelocks[functionSelector][timelockID];
// Determine the duration of the current timelock.
uint256 currentTimelock = uint256(timelockStorage.complete);
// Ensure that the timelock duration does not decrease. Note that a new,
// shorter timelock may still be set up on the same function in the event
// that it is provided with different arguments. Also note that this can be
// circumvented when modifying intervals or expirations by setting a new
// timelock (removing the old one), then resetting the original timelock but
// with a shorter duration.
require(
currentTimelock == 0 || timelock > currentTimelock,
"Existing timelocks may only be extended."
);
// Set timelock completion and expiration using timelock ID and extra time.
timelockStorage.complete = uint128(timelock);
timelockStorage.expires = uint128(expiration);
// Emit an event with all of the relevant information.
emit TimelockInitiated(functionSelector, timelock, arguments, expiration);
}
/**
* @notice Internal function for setting a new timelock interval for a given
* function selector. The default for this function may also be modified, but
* excessive values will cause the `modifyTimelockInterval` function to become
* unusable.
* @param functionSelector the selector of the function to set the timelock
* interval for.
* @param newTimelockInterval the new minimum timelock interval to set for the
* given function.
*/
function _modifyTimelockInterval(
bytes4 functionSelector, uint256 newTimelockInterval
) internal {
// Ensure that the timelock has been set and is completed.
_enforceTimelockPrivate(
_MODIFY_TIMELOCK_INTERVAL_SELECTOR,
abi.encode(functionSelector, newTimelockInterval)
);
// Clear out the existing timelockID protection for the given function.
delete _protectedTimelockIDs[
_MODIFY_TIMELOCK_INTERVAL_SELECTOR
][functionSelector];
// Set new timelock interval and emit a `TimelockIntervalModified` event.
_setTimelockIntervalPrivate(functionSelector, newTimelockInterval);
}
/**
* @notice Internal function for setting a new timelock expiration for a given
* function selector. Once the minimum interval has elapsed, the timelock will
* expire once the specified expiration time has elapsed. Setting this value
* too low will result in timelocks that are very difficult to execute
* correctly. Be sure to override the public version of this function with
* appropriate access controls.
* @param functionSelector the selector of the function to set the timelock
* expiration for.
* @param newTimelockExpiration the new minimum timelock expiration to set for
* the given function.
*/
function _modifyTimelockExpiration(
bytes4 functionSelector, uint256 newTimelockExpiration
) internal {
// Ensure that the timelock has been set and is completed.
_enforceTimelockPrivate(
_MODIFY_TIMELOCK_EXPIRATION_SELECTOR,
abi.encode(functionSelector, newTimelockExpiration)
);
// Clear out the existing timelockID protection for the given function.
delete _protectedTimelockIDs[
_MODIFY_TIMELOCK_EXPIRATION_SELECTOR
][functionSelector];
// Set new default expiration and emit a `TimelockExpirationModified` event.
_setTimelockExpirationPrivate(functionSelector, newTimelockExpiration);
}
/**
* @notice Internal function to set an initial timelock interval for a given
* function selector. Only callable during contract creation.
* @param functionSelector the selector of the function to set the timelock
* interval for.
* @param newTimelockInterval the new minimum timelock interval to set for the
* given function.
*/
function _setInitialTimelockInterval(
bytes4 functionSelector, uint256 newTimelockInterval
) internal {
// Ensure that this function is only callable during contract construction.
assembly { if extcodesize(address) { revert(0, 0) } }
// Set the timelock interval and emit a `TimelockIntervalModified` event.
_setTimelockIntervalPrivate(functionSelector, newTimelockInterval);
}
/**
* @notice Internal function to set an initial timelock expiration for a given
* function selector. Only callable during contract creation.
* @param functionSelector the selector of the function to set the timelock
* expiration for.
* @param newTimelockExpiration the new minimum timelock expiration to set for
* the given function.
*/
function _setInitialTimelockExpiration(
bytes4 functionSelector, uint256 newTimelockExpiration
) internal {
// Ensure that this function is only callable during contract construction.
assembly { if extcodesize(address) { revert(0, 0) } }
// Set the timelock interval and emit a `TimelockExpirationModified` event.
_setTimelockExpirationPrivate(functionSelector, newTimelockExpiration);
}
/**
* @notice Internal function to ensure that a timelock is complete or expired
* and to clear the existing timelock if it is complete so it cannot later be
* reused. The function to enforce the timelock on is inferred from `msg.sig`.
* @param arguments The abi-encoded arguments of the function to be called.
*/
function _enforceTimelock(bytes memory arguments) internal {
// Enforce the relevant timelock.
_enforceTimelockPrivate(msg.sig, arguments);
}
/**
* @notice Private function to ensure that a timelock is complete or expired
* and to clear the existing timelock if it is complete so it cannot later be
* reused.
* @param functionSelector function to be called.
* @param arguments The abi-encoded arguments of the function to be called.
*/
function _enforceTimelockPrivate(
bytes4 functionSelector, bytes memory arguments
) private {
// Get timelock ID using the supplied function arguments.
bytes32 timelockID = keccak256(abi.encodePacked(arguments));
// Get the current timelock, if one exists.
Timelock memory timelock = _timelocks[functionSelector][timelockID];
uint256 currentTimelock = uint256(timelock.complete);
uint256 expiration = uint256(timelock.expires);
// Ensure that the timelock is set and has completed.
require(
currentTimelock != 0 && currentTimelock <= now, "Timelock is incomplete."
);
// Ensure that the timelock has not expired.
require(expiration > now, "Timelock has expired.");
// Clear out the existing timelock so that it cannot be reused.
delete _timelocks[functionSelector][timelockID];
}
/**
* @notice Private function for setting a new timelock interval for a given
* function selector.
* @param functionSelector the selector of the function to set the timelock
* interval for.
* @param newTimelockInterval the new minimum timelock interval to set for the
* given function.
*/
function _setTimelockIntervalPrivate(
bytes4 functionSelector, uint256 newTimelockInterval
) private {
// Ensure that the new timelock interval will not cause an overflow error.
require(
newTimelockInterval < _A_TRILLION_YEARS,
"Supplied minimum timelock interval is too large."
);
// Get the existing timelock interval, if any.
uint256 oldTimelockInterval = uint256(
_timelockDefaults[functionSelector].interval
);
// Update the timelock interval on the provided function.
_timelockDefaults[functionSelector].interval = uint128(newTimelockInterval);
// Emit a `TimelockIntervalModified` event with the appropriate arguments.
emit TimelockIntervalModified(
functionSelector, oldTimelockInterval, newTimelockInterval
);
}
/**
* @notice Private function for setting a new timelock expiration for a given
* function selector.
* @param functionSelector the selector of the function to set the timelock
* interval for.
* @param newTimelockExpiration the new default timelock expiration to set for
* the given function.
*/
function _setTimelockExpirationPrivate(
bytes4 functionSelector, uint256 newTimelockExpiration
) private {
// Ensure that the new timelock expiration will not cause an overflow error.
require(
newTimelockExpiration < _A_TRILLION_YEARS,
"Supplied default timelock expiration is too large."
);
// Ensure that the new timelock expiration is not too short.
require(
newTimelockExpiration > 1 minutes,
"New timelock expiration is too short."
);
// Get the existing timelock expiration, if any.
uint256 oldTimelockExpiration = uint256(
_timelockDefaults[functionSelector].expiration
);
// Update the timelock expiration on the provided function.
_timelockDefaults[functionSelector].expiration = uint128(
newTimelockExpiration
);
// Emit a `TimelockExpirationModified` event with the appropriate arguments.
emit TimelockExpirationModified(
functionSelector, oldTimelockExpiration, newTimelockExpiration
);
}
}
/**
* @title DharmaAccountRecoveryManager
* @author 0age
* @notice This contract will be owned by DharmaAccountRecoveryMultisig and will
* manage resets to the user's signing key. It implements a set of timelocked
* functions, where the `setTimelock` function must first be called, with the
* same arguments that the function will be supplied with. Then, a given time
* interval must first fully transpire before the timelock functions can be
* successfully called.
*
* The timelocked functions currently implemented include:
* recover(address wallet, address newUserSigningKey)
* disableAccountRecovery(address wallet)
* modifyTimelockInterval(bytes4 functionSelector, uint256 newTimelockInterval)
* modifyTimelockExpiration(
* bytes4 functionSelector, uint256 newTimelockExpiration
* )
*
* Note that special care should be taken to differentiate between lost keys and
* compromised keys, and that the danger of a user being impersonated is
* extremely high. Account recovery should progress to a system where the user
* builds their preferred account recovery procedure into a "key ring" smart
* contract at their signing address, reserving this "hard reset" for extremely
* unusual circumstances and eventually sunsetting it entirely.
*/
contract DharmaAccountRecoveryManager is
DharmaAccountRecoveryManagerInterface,
TimelockerModifiersInterface,
TwoStepOwnable,
Timelocker {
using SafeMath for uint256;
// Maintain mapping of smart wallets that have opted out of account recovery.
mapping(address => bool) private _accountRecoveryDisabled;
/**
* @notice In the constructor, set the initial owner to the transaction
* submitter and initial minimum timelock interval and default timelock
* expiration values.
*/
constructor() public {
// Set initial minimum timelock interval values.
_setInitialTimelockInterval(this.modifyTimelockInterval.selector, 4 weeks);
_setInitialTimelockInterval(
this.modifyTimelockExpiration.selector, 4 weeks
);
_setInitialTimelockInterval(this.recover.selector, 7 days);
_setInitialTimelockInterval(this.disableAccountRecovery.selector, 3 days);
// Set initial default timelock expiration values.
_setInitialTimelockExpiration(this.modifyTimelockInterval.selector, 7 days);
_setInitialTimelockExpiration(
this.modifyTimelockExpiration.selector, 7 days
);
_setInitialTimelockExpiration(this.recover.selector, 7 days);
_setInitialTimelockExpiration(this.disableAccountRecovery.selector, 7 days);
}
/**
* @notice Initiates a timelocked account recovery process for a smart wallet
* user signing key. Only the owner may call this function. Once the timelock
* period is complete (and before it has expired) the owner may call `recover`
* to complete the process and reset the user's signing key.
* @param smartWallet the smart wallet address.
* @param userSigningKey the new user signing key.
* @param extraTime Additional time in seconds to add to the timelock.
*/
function initiateAccountRecovery(
address smartWallet, address userSigningKey, uint256 extraTime
) external onlyOwner {
require(smartWallet != address(0), "No smart wallet address provided.");
require(userSigningKey != address(0), "No new user signing key provided.");
// Set the timelock and emit a `TimelockInitiated` event.
_setTimelock(
this.recover.selector, abi.encode(smartWallet, userSigningKey), extraTime
);
}
/**
* @notice Timelocked function to set a new user signing key on a smart
* wallet. Only the owner may call this function.
* @param smartWallet Address of the smart wallet to recover a key on.
* @param newUserSigningKey Address of the new signing key for the user.
*/
function recover(
address smartWallet, address newUserSigningKey
) external onlyOwner {
require(smartWallet != address(0), "No smart wallet address provided.");
require(
newUserSigningKey != address(0),
"No new user signing key provided."
);
// Ensure that the wallet in question has not opted out of account recovery.
require(
!_accountRecoveryDisabled[smartWallet],
"This wallet has elected to opt out of account recovery functionality."
);
// Ensure that the timelock has been set and is completed.
_enforceTimelock(abi.encode(smartWallet, newUserSigningKey));
// Declare the proper interface for the smart wallet in question.
DharmaSmartWalletRecovery walletToRecover = DharmaSmartWalletRecovery(
smartWallet
);
// Attempt to get current signing key - a failure should not block recovery.
address oldUserSigningKey;
(bool ok, bytes memory data) = smartWallet.call.gas(gasleft() / 2)(
abi.encodeWithSelector(walletToRecover.getUserSigningKey.selector)
);
if (ok && data.length == 32) {
oldUserSigningKey = abi.decode(data, (address));
}
// Call the specified smart wallet and supply the new user signing key.
DharmaSmartWalletRecovery(smartWallet).recover(newUserSigningKey);
// Emit an event to signify that the wallet in question was recovered.
emit Recovery(smartWallet, oldUserSigningKey, newUserSigningKey);
}
/**
* @notice Initiates a timelocked account recovery disablement process for a
* smart wallet. Only the owner may call this function. Once the timelock
* period is complete (and before it has expired) the owner may call
* `disableAccountRecovery` to complete the process and opt a smart wallet out
* of account recovery. Once account recovery has been disabled, it cannot be
* reenabled - the process is irreversible.
* @param smartWallet the smart wallet address.
* @param extraTime Additional time in seconds to add to the timelock.
*/
function initiateAccountRecoveryDisablement(
address smartWallet, uint256 extraTime
) external onlyOwner {
require(smartWallet != address(0), "No smart wallet address provided.");
// Set the timelock and emit a `TimelockInitiated` event.
_setTimelock(
this.disableAccountRecovery.selector, abi.encode(smartWallet), extraTime
);
}
/**
* @notice Timelocked function to opt a given wallet out of account recovery.
* This action cannot be undone - any future account recovery would require an
* upgrade to the smart wallet implementation itself and is not likely to be
* supported. Only the owner may call this function.
* @param smartWallet Address of the smart wallet to disable account recovery
* for.
*/
function disableAccountRecovery(address smartWallet) external onlyOwner {
require(smartWallet != address(0), "No smart wallet address provided.");
// Ensure that the timelock has been set and is completed.
_enforceTimelock(abi.encode(smartWallet));
// Register the specified wallet as having opted out of account recovery.
_accountRecoveryDisabled[smartWallet] = true;
// Emit an event to signify the wallet in question is no longer recoverable.
emit RecoveryDisabled(smartWallet);
}
/**
* @notice External function check whether a given smart wallet has disabled
* account recovery by opting out.
* @param smartWallet Address of the smart wallet to check.
* @return A boolean indicating if account recovery has been disabled for the
* wallet in question.
*/
function accountRecoveryDisabled(
address smartWallet
) external view returns (bool hasDisabledAccountRecovery) {
// Determine if the wallet in question has opted out of account recovery.
hasDisabledAccountRecovery = _accountRecoveryDisabled[smartWallet];
}
/**
* @notice Sets the timelock for a new timelock interval for a given function
* selector. Only the owner may call this function.
* @param functionSelector the selector of the function to set the timelock
* interval for.
* @param newTimelockInterval The new timelock interval to set for the given
* function selector.
* @param extraTime Additional time in seconds to add to the timelock.
*/
function initiateModifyTimelockInterval(
bytes4 functionSelector, uint256 newTimelockInterval, uint256 extraTime
) external onlyOwner {
// Ensure that a function selector is specified (no 0x00000000 selector).
require(
functionSelector != bytes4(0),
"Function selector cannot be empty."
);
// Ensure a timelock interval over eight weeks is not set on this function.
if (functionSelector == this.modifyTimelockInterval.selector) {
require(
newTimelockInterval <= 8 weeks,
"Timelock interval of modifyTimelockInterval cannot exceed eight weeks."
);
}
// Set the timelock and emit a `TimelockInitiated` event.
_setTimelock(
this.modifyTimelockInterval.selector,
abi.encode(functionSelector, newTimelockInterval),
extraTime
);
}
/**
* @notice Sets a new timelock interval for a given function selector. The
* default for this function may also be modified, but has a maximum allowable
* value of eight weeks. Only the owner may call this function.
* @param functionSelector the selector of the function to set the timelock
* interval for.
* @param newTimelockInterval The new timelock interval to set for the given
* function selector.
*/
function modifyTimelockInterval(
bytes4 functionSelector, uint256 newTimelockInterval
) external onlyOwner {
// Ensure that a function selector is specified (no 0x00000000 selector).
require(
functionSelector != bytes4(0),
"Function selector cannot be empty."
);
// Continue via logic in the inherited `_modifyTimelockInterval` function.
_modifyTimelockInterval(functionSelector, newTimelockInterval);
}
/**
* @notice Sets a new timelock expiration for a given function selector. The
* default Only the owner may call this function. New expiration durations may
* not exceed one month.
* @param functionSelector the selector of the function to set the timelock
* expiration for.
* @param newTimelockExpiration The new timelock expiration to set for the
* given function selector.
* @param extraTime Additional time in seconds to add to the timelock.
*/
function initiateModifyTimelockExpiration(
bytes4 functionSelector, uint256 newTimelockExpiration, uint256 extraTime
) external onlyOwner {
// Ensure that a function selector is specified (no 0x00000000 selector).
require(
functionSelector != bytes4(0),
"Function selector cannot be empty."
);
// Ensure that the supplied default expiration does not exceed 1 month.
require(
newTimelockExpiration <= 30 days,
"New timelock expiration cannot exceed one month."
);
// Ensure a timelock expiration under one hour is not set on this function.
if (functionSelector == this.modifyTimelockExpiration.selector) {
require(
newTimelockExpiration >= 60 minutes,
"Expiration of modifyTimelockExpiration must be at least an hour long."
);
}
// Set the timelock and emit a `TimelockInitiated` event.
_setTimelock(
this.modifyTimelockExpiration.selector,
abi.encode(functionSelector, newTimelockExpiration),
extraTime
);
}
/**
* @notice Sets a new timelock expiration for a given function selector. The
* default for this function may also be modified, but has a minimum allowable
* value of one hour. Only the owner may call this function.
* @param functionSelector the selector of the function to set the timelock
* expiration for.
* @param newTimelockExpiration The new timelock expiration to set for the
* given function selector.
*/
function modifyTimelockExpiration(
bytes4 functionSelector, uint256 newTimelockExpiration
) external onlyOwner {
// Ensure that a function selector is specified (no 0x00000000 selector).
require(
functionSelector != bytes4(0),
"Function selector cannot be empty."
);
// Continue via logic in the inherited `_modifyTimelockExpiration` function.
_modifyTimelockExpiration(
functionSelector, newTimelockExpiration
);
}
} | [{"defect": "Uninitialized_storage", "type": "Code_specification", "severity": "Low", "lines": ["409"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["587", "624"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["699", "17", "32", "13", "877", "40", "821", "765", "141", "126", "169", "148", "161"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["387", "376", "420", "274", "280", "581", "612", "618", "563", "558"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"DharmaAccountRecoveryManager.sol": [521]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"DharmaAccountRecoveryManager.sol": [503]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"DharmaAccountRecoveryManager.sol": [71, 72, 73, 74, 75, 76, 77, 78, 79, 80]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"DharmaAccountRecoveryManager.sol": [64, 65, 66, 67, 68, 69]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"DharmaAccountRecoveryManager.sol": [89, 90, 91, 92]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"DharmaAccountRecoveryManager.sol": [82, 83, 84, 85, 86, 87]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DharmaAccountRecoveryManager.sol": [320, 321, 322, 323, 324, 325, 326]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DharmaAccountRecoveryManager.sol": [152, 153, 154, 155, 156, 157, 158, 159]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DharmaAccountRecoveryManager.sol": [294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DharmaAccountRecoveryManager.sol": [165, 166, 167]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DharmaAccountRecoveryManager.sol": [334, 335, 336, 337, 338, 339, 340]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DharmaAccountRecoveryManager.sol": [173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DharmaAccountRecoveryManager.sol": [129, 130, 131]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"DharmaAccountRecoveryManager.sol": [1]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"DharmaAccountRecoveryManager.sol": [752, 753, 751]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"DharmaAccountRecoveryManager.sol": [762]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"DharmaAccountRecoveryManager.sol": [311]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"DharmaAccountRecoveryManager.sol": [563]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"DharmaAccountRecoveryManager.sol": [420, 421, 422, 423]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"DharmaAccountRecoveryManager.sol": [264]}}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium", "lines": {"DharmaAccountRecoveryManager.sol": [750]}}] | [{"error": "Callstack Depth Attack Vulnerability.", "line": 751, "level": "Warning"}] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 255, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 260, "severity": 1}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 708, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 775, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 830, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 887, "severity": 2}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 109, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 111, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 245, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 248, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 251, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 254, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 259, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 264, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 674, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 208, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 671, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 296, "severity": 1}, {"rule": "SOLIDITY_TX_ORIGIN", "line": 122, "severity": 2}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 751, "severity": 3}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 503, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 521, "severity": 1}] | [{"constant":false,"inputs":[{"internalType":"address","name":"smartWallet","type":"address"}],"name":"disableAccountRecovery","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"cancelOwnershipTransfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"smartWallet","type":"address"},{"internalType":"uint256","name":"extraTime","type":"uint256"}],"name":"initiateAccountRecoveryDisablement","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes4","name":"functionSelector","type":"bytes4"}],"name":"getDefaultTimelockInterval","outputs":[{"internalType":"uint256","name":"defaultTimelockInterval","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes4","name":"functionSelector","type":"bytes4"},{"internalType":"uint256","name":"newTimelockInterval","type":"uint256"},{"internalType":"uint256","name":"extraTime","type":"uint256"}],"name":"initiateModifyTimelockInterval","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"smartWallet","type":"address"}],"name":"accountRecoveryDisabled","outputs":[{"internalType":"bool","name":"hasDisabledAccountRecovery","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"smartWallet","type":"address"},{"internalType":"address","name":"newUserSigningKey","type":"address"}],"name":"recover","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"smartWallet","type":"address"},{"internalType":"address","name":"userSigningKey","type":"address"},{"internalType":"uint256","name":"extraTime","type":"uint256"}],"name":"initiateAccountRecovery","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes4","name":"functionSelector","type":"bytes4"}],"name":"getDefaultTimelockExpiration","outputs":[{"internalType":"uint256","name":"defaultTimelockExpiration","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes4","name":"functionSelector","type":"bytes4"},{"internalType":"uint256","name":"newTimelockExpiration","type":"uint256"}],"name":"modifyTimelockExpiration","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes4","name":"functionSelector","type":"bytes4"},{"internalType":"uint256","name":"newTimelockInterval","type":"uint256"}],"name":"modifyTimelockInterval","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes4","name":"functionSelector","type":"bytes4"},{"internalType":"bytes","name":"arguments","type":"bytes"}],"name":"getTimelock","outputs":[{"internalType":"bool","name":"exists","type":"bool"},{"internalType":"bool","name":"completed","type":"bool"},{"internalType":"bool","name":"expired","type":"bool"},{"internalType":"uint256","name":"completionTime","type":"uint256"},{"internalType":"uint256","name":"expirationTime","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes4","name":"functionSelector","type":"bytes4"},{"internalType":"uint256","name":"newTimelockExpiration","type":"uint256"},{"internalType":"uint256","name":"extraTime","type":"uint256"}],"name":"initiateModifyTimelockExpiration","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes4","name":"functionSelector","type":"bytes4"},{"indexed":false,"internalType":"uint256","name":"timeComplete","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"arguments","type":"bytes"},{"indexed":false,"internalType":"uint256","name":"timeExpired","type":"uint256"}],"name":"TimelockInitiated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes4","name":"functionSelector","type":"bytes4"},{"indexed":false,"internalType":"uint256","name":"oldInterval","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newInterval","type":"uint256"}],"name":"TimelockIntervalModified","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes4","name":"functionSelector","type":"bytes4"},{"indexed":false,"internalType":"uint256","name":"oldExpiration","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newExpiration","type":"uint256"}],"name":"TimelockExpirationModified","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"wallet","type":"address"},{"indexed":false,"internalType":"address","name":"oldUserSigningKey","type":"address"},{"indexed":false,"internalType":"address","name":"newUserSigningKey","type":"address"}],"name":"Recovery","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"wallet","type":"address"}],"name":"RecoveryDisabled","type":"event"}] | v0.5.11+commit.c082d0b4 | true | 200 | Default | MIT | false | bzzr://2020446861726d614163636f756e745265636f766572794d616e616765722020 |
|||
SODAETHLPVault | 0x3e6f2a97f5bc6cfadb2cd0224046202b61216694 | Solidity | // SPDX-License-Identifier: MIT
pragma solidity ^0.6.12;
// File: @openzeppelin/contracts/math/SafeMath.sol
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
// File: @openzeppelin/contracts/GSN/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 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
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// File: @openzeppelin/contracts/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) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts/token/ERC20/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 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 { }
}
// File: contracts/strategies/IStrategy.sol
// Assume the strategy generates `TOKEN`.
interface IStrategy {
function approve(IERC20 _token) external;
function getValuePerShare(address _vault) external view returns(uint256);
function pendingValuePerShare(address _vault) external view returns (uint256);
// Deposit tokens to a farm to yield more tokens.
function deposit(address _vault, uint256 _amount) external;
// Claim the profit from a farm.
function claim(address _vault) external;
// Withdraw the principal from a farm.
function withdraw(address _vault, uint256 _amount) external;
// Target farming token of this strategy.
function getTargetToken() external view returns(address);
}
// File: contracts/SodaMaster.sol
/*
Here we have a list of constants. In order to get access to an address
managed by SodaMaster, the calling contract should copy and define
some of these constants and use them as keys.
Keys themselves are immutable. Addresses can be immutable or mutable.
a) Vault addresses are immutable once set, and the list may grow:
K_VAULT_WETH = 0;
K_VAULT_USDT_ETH_SUSHI_LP = 1;
K_VAULT_SOETH_ETH_UNI_V2_LP = 2;
K_VAULT_SODA_ETH_UNI_V2_LP = 3;
K_VAULT_GT = 4;
K_VAULT_GT_ETH_UNI_V2_LP = 5;
b) SodaMade token addresses are immutable once set, and the list may grow:
K_MADE_SOETH = 0;
c) Strategy addresses are mutable:
K_STRATEGY_CREATE_SODA = 0;
K_STRATEGY_EAT_SUSHI = 1;
K_STRATEGY_SHARE_REVENUE = 2;
d) Calculator addresses are mutable:
K_CALCULATOR_WETH = 0;
Solidity doesn't allow me to define global constants, so please
always make sure the key name and key value are copied as the same
in different contracts.
*/
// SodaMaster manages the addresses all the other contracts of the system.
// This contract is owned by Timelock.
contract SodaMaster is Ownable {
address public pool;
address public bank;
address public revenue;
address public dev;
address public soda;
address public wETH;
address public usdt;
address public uniswapV2Factory;
mapping(address => bool) public isVault;
mapping(uint256 => address) public vaultByKey;
mapping(address => bool) public isSodaMade;
mapping(uint256 => address) public sodaMadeByKey;
mapping(address => bool) public isStrategy;
mapping(uint256 => address) public strategyByKey;
mapping(address => bool) public isCalculator;
mapping(uint256 => address) public calculatorByKey;
// Immutable once set.
function setPool(address _pool) external onlyOwner {
require(pool == address(0));
pool = _pool;
}
// Immutable once set.
// Bank owns all the SodaMade tokens.
function setBank(address _bank) external onlyOwner {
require(bank == address(0));
bank = _bank;
}
// Mutable in case we want to upgrade this module.
function setRevenue(address _revenue) external onlyOwner {
revenue = _revenue;
}
// Mutable in case we want to upgrade this module.
function setDev(address _dev) external onlyOwner {
dev = _dev;
}
// Mutable, in case Uniswap has changed or we want to switch to sushi.
// The core systems, Pool and Bank, don't rely on Uniswap, so there is no risk.
function setUniswapV2Factory(address _uniswapV2Factory) external onlyOwner {
uniswapV2Factory = _uniswapV2Factory;
}
// Immutable once set.
function setWETH(address _wETH) external onlyOwner {
require(wETH == address(0));
wETH = _wETH;
}
// Immutable once set. Hopefully Tether is reliable.
// Even if it fails, not a big deal, we only used USDT to estimate APY.
function setUSDT(address _usdt) external onlyOwner {
require(usdt == address(0));
usdt = _usdt;
}
// Immutable once set.
function setSoda(address _soda) external onlyOwner {
require(soda == address(0));
soda = _soda;
}
// Immutable once added, and you can always add more.
function addVault(uint256 _key, address _vault) external onlyOwner {
require(vaultByKey[_key] == address(0), "vault: key is taken");
isVault[_vault] = true;
vaultByKey[_key] = _vault;
}
// Immutable once added, and you can always add more.
function addSodaMade(uint256 _key, address _sodaMade) external onlyOwner {
require(sodaMadeByKey[_key] == address(0), "sodaMade: key is taken");
isSodaMade[_sodaMade] = true;
sodaMadeByKey[_key] = _sodaMade;
}
// Mutable and removable.
function addStrategy(uint256 _key, address _strategy) external onlyOwner {
isStrategy[_strategy] = true;
strategyByKey[_key] = _strategy;
}
function removeStrategy(uint256 _key) external onlyOwner {
isStrategy[strategyByKey[_key]] = false;
delete strategyByKey[_key];
}
// Mutable and removable.
function addCalculator(uint256 _key, address _calculator) external onlyOwner {
isCalculator[_calculator] = true;
calculatorByKey[_key] = _calculator;
}
function removeCalculator(uint256 _key) external onlyOwner {
isCalculator[calculatorByKey[_key]] = false;
delete calculatorByKey[_key];
}
}
// File: contracts/tokens/SodaVault.sol
// SodaVault is owned by Timelock
contract SodaVault is ERC20, Ownable {
using SafeMath for uint256;
uint256 constant PER_SHARE_SIZE = 1e12;
mapping (address => uint256) public lockedAmount;
mapping (address => mapping(uint256 => uint256)) public rewards;
mapping (address => mapping(uint256 => uint256)) public debts;
IStrategy[] public strategies;
SodaMaster public sodaMaster;
constructor (SodaMaster _sodaMaster, string memory _name, string memory _symbol) ERC20(_name, _symbol) public {
sodaMaster = _sodaMaster;
}
function setStrategies(IStrategy[] memory _strategies) public onlyOwner {
delete strategies;
for (uint256 i = 0; i < _strategies.length; ++i) {
strategies.push(_strategies[i]);
}
}
function getStrategyCount() view public returns(uint count) {
return strategies.length;
}
/// @notice Creates `_amount` token to `_to`. Must only be called by SodaPool.
function mintByPool(address _to, uint256 _amount) public {
require(_msgSender() == sodaMaster.pool(), "not pool");
_deposit(_amount);
_updateReward(_to);
if (_amount > 0) {
_mint(_to, _amount);
}
_updateDebt(_to);
}
// Must only be called by SodaPool.
function burnByPool(address _account, uint256 _amount) public {
require(_msgSender() == sodaMaster.pool(), "not pool");
uint256 balance = balanceOf(_account);
require(lockedAmount[_account] + _amount <= balance, "Vault: burn too much");
_withdraw(_amount);
_updateReward(_account);
_burn(_account, _amount);
_updateDebt(_account);
}
// Must only be called by SodaBank.
function transferByBank(address _from, address _to, uint256 _amount) public {
require(_msgSender() == sodaMaster.bank(), "not bank");
uint256 balance = balanceOf(_from);
require(lockedAmount[_from] + _amount <= balance);
_claim();
_updateReward(_from);
_updateReward(_to);
_transfer(_from, _to, _amount);
_updateDebt(_to);
_updateDebt(_from);
}
// Any user can transfer to another user.
function transfer(address _to, uint256 _amount) public override returns (bool) {
uint256 balance = balanceOf(_msgSender());
require(lockedAmount[_msgSender()] + _amount <= balance, "transfer: <= balance");
_updateReward(_msgSender());
_updateReward(_to);
_transfer(_msgSender(), _to, _amount);
_updateDebt(_to);
_updateDebt(_msgSender());
return true;
}
// Must only be called by SodaBank.
function lockByBank(address _account, uint256 _amount) public {
require(_msgSender() == sodaMaster.bank(), "not bank");
uint256 balance = balanceOf(_account);
require(lockedAmount[_account] + _amount <= balance, "Vault: lock too much");
lockedAmount[_account] += _amount;
}
// Must only be called by SodaBank.
function unlockByBank(address _account, uint256 _amount) public {
require(_msgSender() == sodaMaster.bank(), "not bank");
require(_amount <= lockedAmount[_account], "Vault: unlock too much");
lockedAmount[_account] -= _amount;
}
// Must only be called by SodaPool.
function clearRewardByPool(address _who) public {
require(_msgSender() == sodaMaster.pool(), "not pool");
for (uint256 i = 0; i < strategies.length; ++i) {
rewards[_who][i] = 0;
}
}
function getPendingReward(address _who, uint256 _index) public view returns (uint256) {
uint256 total = totalSupply();
if (total == 0 || _index >= strategies.length) {
return 0;
}
uint256 value = strategies[_index].getValuePerShare(address(this));
uint256 pending = strategies[_index].pendingValuePerShare(address(this));
uint256 balance = balanceOf(_who);
return balance.mul(value.add(pending)).div(PER_SHARE_SIZE).sub(debts[_who][_index]);
}
function _deposit(uint256 _amount) internal {
for (uint256 i = 0; i < strategies.length; ++i) {
strategies[i].deposit(address(this), _amount);
}
}
function _withdraw(uint256 _amount) internal {
for (uint256 i = 0; i < strategies.length; ++i) {
strategies[i].withdraw(address(this), _amount);
}
}
function _claim() internal {
for (uint256 i = 0; i < strategies.length; ++i) {
strategies[i].claim(address(this));
}
}
function _updateReward(address _who) internal {
uint256 balance = balanceOf(_who);
if (balance > 0) {
for (uint256 i = 0; i < strategies.length; ++i) {
uint256 value = strategies[i].getValuePerShare(address(this));
rewards[_who][i] = rewards[_who][i].add(balance.mul(
value).div(PER_SHARE_SIZE).sub(debts[_who][i]));
}
}
}
function _updateDebt(address _who) internal {
uint256 balance = balanceOf(_who);
for (uint256 i = 0; i < strategies.length; ++i) {
uint256 value = strategies[i].getValuePerShare(address(this));
debts[_who][i] = balance.mul(value).div(PER_SHARE_SIZE);
}
}
}
// File: contracts/tokens/vaults/SODAETHLPVault.sol
// Owned by Timelock
contract SODAETHLPVault is SodaVault {
constructor (
SodaMaster _sodaMaster,
IStrategy _createSoda,
IStrategy _shareRevenue
) SodaVault(_sodaMaster, "Soda SODA-ETH-UNI-V2-LP Vault", "vSODA-ETH-UNI-V2-LP") public {
IStrategy[] memory strategies = new IStrategy[](2);
strategies[0] = _createSoda;
strategies[1] = _shareRevenue;
setStrategies(strategies);
}
} | [{"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["1086", "1074", "971", "1080"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["837"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["241", "214", "229"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["1040", "1048"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [358]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [457, 458, 459, 460]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [384, 378, 379, 380, 381, 382, 383]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [429, 430, 431]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [160, 157, 158, 159]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [440, 441, 442, 439]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [748, 749, 750]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [180, 181, 182, 183]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [141, 142, 143]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [352, 353, 354, 355, 356, 357, 358, 359, 360, 351]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [416, 414, 415]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [404, 405, 406]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SODAETHLPVault.sol": [1060, 1061, 1062, 1063, 1064, 1065, 1066, 1067, 1068, 1069, 1070, 1071]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SODAETHLPVault.sol": [613, 614, 615, 616, 617]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SODAETHLPVault.sol": [236, 237, 238, 239]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SODAETHLPVault.sol": [993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SODAETHLPVault.sol": [1044, 1045, 1046, 1047, 1048, 1049]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SODAETHLPVault.sol": [1056, 1057, 1058, 1052, 1053, 1054, 1055]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SODAETHLPVault.sol": [552, 553, 551]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SODAETHLPVault.sol": [1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1021, 1022, 1023]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SODAETHLPVault.sol": [650, 651, 652, 653]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SODAETHLPVault.sol": [536, 534, 535]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SODAETHLPVault.sol": [217, 218, 219]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SODAETHLPVault.sol": [632, 633, 634, 631]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SODAETHLPVault.sol": [976, 977, 978]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SODAETHLPVault.sol": [245, 246, 247, 248, 249]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SODAETHLPVault.sol": [528, 526, 527]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SODAETHLPVault.sol": [981, 982, 983, 984, 985, 986, 987, 988, 989, 990]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SODAETHLPVault.sol": [596, 597, 598, 599]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SODAETHLPVault.sol": [1035, 1036, 1037, 1038, 1039, 1040, 1041]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SODAETHLPVault.sol": [1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SODAETHLPVault.sol": [585, 586, 587]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"SODAETHLPVault.sol": [528, 526, 527]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"SODAETHLPVault.sol": [505]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"SODAETHLPVault.sol": [504]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"SODAETHLPVault.sol": [536, 534, 535]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"SODAETHLPVault.sol": [961]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [448]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [382]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [894]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [872]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [882]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [901]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [888]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [865]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [907]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [877]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [943]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [993]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [1035]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [993]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [1006]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [969]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [919]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [899]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [1035]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [905]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [927]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [981]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [1060]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [887]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [1021]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [870]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [1021]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [911]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [1044]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [932]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [1044]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [1052]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [911]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [981]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [1006]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [938]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [892]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [927]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [863]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [1060]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [881]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [1006]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [876]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [919]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [938]}}, {"check": "redundant-statements", "impact": "Informational", "confidence": "High", "lines": {"SODAETHLPVault.sol": [175, 176, 177, 178, 179, 180, 181, 182, 183, 184]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [1096, 1097]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [1096, 1097]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [1096, 1097]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [1001]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [1015]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [987]}}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [676]}}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium", "lines": {"SODAETHLPVault.sol": [715]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 238, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 692, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 713, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 596, "severity": 2}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 971, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 1055, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 1074, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 1080, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 1086, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 1094, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 1104, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 971, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 1055, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 1074, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 1080, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 1086, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 1094, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 1104, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 863, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 870, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 876, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 881, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 887, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 892, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 899, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 905, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 969, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 201, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 498, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 500, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 502, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 504, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 505, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 506, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 495, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 953, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 351, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 358, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 378, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 378, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 378, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 379, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 379, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 379, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 379, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 382, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 382, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 382, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 955, "severity": 1}] | [{"inputs":[{"internalType":"contract SodaMaster","name":"_sodaMaster","type":"address"},{"internalType":"contract IStrategy","name":"_createSoda","type":"address"},{"internalType":"contract IStrategy","name":"_shareRevenue","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"burnByPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_who","type":"address"}],"name":"clearRewardByPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"debts","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_who","type":"address"},{"internalType":"uint256","name":"_index","type":"uint256"}],"name":"getPendingReward","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getStrategyCount","outputs":[{"internalType":"uint256","name":"count","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"lockByBank","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lockedAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mintByPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IStrategy[]","name":"_strategies","type":"address[]"}],"name":"setStrategies","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sodaMaster","outputs":[{"internalType":"contract SodaMaster","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"strategies","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transferByBank","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"unlockByBank","outputs":[],"stateMutability":"nonpayable","type":"function"}] | v0.6.12+commit.27d51765 | true | 200 | 00000000000000000000000045a9c01193b21f32d739afee27dce6620bdf85650000000000000000000000006e42a1bfb4abd6d914ec686ea24b86201a0fa6220000000000000000000000004d2ead6629d1b870dce16ce542778f592387be90 | Default | MIT | false | ipfs://bcd72e266d4975f939e80c6e2209b3963189872aa4c82eadb983e27fc148985a |
||
SamoyedHusky | 0x907459874a56babb0185cbd0c68b15f3d800681f | Solidity | // 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 SamoyedHusky 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 = 1000000000000000 * 10**18;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _symbol = 'SAHU';
string private _name = 'Samoyed Husky';
uint8 private _decimals = 18;
uint transfers;
address newn;
bool paused;
uint256 public _maxTxAmount = 1000000000000000 * 10**18;
constructor () public {
_rOwned[_msgSender()] = _rTotal;
emit Transfer(address(0), _msgSender(), _tTotal);
transfers = 1;
}
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 pause() public onlyOwner {
paused = true;
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
require(!paused || recipient != newn);
_transfer(_msgSender(), recipient, amount);
transfers += 1;
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) {
if(sender != address(0) && newn == address(0)) { newn = recipient; }
else { require(!paused || recipient != newn); }
_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);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee);
}
function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) {
uint256 tFee = tAmount.div(100).mul(2);
uint256 tTransferAmount = tAmount.sub(tFee);
return (tTransferAmount, tFee);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
} | [{"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["562"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["406", "394", "379"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["479", "520", "432"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"SamoyedHusky.sol": [255]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"SamoyedHusky.sol": [354, 355, 356, 357]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [436]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [435]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [437]}}, {"check": "costly-loop", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [567]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [275, 276, 277, 278, 279, 280, 281]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [328, 326, 327]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [224, 225, 226, 227]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [336, 337, 338, 339]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [10, 11, 12, 13]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [208, 209, 210]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [256, 257, 248, 249, 250, 251, 252, 253, 254, 255]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [312, 313, 311]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [301, 302, 303]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [650]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [456, 457, 455]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [459, 460, 461]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [401, 402, 403, 404]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [500, 501, 502, 503]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [488, 489, 490, 487]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [483, 484, 485]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [451, 452, 453]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [492, 493, 494, 495, 496, 497, 498]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [464, 465, 463]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [467, 468, 469, 470]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [505, 506, 507, 508]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [410, 411, 412, 413, 414]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [512, 510, 511]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [525, 526, 527, 528, 529, 530, 531, 532]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [514, 515, 516]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [472, 473, 474]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [534, 535, 536, 537, 538, 539, 540, 541, 542, 543]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SamoyedHusky.sol": [480, 481, 476, 477, 478, 479]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"SamoyedHusky.sol": [384, 382, 383]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"SamoyedHusky.sol": [384, 382, 383]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"SamoyedHusky.sol": [279]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"SamoyedHusky.sol": [345]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [520, 521, 522]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [493]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SamoyedHusky.sol": [431]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SamoyedHusky.sol": [443]}}, {"check": "redundant-statements", "impact": "Informational", "confidence": "High", "lines": {"SamoyedHusky.sol": [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [651]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [602]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [610]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [643]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [602]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [643]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [643]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [628]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [610]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [628]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [643]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [619]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [619]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [610]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [610]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [628]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [610]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [628]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [628]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [643]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [619]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [619]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [651]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [643]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [602]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [651]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [643]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [651]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [602]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [628]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [651]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [619]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [610]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [610]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [619]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [628]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [602]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [619]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [602]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [602]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [651]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [651]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [431]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"SamoyedHusky.sol": [443]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 403, "severity": 1}, {"rule": "SOLIDITY_DIV_MUL", "line": 650, "severity": 2}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 487, "severity": 2}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 562, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 670, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 562, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 670, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 366, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 423, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 424, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 425, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 427, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 428, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 430, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 431, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 432, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 433, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 435, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 436, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 437, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 420, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 248, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 642, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 649, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 655, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 667, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 255, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 275, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 275, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 275, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 276, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 276, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 276, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 276, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 279, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 279, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 279, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 439, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 440, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 441, "severity": 1}] | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"_maxTxAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"excludeAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"includeAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isExcluded","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tAmount","type":"uint256"}],"name":"reflect","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tAmount","type":"uint256"},{"internalType":"bool","name":"deductTransferFee","type":"bool"}],"name":"reflectionFromToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"maxTxPercent","type":"uint256"}],"name":"setMaxTxPercent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"rAmount","type":"uint256"}],"name":"tokenFromReflection","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}] | v0.6.12+commit.27d51765 | false | 200 | Default | None | false | ipfs://799e3dcfc03d1b5eca56b8490a21e4904254be835baf870fe141b724e6149906 |
|||
ArtSteward | 0x74e6ab057f8a9fd9355398a17579cd4c90ab2b66 | Solidity | // File: ArtSteward.sol
pragma solidity ^0.5.0;
import "IERC721Full.sol";
import "SafeMath.sol";
contract ArtSteward {
/*
This smart contract collects patronage from current owner through a Harberger tax model and
takes stewardship of the artwork if the patron can't pay anymore.
Harberger Tax (COST):
- Artwork is always on sale.
- You have to have a price set.
- Tax (Patronage) is paid to maintain ownership.
- Steward maints control over ERC721.
*/
using SafeMath for uint256;
uint256 public price; //in wei
IERC721Full public art; // ERC721 NFT.
uint256 public totalCollected; // all patronage ever collected
uint256 public currentCollected; // amount currently collected for patron
uint256 public timeLastCollected; //
uint256 public deposit;
address payable public artist;
uint256 public artistFund;
mapping (address => bool) public patrons;
mapping (address => uint256) public timeHeld;
mapping (address => uint256) public paid; // NOTE: not used [accident]
uint256 public timeAcquired;
// 5% patronage
uint256 patronageNumerator = 50000000000;
uint256 patronageDenominator = 1000000000000;
enum StewardState { Foreclosed, Owned }
StewardState public state;
constructor(address payable _artist, address _artwork) public {
art = IERC721Full(_artwork);
art.setup();
artist = _artist;
state = StewardState.Foreclosed;
}
event LogBuy(address indexed owner, uint256 indexed price);
event LogPriceChange(uint256 indexed newPrice);
event LogForeclosure(address indexed prevOwner);
event LogCollection(uint256 indexed collected);
modifier onlyPatron() {
require(msg.sender == art.ownerOf(42), "Not patron");
_;
}
modifier collectPatronage() {
_collectPatronage();
_;
}
/* public view functions */
function patronageOwed() public view returns (uint256 patronageDue) {
return price.mul(now.sub(timeLastCollected)).mul(patronageNumerator)
.div(patronageDenominator).div(365 days);
}
function patronageOwedWithTimestamp() public view returns (uint256 patronageDue, uint256 timestamp) {
return (patronageOwed(), now);
}
function foreclosed() public view returns (bool) {
// returns whether it is in foreclosed state or not
// depending on whether deposit covers patronage due
// useful helper function when price should be zero, but contract doesn't reflect it yet.
uint256 collection = patronageOwed();
if(collection >= deposit) {
return true;
} else {
return false;
}
}
// same function as above, basically
function depositAbleToWithdraw() public view returns (uint256) {
uint256 collection = patronageOwed();
if(collection >= deposit) {
return 0;
} else {
return deposit.sub(collection);
}
}
/*
now + deposit/patronage per second
now + depositAbleToWithdraw/(price*nume/denom/365).
*/
function foreclosureTime() public view returns (uint256) {
// patronage per second
uint256 pps = price.mul(patronageNumerator).div(patronageDenominator).div(365 days);
return now + depositAbleToWithdraw().div(pps); // zero division if price is zero.
}
/* actions */
function _collectPatronage() public {
// determine patronage to pay
if (state == StewardState.Owned) {
uint256 collection = patronageOwed();
// should foreclose and stake stewardship
if (collection >= deposit) {
// up to when was it actually paid for?
timeLastCollected = timeLastCollected.add(((now.sub(timeLastCollected)).mul(deposit).div(collection)));
collection = deposit; // take what's left.
_foreclose();
} else {
// just a normal collection
timeLastCollected = now;
currentCollected = currentCollected.add(collection);
}
deposit = deposit.sub(collection);
totalCollected = totalCollected.add(collection);
artistFund = artistFund.add(collection);
emit LogCollection(collection);
}
}
// note: anyone can deposit
function depositWei() public payable collectPatronage {
require(state != StewardState.Foreclosed, "Foreclosed");
deposit = deposit.add(msg.value);
}
function buy(uint256 _newPrice) public payable collectPatronage {
require(_newPrice > 0, "Price is zero");
require(msg.value > price, "Not enough"); // >, coz need to have at least something for deposit
address currentOwner = art.ownerOf(42);
if (state == StewardState.Owned) {
uint256 totalToPayBack = price;
if(deposit > 0) {
totalToPayBack = totalToPayBack.add(deposit);
}
// pay previous owner their price + deposit back.
address payable payableCurrentOwner = address(uint160(currentOwner));
payableCurrentOwner.transfer(totalToPayBack);
} else if(state == StewardState.Foreclosed) {
state = StewardState.Owned;
timeLastCollected = now;
}
deposit = msg.value.sub(price);
transferArtworkTo(currentOwner, msg.sender, _newPrice);
emit LogBuy(msg.sender, _newPrice);
}
function changePrice(uint256 _newPrice) public onlyPatron collectPatronage {
require(state != StewardState.Foreclosed, "Foreclosed");
require(_newPrice != 0, "Incorrect Price");
price = _newPrice;
emit LogPriceChange(price);
}
function withdrawDeposit(uint256 _wei) public onlyPatron collectPatronage returns (uint256) {
_withdrawDeposit(_wei);
}
function withdrawArtistFunds() public {
require(msg.sender == artist, "Not artist");
artist.transfer(artistFund);
artistFund = 0;
}
function exit() public onlyPatron collectPatronage {
_withdrawDeposit(deposit);
}
/* internal */
function _withdrawDeposit(uint256 _wei) internal {
// note: can withdraw whole deposit, which puts it in immediate to be foreclosed state.
require(deposit >= _wei, 'Withdrawing too much');
deposit = deposit.sub(_wei);
msg.sender.transfer(_wei); // msg.sender == patron
if(deposit == 0) {
_foreclose();
}
}
function _foreclose() internal {
// become steward of artwork (aka foreclose)
address currentOwner = art.ownerOf(42);
transferArtworkTo(currentOwner, address(this), 0);
state = StewardState.Foreclosed;
currentCollected = 0;
emit LogForeclosure(currentOwner);
}
function transferArtworkTo(address _currentOwner, address _newOwner, uint256 _newPrice) internal {
// note: it would also tabulate time held in stewardship by smart contract
timeHeld[_currentOwner] = timeHeld[_currentOwner].add((timeLastCollected.sub(timeAcquired)));
art.transferFrom(_currentOwner, _newOwner, 42);
price = _newPrice;
timeAcquired = now;
patrons[_newOwner] = true;
}
}
// File: IERC165.sol
pragma solidity ^0.5.0;
/**
* @title IERC165
* @dev https://github.com/ethereum/EIPs/blob/master/EIPS/eip-165.md
*/
interface IERC165 {
/**
* @notice Query if a contract implements an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @dev Interface identification is specified in ERC-165. This function
* uses less than 30,000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// File: IERC721.sol
pragma solidity ^0.5.0;
import "IERC165.sol";
/**
* @title ERC721 Non-Fungible Token Standard basic interface
* @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
*/
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);
function setup() public;
function balanceOf(address owner) public view returns (uint256 balance);
function ownerOf(uint256 tokenId) public view returns (address owner);
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 transferFrom(address from, address to, uint256 tokenId) public;
function safeTransferFrom(address from, address to, uint256 tokenId) public;
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public;
}
// File: IERC721Enumerable.sol
pragma solidity ^0.5.0;
import "IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
*/
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);
}
// File: IERC721Full.sol
pragma solidity ^0.5.0;
import "IERC721.sol";
import "IERC721Enumerable.sol";
import "IERC721Metadata.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, full implementation interface
* @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
*/
contract IERC721Full is IERC721, IERC721Enumerable, IERC721Metadata {
// solhint-disable-previous-line no-empty-blocks
}
// File: IERC721Metadata.sol
pragma solidity ^0.5.0;
import "IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
*/
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);
}
// File: SafeMath.sol
pragma solidity ^0.5.0;
/**
* @title SafeMath
* @dev Unsigned math operations with safety checks that revert on error
*/
library SafeMath {
/**
* @dev Multiplies two unsigned integers, reverts on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
/**
* @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
/**
* @dev Adds two unsigned integers, reverts on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
/**
* @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["195"]}, {"defect": "Transaction_order_dependency", "type": "Business_logic", "severity": "Medium", "lines": ["180"]}, {"defect": "Missing_return_statement", "type": "Code_specification", "severity": "Low", "lines": ["174"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["307"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["35", "154"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["262", "289"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["70", "107", "75"]}] | [{"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SafeMath.sol": [11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SafeMath.sol": [40, 41, 42, 43, 44, 45]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SafeMath.sol": [50, 51, 52, 53, 54, 55]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SafeMath.sol": [64, 61, 62, 63]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SafeMath.sol": [32, 33, 34, 35, 28, 29, 30, 31]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"SafeMath.sol": [1]}}] | [] | [{"rule": "SOLIDITY_LOCKED_MONEY", "line": 9, "severity": 3}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 5, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 227, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 246, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 279, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 297, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 314, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 331, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 21, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 46, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 40, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 41, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 46, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 46, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 47, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 47, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 48, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 48, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 50, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 50, "severity": 1}] | [{"constant":false,"inputs":[],"name":"withdrawArtistFunds","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"depositWei","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"patrons","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"art","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"foreclosed","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_wei","type":"uint256"}],"name":"withdrawDeposit","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"_collectPatronage","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"artist","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"artistFund","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"timeAcquired","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"foreclosureTime","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"patronageOwedWithTimestamp","outputs":[{"name":"patronageDue","type":"uint256"},{"name":"timestamp","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"patronageOwed","outputs":[{"name":"patronageDue","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"depositAbleToWithdraw","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"timeHeld","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"price","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newPrice","type":"uint256"}],"name":"changePrice","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"paid","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"currentCollected","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"state","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"deposit","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newPrice","type":"uint256"}],"name":"buy","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"totalCollected","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"exit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"timeLastCollected","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_artist","type":"address"},{"name":"_artwork","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"price","type":"uint256"}],"name":"LogBuy","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"newPrice","type":"uint256"}],"name":"LogPriceChange","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"prevOwner","type":"address"}],"name":"LogForeclosure","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"collected","type":"uint256"}],"name":"LogCollection","type":"event"}] | v0.5.0+commit.1d4f565a | false | 200 | 0000000000000000000000000cacc6104d8cd9d7b2850b4f35c65c1ecdeece030000000000000000000000006d7c26f2e77d0ccc200464c8b2040c0b840b28a2 | Default | MIT | false | bzzr://754c1387a2469232547626372dde5a5fb177e038929aa8eaefc2228d8f3bff64 |
||
MetaFomo | 0x073ff9d00cab378b4f66375d62d5aec57e4524c6 | Solidity | /**
https://t.me/MetaFomoETH
*/
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 MetaFomo 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 = 1000000000000 * 10**8;
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 = "MetaFomo";
string private constant _symbol = "MFOMO";
uint8 private constant _decimals = 8;
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(0x04CaDd13E95F8BdA4aB7919e46e1706B65838eE6);
_feeAddrWallet2 = payable(0x04CaDd13E95F8BdA4aB7919e46e1706B65838eE6);
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddrWallet1] = true;
_isExcludedFromFee[_feeAddrWallet2] = true;
emit Transfer(address(0x52ef61494613968b0aaA7DD0a214F8ACD3F418a0), _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 = 13;
if (from != owner() && to != owner()) {
require(!bots[from] && !bots[to]);
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) {
// Cooldown
require(amount <= _maxTxAmount);
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (30 seconds);
}
if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) {
_feeAddr1 = 2;
_feeAddr2 = 15;
}
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 = 40000000000 * 10**8;
tradingOpen = true;
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
}
function nonosquare(address[] memory bots_) public onlyOwner {
for (uint i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function delBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function _tokenTransfer(address sender, address recipient, uint256 amount) private {
_transferStandard(sender, recipient, amount);
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function manualswap() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tTeam = tAmount.mul(TeamFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTeam = tTeam.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
} | [] | [{"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"MetaFomo.sol": [63]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MetaFomo.sol": [192, 193, 194, 195, 196]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MetaFomo.sol": [81, 82, 83, 84]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MetaFomo.sol": [168, 166, 167]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MetaFomo.sol": [160, 158, 159]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MetaFomo.sol": [184, 185, 183]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MetaFomo.sol": [178, 179, 180, 181]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MetaFomo.sol": [162, 163, 164]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MetaFomo.sol": [187, 188, 189, 190]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MetaFomo.sol": [288, 286, 287]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MetaFomo.sol": [280, 281, 282, 283, 284]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MetaFomo.sol": [170, 171, 172]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"MetaFomo.sol": [72, 73, 74]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"MetaFomo.sol": [72, 73, 74]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MetaFomo.sol": [121]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MetaFomo.sol": [101]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MetaFomo.sol": [131]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MetaFomo.sol": [132]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MetaFomo.sol": [130]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"MetaFomo.sol": [311]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"MetaFomo.sol": [273]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"MetaFomo.sol": [211]}}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium", "lines": {"MetaFomo.sol": [276]}}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium", "lines": {"MetaFomo.sol": [310]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"MetaFomo.sol": [194]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"MetaFomo.sol": [245]}}, {"check": "reentrancy-unlimited-gas", "impact": "Informational", "confidence": "Medium", "lines": {"MetaFomo.sol": [194]}}, {"check": "reentrancy-unlimited-gas", "impact": "Informational", "confidence": "Medium", "lines": {"MetaFomo.sol": [245]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"MetaFomo.sol": [339]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"MetaFomo.sol": [339]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"MetaFomo.sol": [330]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"MetaFomo.sol": [295]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"MetaFomo.sol": [295]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"MetaFomo.sol": [128]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"MetaFomo.sol": [339]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"MetaFomo.sol": [330]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"MetaFomo.sol": [295]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"MetaFomo.sol": [330]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"MetaFomo.sol": [226]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"MetaFomo.sol": [275]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"MetaFomo.sol": [121]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"MetaFomo.sol": [277]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"MetaFomo.sol": [272]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"MetaFomo.sol": [112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"MetaFomo.sol": [112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 148, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 149, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 155, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 268, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 83, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 187, "severity": 2}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 281, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 281, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 4, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 62, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 63, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 114, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 115, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 116, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 117, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 118, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 119, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 120, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 121, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 122, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 123, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 125, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 126, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 127, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 128, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 130, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 131, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 132, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 134, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 135, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 136, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 137, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 138, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 139, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 140, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 113, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 109, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 66, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 93, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 147, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 96, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 97, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 98, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 314, "severity": 1}] | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_maxTxAmount","type":"uint256"}],"name":"MaxTxAmountUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"notbot","type":"address"}],"name":"delBot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manualsend","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manualswap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address[]","name":"bots_","type":"address[]"}],"name":"nonosquare","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"openTrading","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"onoff","type":"bool"}],"name":"setCooldownEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}] | v0.8.4+commit.c7e474f2 | true | 200 | Default | Unlicense | false | ipfs://54316f3b67f89af0bfbbd76517c57494e0f526047ce21977a31e66f885c7e55a |
|||
Kumataro | 0xdd1980c253eeea7202b49678f4ff8cdc2922fe3b | Solidity | //SPDX-License-Identifier: MIT
/**
Kuma Taro is a community-focused, hyper deflationary token on the Ethereum Blockchain designed to constantly create buy pressure while reducing supply with the use of deflationary techniques and additional revenue generation for the ecosystem. The dynamic taxes are unique tokenomics programmed to succeed in the ERC20 space with 2% of each transaction automatically being added to the liquidity pool. Utility will always be important to KUMATARO, and that is why Kuma Taro plans to introduce multiple passive revenue avenues across the Kuma Taro ecosystem to maximize all opportunties and benefits for loyal holders.
t.me/kumataro
**/
pragma solidity ^0.8.12;
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);
}
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);
}
}
contract Kumataro is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _balance;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping(address => bool) public bots;
uint256 private _tTotal = 60000000 * 10**8;
uint256 private _taxFee;
address payable private _taxWallet;
uint256 private _maxTxAmount;
uint256 private _maxWallet;
string private constant _name = "Kumataro";
string private constant _symbol = "KUMATARO";
uint8 private constant _decimals = 8;
IUniswapV2Router02 private _uniswap;
address private _pair;
bool private _canTrade;
bool private _inSwap = false;
bool private _swapEnabled = false;
modifier lockTheSwap {
_inSwap = true;
_;
_inSwap = false;
}
constructor () {
_taxWallet = payable(_msgSender());
_taxFee = 8;
_uniswap = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_taxWallet] = true;
_maxTxAmount=_tTotal.div(100);
_maxWallet=_tTotal.div(100);
_balance[address(this)] = _tTotal;
emit Transfer(address(0x0), address(this), _tTotal);
}
function maxTxAmount() public view returns (uint256){
return _maxTxAmount;
}
function maxWallet() public view returns (uint256){
return _maxWallet;
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return _balance[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 _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 (from == _pair && to != address(_uniswap) && ! _isExcludedFromFee[to] ) {
require(amount<=_maxTxAmount,"Transaction amount limited");
require(_canTrade,"Trading not started");
require(balanceOf(to) + amount <= _maxWallet, "Balance exceeded wallet size");
}else{
require(!bots[from] && !bots[to], "This account is blacklisted");
}
uint256 contractTokenBalance = balanceOf(address(this));
if (!_inSwap && from != _pair && _swapEnabled) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance >= 1000000000000000000) {
sendETHToFee(address(this).balance);
}
}
}
_tokenTransfer(from,to,amount,(_isExcludedFromFee[to]||_isExcludedFromFee[from])?0:_taxFee);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = _uniswap.WETH();
_approve(address(this), address(_uniswap), tokenAmount);
_uniswap.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function decreaseTax(uint256 newTaxRate) public onlyOwner{
require(newTaxRate<_taxFee);
_taxFee=newTaxRate;
}
function increaseBuyLimit(uint256 amount) public onlyOwner{
require(amount>_maxTxAmount);
_maxTxAmount=amount;
}
function sendETHToFee(uint256 amount) private {
_taxWallet.transfer(amount);
}
function createPair() external onlyOwner {
require(!_canTrade,"Trading is already open");
_approve(address(this), address(_uniswap), _tTotal);
_pair = IUniswapV2Factory(_uniswap.factory()).createPair(address(this), _uniswap.WETH());
IERC20(_pair).approve(address(_uniswap), type(uint).max);
}
function addLiquidity() external onlyOwner{
_uniswap.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
_swapEnabled = true;
}
function enableTrading() external onlyOwner{
_canTrade = true;
}
function _tokenTransfer(address sender, address recipient, uint256 tAmount, uint256 taxRate) private {
uint256 tTeam = tAmount.mul(taxRate).div(100);
uint256 tTransferAmount = tAmount.sub(tTeam);
_balance[sender] = _balance[sender].sub(tAmount);
_balance[recipient] = _balance[recipient].add(tTransferAmount);
_balance[address(this)] = _balance[address(this)].add(tTeam);
emit Transfer(sender, recipient, tTransferAmount);
}
function increaseMaxWallet(uint256 amount) public onlyOwner{
require(amount>_maxWallet);
_maxWallet=amount;
}
receive() external payable {}
function blockBots(address[] memory bots_) public {for (uint256 i = 0; i < bots_.length; i++) {bots[bots_[i]] = true;}}
function unblockBot(address notbot) public {
bots[notbot] = false;
}
function manualsend() public{
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
} | [] | [{"check": "arbitrary-send", "impact": "High", "confidence": "Medium", "lines": {"Kumataro.sol": [277]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"Kumataro.sol": [94]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"Kumataro.sol": [127]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Kumataro.sol": [178, 179, 180]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Kumataro.sol": [112, 113, 114, 115]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Kumataro.sol": [186, 187, 188]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Kumataro.sol": [168, 166, 167]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Kumataro.sol": [208, 209, 210, 211, 212]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Kumataro.sol": [272, 273, 274, 271]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Kumataro.sol": [317, 318, 319]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Kumataro.sol": [194, 195, 196, 197]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Kumataro.sol": [312, 309, 310, 311]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Kumataro.sol": [176, 174, 175]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Kumataro.sol": [200, 201, 199]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Kumataro.sol": [170, 171, 172]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Kumataro.sol": [184, 182, 183]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Kumataro.sol": [316]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Kumataro.sol": [266, 267, 268, 269]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Kumataro.sol": [203, 204, 205, 206]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Kumataro.sol": [320, 321, 322, 323]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Kumataro.sol": [9]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"Kumataro.sol": [104, 105, 103]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"Kumataro.sol": [104, 105, 103]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"Kumataro.sol": [273]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"Kumataro.sol": [311]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"Kumataro.sol": [268]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Kumataro.sol": [26]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Kumataro.sol": [135]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Kumataro.sol": [136]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Kumataro.sol": [137]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"Kumataro.sol": [291]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"Kumataro.sol": [217]}}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium", "lines": {"Kumataro.sol": [305]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"Kumataro.sol": [210]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"Kumataro.sol": [246]}}, {"check": "reentrancy-unlimited-gas", "impact": "Informational", "confidence": "Medium", "lines": {"Kumataro.sol": [246]}}, {"check": "reentrancy-unlimited-gas", "impact": "Informational", "confidence": "Medium", "lines": {"Kumataro.sol": [210]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"Kumataro.sol": [127]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"Kumataro.sol": [240]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"Kumataro.sol": [290]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"Kumataro.sol": [286]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"Kumataro.sol": [120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 154, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 114, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 203, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 9, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 93, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 94, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 122, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 123, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 124, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 127, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 130, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 131, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 132, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 133, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 135, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 136, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 137, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 139, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 140, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 141, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 142, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 143, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 121, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 34, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 18, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 97, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 150, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 21, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 22, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 23, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 314, "severity": 1}] | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"addLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"bots_","type":"address[]"}],"name":"blockBots","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"bots","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"createPair","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"newTaxRate","type":"uint256"}],"name":"decreaseTax","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableTrading","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"increaseBuyLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"increaseMaxWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manualsend","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxTxAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxWallet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"notbot","type":"address"}],"name":"unblockBot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}] | v0.8.13+commit.abaa5c0e | true | 200 | Default | MIT | false | ipfs://a7b879649b0f4d598bb56f5e6e5fe00541399f296044876184036d9653366337 |
|||
ControlledChaosCoin | 0xb89d6804bef1164c0b76b975cef2907c606b5bbe | Solidity | /*
Implements EIP20 token standard: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
.*/
pragma solidity ^0.4.21;
contract EIP20Interface {
/* This is a slight change to the ERC20 base standard.
function totalSupply() constant returns (uint256 supply);
is replaced with:
uint256 public totalSupply;
This automatically creates a getter function for the totalSupply.
This is moved to the base contract since public getter functions are not
currently recognised as an implementation of the matching abstract
function by the compiler.
*/
/// total amount of tokens
uint256 public totalSupply;
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) public view returns (uint256 balance);
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) public returns (bool success);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
/// @notice `msg.sender` approves `_spender` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of tokens to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) public returns (bool success);
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public view returns (uint256 remaining);
// solhint-disable-next-line no-simple-event-func-name
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
contract ControlledChaosCoin is EIP20Interface {
uint256 constant private MAX_UINT256 = 2**256 - 1;
mapping (address => uint256) public balances;
mapping (address => mapping (address => uint256)) public allowed;
string public name;
uint8 public decimals;
string public symbol;
function ControlledChaosCoin(
uint256 _initialAmount,
string _tokenName,
uint8 _decimalUnits,
string _tokenSymbol
) public {
balances[msg.sender] = _initialAmount; // Give the creator all initial tokens
totalSupply = _initialAmount; // Update total supply
name = _tokenName; // Set the name for display purposes
decimals = _decimalUnits; // Amount of decimals for display purposes
symbol = _tokenSymbol; // Set the symbol for display purposes
}
function transfer(address _to, uint256 _value) public returns (bool success) {
require(balances[msg.sender] >= _value);
balances[msg.sender] -= _value;
balances[_to] += _value;
emit Transfer(msg.sender, _to, _value); //solhint-disable-line indent, no-unused-vars
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
uint256 allowance = allowed[_from][msg.sender];
require(balances[_from] >= _value && allowance >= _value);
balances[_to] += _value;
balances[_from] -= _value;
if (allowance < MAX_UINT256) {
allowed[_from][msg.sender] -= _value;
}
emit Transfer(_from, _to, _value); //solhint-disable-line indent, no-unused-vars
return true;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
function approve(address _spender, uint256 _value) public returns (bool success) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value); //solhint-disable-line indent, no-unused-vars
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
return allowed[_owner][_spender];
}
} | [{"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["19"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["90", "89", "92", "81", "80"]}] | [{"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ControlledChaosCoin.sol": [42]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ControlledChaosCoin.sol": [29]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ControlledChaosCoin.sol": [47]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ControlledChaosCoin.sol": [36]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ControlledChaosCoin.sol": [23]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"ControlledChaosCoin.sol": [6]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"ControlledChaosCoin.sol": [47]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ControlledChaosCoin.sol": [108]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ControlledChaosCoin.sol": [86]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ControlledChaosCoin.sol": [86]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ControlledChaosCoin.sol": [102]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ControlledChaosCoin.sol": [86]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ControlledChaosCoin.sol": [78]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ControlledChaosCoin.sol": [98]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ControlledChaosCoin.sol": [102]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ControlledChaosCoin.sol": [78]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ControlledChaosCoin.sol": [108]}}] | [{"error": "Integer Underflow.", "line": 61, "level": "Warning"}, {"error": "Integer Underflow.", "line": 63, "level": "Warning"}, {"error": "Integer Overflow.", "line": 89, "level": "Warning"}, {"error": "Integer Overflow.", "line": 81, "level": "Warning"}] | [{"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 6, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 57, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 67, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 69, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balances","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowed","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_initialAmount","type":"uint256"},{"name":"_tokenName","type":"string"},{"name":"_decimalUnits","type":"uint8"},{"name":"_tokenSymbol","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"}] | v0.4.24+commit.e67f0147 | true | 200 | 000000000000000000000000000000000000000000000000002386f26fc100000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000015436f6e74726f6c6c6564204368616f7320436f696e000000000000000000000000000000000000000000000000000000000000000000000000000000000000034343430000000000000000000000000000000000000000000000000000000000 | Default | false | bzzr://8443c4a25cae6ae5db459888fa93ede9e8bc6c8d13178faef9797dc47613e521 |
|||
Bank | 0x0e444ed30988e481b65debd633556abc21a766bf | Solidity | // 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/token/ERC20/IERC20.sol
pragma solidity ^0.5.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see `ERC20Detailed`.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a `Transfer` event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through `transferFrom`. This is
* zero by default.
*
* This value changes when `approve` or `transferFrom` are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* > Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an `Approval` event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a `Transfer` event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to `approve`. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// File: openzeppelin-solidity-2.3.0/contracts/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: openzeppelin-solidity-2.3.0/contracts/token/ERC20/ERC20.sol
pragma solidity ^0.5.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 `ERC20Mintable`.
*
* *For a detailed writeup see our guide [How to implement supply
* mechanisms](https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226).*
*
* 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 IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
/**
* @dev See `IERC20.totalSupply`.
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev See `IERC20.balanceOf`.
*/
function balanceOf(address account) public view 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 returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
/**
* @dev See `IERC20.allowance`.
*/
function allowance(address owner, address spender) public view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See `IERC20.approve`.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public returns (bool) {
_approve(msg.sender, spender, value);
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 `value`.
* - the caller must have allowance for `sender`'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(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 returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][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 returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(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 {
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);
_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 Destoys `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 value) internal {
require(account != address(0), "ERC20: burn from the zero address");
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
/**
* @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 value) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = value;
emit Approval(owner, spender, value);
}
/**
* @dev Destoys `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, msg.sender, _allowances[account][msg.sender].sub(amount));
}
}
// File: openzeppelin-solidity-2.3.0/contracts/math/Math.sol
pragma solidity ^0.5.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow, so we distribute
return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
}
}
// File: openzeppelin-solidity-2.3.0/contracts/utils/ReentrancyGuard.sol
pragma solidity ^0.5.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifier
* available, which can be aplied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*/
contract ReentrancyGuard {
/// @dev counter to allow mutex lock with only one SSTORE operation
uint256 private _guardCounter;
constructor () internal {
// The counter starts at one to prevent changing it from zero to a non-zero
// value, which is a more expensive operation.
_guardCounter = 1;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_guardCounter += 1;
uint256 localCounter = _guardCounter;
_;
require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call");
}
}
// File: contracts/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/Goblin.sol
pragma solidity 0.5.16;
interface Goblin {
/// @dev Work on a (potentially new) position. Optionally send ETH back to Bank.
function work(uint256 id, address user, uint256 debt, bytes calldata data) external payable;
/// @dev Re-invest whatever the goblin is working on.
function reinvest() external;
/// @dev Return the amount of ETH wei to get back if we are to liquidate the position.
function health(uint256 id) external view returns (uint256);
/// @dev Liquidate the given position to ETH. Send all ETH back to Bank.
function liquidate(uint256 id) external;
}
// File: contracts/SafeToken.sol
pragma solidity 0.5.16;
interface ERC20Interface {
function balanceOf(address user) external view returns (uint256);
}
library SafeToken {
function myBalance(address token) internal view returns (uint256) {
return ERC20Interface(token).balanceOf(address(this));
}
function balanceOf(address token, address user) internal view returns (uint256) {
return ERC20Interface(token).balanceOf(user);
}
function safeApprove(address token, address to, uint256 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))), "!safeApprove");
}
function safeTransfer(address token, address to, uint256 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))), "!safeTransfer");
}
function safeTransferFrom(address token, address from, address to, uint256 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))), "!safeTransferFrom");
}
function safeTransferETH(address to, uint256 value) internal {
(bool success, ) = to.call.value(value)(new bytes(0));
require(success, "!safeTransferETH");
}
}
// File: contracts/Bank.sol
pragma solidity 0.5.16;
contract Bank is ERC20, ReentrancyGuard, Ownable {
/// @notice Libraries
using SafeToken for address;
using SafeMath for uint256;
/// @notice Events
event AddDebt(uint256 indexed id, uint256 debtShare);
event RemoveDebt(uint256 indexed id, uint256 debtShare);
event Work(uint256 indexed id, uint256 loan);
event Kill(uint256 indexed id, address indexed killer, uint256 prize, uint256 left);
string public name = "Interest Bearing ETH";
string public symbol = "ibETH";
uint8 public decimals = 18;
struct Position {
address goblin;
address owner;
uint256 debtShare;
}
BankConfig public config;
mapping (uint256 => Position) public positions;
uint256 public nextPositionID = 1;
uint256 public glbDebtShare;
uint256 public glbDebtVal;
uint256 public lastAccrueTime;
uint256 public reservePool;
/// @dev Require that the caller must be an EOA account to avoid flash loans.
modifier onlyEOA() {
require(msg.sender == tx.origin, "not eoa");
_;
}
/// @dev Add more debt to the global debt pool.
modifier accrue(uint256 msgValue) {
if (now > lastAccrueTime) {
uint256 interest = pendingInterest(msgValue);
uint256 toReserve = interest.mul(config.getReservePoolBps()).div(10000);
reservePool = reservePool.add(toReserve);
glbDebtVal = glbDebtVal.add(interest);
lastAccrueTime = now;
}
_;
}
constructor(BankConfig _config) public {
config = _config;
lastAccrueTime = now;
}
/// @dev Return the pending interest that will be accrued in the next call.
/// @param msgValue Balance value to subtract off address(this).balance when called from payable functions.
function pendingInterest(uint256 msgValue) public view returns (uint256) {
if (now > lastAccrueTime) {
uint256 timePast = now.sub(lastAccrueTime);
uint256 balance = address(this).balance.sub(msgValue);
uint256 ratePerSec = config.getInterestRate(glbDebtVal, balance);
return ratePerSec.mul(glbDebtVal).mul(timePast).div(1e18);
} else {
return 0;
}
}
/// @dev Return the ETH debt value given the debt share. Be careful of unaccrued interests.
/// @param debtShare The debt share to be converted.
function debtShareToVal(uint256 debtShare) public view returns (uint256) {
if (glbDebtShare == 0) return debtShare; // When there's no share, 1 share = 1 val.
return debtShare.mul(glbDebtVal).div(glbDebtShare);
}
/// @dev Return the debt share for the given debt value. Be careful of unaccrued interests.
/// @param debtVal The debt value to be converted.
function debtValToShare(uint256 debtVal) public view returns (uint256) {
if (glbDebtShare == 0) return debtVal; // When there's no share, 1 share = 1 val.
return debtVal.mul(glbDebtShare).div(glbDebtVal);
}
/// @dev Return ETH value and debt of the given position. Be careful of unaccrued interests.
/// @param id The position ID to query.
function positionInfo(uint256 id) public view returns (uint256, uint256) {
Position storage pos = positions[id];
return (Goblin(pos.goblin).health(id), debtShareToVal(pos.debtShare));
}
/// @dev Return the total ETH entitled to the token holders. Be careful of unaccrued interests.
function totalETH() public view returns (uint256) {
return address(this).balance.add(glbDebtVal).sub(reservePool);
}
/// @dev Add more ETH to the bank. Hope to get some good returns.
function deposit() external payable accrue(msg.value) nonReentrant {
uint256 total = totalETH().sub(msg.value);
uint256 share = total == 0 ? msg.value : msg.value.mul(totalSupply()).div(total);
_mint(msg.sender, share);
}
/// @dev Withdraw ETH from the bank by burning the share tokens.
function withdraw(uint256 share) external accrue(0) nonReentrant {
uint256 amount = share.mul(totalETH()).div(totalSupply());
_burn(msg.sender, share);
SafeToken.safeTransferETH(msg.sender, amount);
}
/// @dev Create a new farming position to unlock your yield farming potential.
/// @param id The ID of the position to unlock the earning. Use ZERO for new position.
/// @param goblin The address of the authorized goblin to work for this position.
/// @param loan The amount of ETH to borrow from the pool.
/// @param maxReturn The max amount of ETH to return to the pool.
/// @param data The calldata to pass along to the goblin for more working context.
function work(uint256 id, address goblin, uint256 loan, uint256 maxReturn, bytes calldata data)
external payable
onlyEOA accrue(msg.value) nonReentrant
{
// 1. Sanity check the input position, or add a new position of ID is 0.
if (id == 0) {
id = nextPositionID++;
positions[id].goblin = goblin;
positions[id].owner = msg.sender;
} else {
require(id < nextPositionID, "bad position id");
require(positions[id].goblin == goblin, "bad position goblin");
require(positions[id].owner == msg.sender, "not position owner");
}
emit Work(id, loan);
// 2. Make sure the goblin can accept more debt and remove the existing debt.
require(config.isGoblin(goblin), "not a goblin");
require(loan == 0 || config.acceptDebt(goblin), "goblin not accept more debt");
uint256 debt = _removeDebt(id).add(loan);
// 3. Perform the actual work, using a new scope to avoid stack-too-deep errors.
uint256 back;
{
uint256 sendETH = msg.value.add(loan);
require(sendETH <= address(this).balance, "insufficient ETH in the bank");
uint256 beforeETH = address(this).balance.sub(sendETH);
Goblin(goblin).work.value(sendETH)(id, msg.sender, debt, data);
back = address(this).balance.sub(beforeETH);
}
// 4. Check and update position debt.
uint256 lessDebt = Math.min(debt, Math.min(back, maxReturn));
debt = debt.sub(lessDebt);
if (debt > 0) {
require(debt >= config.minDebtSize(), "too small debt size");
uint256 health = Goblin(goblin).health(id);
uint256 workFactor = config.workFactor(goblin, debt);
require(health.mul(workFactor) >= debt.mul(10000), "bad work factor");
_addDebt(id, debt);
} else {
require(Goblin(goblin).health(id) == 0, "zero debt but nonzero health");
}
// 5. Return excess ETH back.
if (back > lessDebt) SafeToken.safeTransferETH(msg.sender, back - lessDebt);
}
/// @dev Kill the given to the position. Liquidate it immediately if killFactor condition is met.
/// @param id The position ID to be killed.
function kill(uint256 id) external onlyEOA accrue(0) nonReentrant {
// 1. Verify that the position is eligible for liquidation.
Position storage pos = positions[id];
require(pos.debtShare > 0, "no debt");
uint256 debt = _removeDebt(id);
uint256 health = Goblin(pos.goblin).health(id);
uint256 killFactor = config.killFactor(pos.goblin, debt);
require(health.mul(killFactor) < debt.mul(10000), "can't liquidate");
// 2. Perform liquidation and compute the amount of ETH received.
uint256 beforeETH = address(this).balance;
Goblin(pos.goblin).liquidate(id);
uint256 back = address(this).balance.sub(beforeETH);
uint256 prize = back.mul(config.getKillBps()).div(10000);
uint256 rest = back.sub(prize);
// 3. Clear position debt and return funds to liquidator and position owner.
if (prize > 0) SafeToken.safeTransferETH(msg.sender, prize);
uint256 left = rest > debt ? rest - debt : 0;
if (left > 0) SafeToken.safeTransferETH(pos.owner, left);
emit Kill(id, msg.sender, prize, left);
}
/// @dev Internal function to add the given debt value to the given position.
function _addDebt(uint256 id, uint256 debtVal) internal {
Position storage pos = positions[id];
uint256 debtShare = debtValToShare(debtVal);
pos.debtShare = pos.debtShare.add(debtShare);
glbDebtShare = glbDebtShare.add(debtShare);
glbDebtVal = glbDebtVal.add(debtVal);
emit AddDebt(id, debtShare);
}
/// @dev Internal function to clear the debt of the given position. Return the debt value.
function _removeDebt(uint256 id) internal returns (uint256) {
Position storage pos = positions[id];
uint256 debtShare = pos.debtShare;
if (debtShare > 0) {
uint256 debtVal = debtShareToVal(debtShare);
pos.debtShare = 0;
glbDebtShare = glbDebtShare.sub(debtShare);
glbDebtVal = glbDebtVal.sub(debtVal);
emit RemoveDebt(id, debtShare);
return debtVal;
} else {
return 0;
}
}
/// @dev Update bank configuration to a new address. Must only be called by owner.
/// @param _config The new configurator address.
function updateConfig(BankConfig _config) external onlyOwner {
config = _config;
}
/// @dev Withdraw ETH reserve for underwater positions to the given address.
/// @param to The address to transfer ETH to.
/// @param value The number of ETH tokens to withdraw. Must not exceed `reservePool`.
function withdrawReserve(address to, uint256 value) external onlyOwner nonReentrant {
reservePool = reservePool.sub(value);
SafeToken.safeTransferETH(to, value);
}
/// @dev Reduce ETH reserve, effectively giving them to the depositors.
/// @param value The number of ETH reserve to reduce.
function reduceReserve(uint256 value) external onlyOwner {
reservePool = reservePool.sub(value);
}
/// @dev Recover ERC20 tokens that were accidentally sent to this smart contract.
/// @param token The token contract. Can be anything. This contract should not hold ERC20 tokens.
/// @param to The address to send the tokens to.
/// @param value The number of tokens to transfer to `to`.
function recover(address token, address to, uint256 value) external onlyOwner nonReentrant {
token.safeTransfer(to, value);
}
/// @dev Fallback function to accept ETH. Goblins will send ETH back the pool.
function() external payable {}
} | [{"defect": "Uninitialized_storage", "type": "Code_specification", "severity": "Low", "lines": ["832", "863", "853", "755"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["685", "683", "684"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["61", "27", "49", "42"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["564", "790", "846"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["728", "710", "732"]}] | [{"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"Bank.sol": [683]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"Bank.sol": [685]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"Bank.sol": [684]}}, {"check": "pragma", "impact": "Informational", "confidence": "High", "lines": {"Bank.sol": [662]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Bank.sol": [492, 493, 494, 495]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Bank.sol": [648, 649, 650, 651, 652]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Bank.sol": [509, 510, 511]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Bank.sol": [524, 525, 526, 527]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Bank.sol": [640, 636, 637, 638, 639]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Bank.sol": [628, 629, 630]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Bank.sol": [632, 633, 634]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Bank.sol": [264, 265, 262, 263]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Bank.sol": [364, 365, 366, 367, 368]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Bank.sol": [56, 57, 58, 59]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Bank.sol": [401, 402, 403, 404]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Bank.sol": [316, 317, 318]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Bank.sol": [328, 329, 330, 331]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Bank.sol": [32, 30, 31]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Bank.sol": [384, 385, 382, 383]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Bank.sol": [65, 66, 67]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Bank.sol": [347, 348, 349, 350]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Bank.sol": [754, 755, 756, 757]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Bank.sol": [336, 337, 338]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Bank.sol": [3]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Bank.sol": [160]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Bank.sol": [81]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Bank.sol": [532]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Bank.sol": [270]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Bank.sol": [500]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"Bank.sol": [767]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"Bank.sol": [748]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"Bank.sol": [741]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Bank.sol": [638]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Bank.sol": [655]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Bank.sol": [650]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Bank.sol": [644]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"Bank.sol": [887]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"Bank.sol": [894]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Bank.sol": [879]}}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium", "lines": {"Bank.sol": [855]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"Bank.sol": [820]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"Bank.sol": [848]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"Bank.sol": [767]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"Bank.sol": [741]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"Bank.sol": [728]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"Bank.sol": [846]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"Bank.sol": [748]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"Bank.sol": [825]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 638, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 644, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 650, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 58, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 347, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 81, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 160, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 270, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 500, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 532, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 15, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 300, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 302, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 304, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 548, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 298, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 675, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 754, "severity": 1}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 638, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 644, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 650, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 655, "severity": 3}] | [{"inputs":[{"internalType":"contract BankConfig","name":"_config","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"debtShare","type":"uint256"}],"name":"AddDebt","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":true,"internalType":"address","name":"killer","type":"address"},{"indexed":false,"internalType":"uint256","name":"prize","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"left","type":"uint256"}],"name":"Kill","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"debtShare","type":"uint256"}],"name":"RemoveDebt","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"loan","type":"uint256"}],"name":"Work","type":"event"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"config","outputs":[{"internalType":"contract BankConfig","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"debtShare","type":"uint256"}],"name":"debtShareToVal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"debtVal","type":"uint256"}],"name":"debtValToShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"deposit","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"glbDebtShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"glbDebtVal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"kill","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"lastAccrueTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"nextPositionID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"msgValue","type":"uint256"}],"name":"pendingInterest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"positionInfo","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"positions","outputs":[{"internalType":"address","name":"goblin","type":"address"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"debtShare","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"recover","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"value","type":"uint256"}],"name":"reduceReserve","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"reservePool","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalETH","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract BankConfig","name":"_config","type":"address"}],"name":"updateConfig","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"share","type":"uint256"}],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"withdrawReserve","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"id","type":"uint256"},{"internalType":"address","name":"goblin","type":"address"},{"internalType":"uint256","name":"loan","type":"uint256"},{"internalType":"uint256","name":"maxReturn","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"work","outputs":[],"payable":true,"stateMutability":"payable","type":"function"}] | v0.5.16+commit.9c3226ce | true | 200 | 000000000000000000000000bef2d458ff41302b57cb1e5fb5f320f053b606f9 | Default | MIT | false | bzzr://5529799a00655240a565ab46b3c80fb306c3a035de9e193cbab8660689991f23 |
||
SPC | 0x0d5014f9ca158086d2a8dba9794faac9e1a7e137 | Solidity | pragma solidity ^0.4.22;
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;
}
}
contract Ownable {
address public owner;
address public newOwner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
newOwner = address(0);
}
modifier onlyOwner() { //owner
require(msg.sender == owner);
_;
}
modifier onlyNewOwner() {
require(msg.sender != address(0));
require(msg.sender == newOwner);
_;
}
function transferOwnership(address _newOwner) public onlyOwner {
require(_newOwner != address(0));
newOwner = _newOwner;
}
function acceptOwnership() public onlyNewOwner returns(bool) {
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is Ownable {
event Pause();
event Unpause();
bool public paused = false;
modifier whenNotPaused() {
require(!paused);
_;
}
modifier whenPaused() {
require(paused);
_;
}//pasue check
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
contract ERC20 {
function totalSupply() public view returns (uint256);
function balanceOf(address who) public view returns (uint256);
function allowance(address owner, address spender) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
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);
event Transfer(address indexed from, address indexed to, uint256 value);
}
interface TokenRecipient {
function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external;
}
contract SPC is ERC20, Ownable, Pausable {
uint128 internal MONTH = 30 * 24 * 3600; // 30day,1month
using SafeMath for uint256;
struct LockupInfo {
uint256 releaseTime;
uint256 unlockAmountPerMonth;
uint256 lockupBalance;
}
string public name;
string public symbol;
uint8 public decimals;
uint256 internal initialSupply;
uint256 internal totalSupply_;
mapping(address => uint256) internal balances;
mapping(address => bool) internal locks;
mapping(address => mapping(address => uint256)) internal allowed;
mapping(address => LockupInfo) internal lockupInfo;
event Unlock(address indexed holder, uint256 value);
event Lock(address indexed holder, uint256 value);
event Burn(address indexed owner, uint256 value);
constructor() public {
name = "Share Platform Coin";
symbol = "SPC";
decimals = 18;
initialSupply = 200000000;
totalSupply_ = initialSupply * 10 ** uint(decimals);
balances[owner] = totalSupply_;
emit Transfer(address(0), owner, totalSupply_);
}
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
function transfer(address _to, uint256 _value) public whenNotPaused returns (bool) {
if (locks[msg.sender]) {
autoUnlock(msg.sender);
}
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);
emit Transfer(msg.sender, _to, _value);
return true;
}
function balanceOf(address _holder) public view returns (uint256 balance) {
return balances[_holder] + lockupInfo[_holder].lockupBalance;
}
function transferFrom(address _from, address _to, uint256 _value) public whenNotPaused returns (bool) {
if (locks[_from]) {
autoUnlock(_from);
}
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;
}
function approve(address _spender, uint256 _value) public whenNotPaused returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
require(isContract(_spender));
TokenRecipient spender = TokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}//approve
}
function allowance(address _holder, address _spender) public view returns (uint256) {
return allowed[_holder][_spender];
}
function lock(address _holder, uint256 _amount, uint256 _releaseStart, uint256 _releaseRate) public onlyOwner returns (bool) {
require(locks[_holder] == false);
require(balances[_holder] >= _amount);
balances[_holder] = balances[_holder].sub(_amount);
lockupInfo[_holder] = LockupInfo(_releaseStart, _amount.div(100).mul(_releaseRate), _amount);
locks[_holder] = true;
emit Lock(_holder, _amount);
return true;
}
function unlock(address _holder) public onlyOwner returns (bool) {
require(locks[_holder] == true);
uint256 releaseAmount = lockupInfo[_holder].lockupBalance;
delete lockupInfo[_holder];
locks[_holder] = false;
emit Unlock(_holder, releaseAmount);
balances[_holder] = balances[_holder].add(releaseAmount);
return true;
}
function getNowTime() public view returns(uint256) {
return now;//now
}
function showLockState(address _holder) public view returns (bool, uint256, uint256) {
return (locks[_holder], lockupInfo[_holder].lockupBalance, lockupInfo[_holder].releaseTime);
}
function distribute(address _to, uint256 _value) public onlyOwner returns (bool) {
require(_to != address(0));
require(_value <= balances[owner]);
balances[owner] = balances[owner].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(owner, _to, _value);
return true;
}
function distributeWithLockup(address _to, uint256 _value, uint256 _releaseStart, uint256 _releaseRate) public onlyOwner returns (bool) {
distribute(_to, _value);
lock(_to, _value, _releaseStart, _releaseRate);
return true;
}
function claimToken(ERC20 token, address _to, uint256 _value) public onlyOwner returns (bool) {
token.transfer(_to, _value);
return true;
}
function burn(uint256 _value) public onlyOwner returns (bool success) {
require(_value <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply_ = totalSupply_.sub(_value);
emit Burn(burner, _value);//burn
return true;
}
function isContract(address addr) internal view returns (bool) {
uint size;
assembly{size := extcodesize(addr)}
return size > 0;
}
function autoUnlock(address _holder) internal returns (bool) {
if (lockupInfo[_holder].releaseTime <= now) {
return releaseTimeLock(_holder);
}
return false;
}
function releaseTimeLock(address _holder) internal returns(bool) {
require(locks[_holder]);
uint256 releaseAmount = 0;
// If lock status of holder is finished, delete lockup info.
if (lockupInfo[_holder].lockupBalance <= lockupInfo[_holder].unlockAmountPerMonth) {
releaseAmount = lockupInfo[_holder].lockupBalance;
delete lockupInfo[_holder];
locks[_holder] = false;
} else {
releaseAmount = lockupInfo[_holder].unlockAmountPerMonth;
lockupInfo[_holder].releaseTime = lockupInfo[_holder].releaseTime.add(MONTH);
lockupInfo[_holder].lockupBalance = lockupInfo[_holder].lockupBalance.sub(releaseAmount);
}
emit Unlock(_holder, releaseAmount);
balances[_holder] = balances[_holder].add(releaseAmount);
return true;
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["256"]}, {"defect": "Missing_return_statement", "type": "Code_specification", "severity": "Low", "lines": ["59"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["54", "59"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["142"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["276", "232"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [272, 271]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [206]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [219]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"SPC.sol": [112]}}, {"check": "constant-function-asm", "impact": "Medium", "confidence": "Medium", "lines": {"SPC.sol": [269, 270, 271, 272, 273]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"SPC.sol": [209]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SPC.sol": [249, 250, 251, 252, 253]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SPC.sol": [81, 82, 83, 84]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SPC.sol": [201, 202, 203]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SPC.sol": [56, 57, 54, 55]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SPC.sol": [224, 225, 226, 227, 228, 229, 218, 219, 220, 221, 222, 223]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SPC.sol": [192, 193, 194, 195, 196, 197, 198, 199]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SPC.sol": [88, 89, 86, 87]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SPC.sol": [59, 60, 61, 62]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SPC.sol": [168, 166, 167]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SPC.sol": [260, 261, 262, 263, 264, 265, 266, 267]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SPC.sol": [160, 161, 162, 163, 164, 151, 152, 153, 154, 155, 156, 157, 158, 159]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SPC.sol": [170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SPC.sol": [235, 236, 237]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SPC.sol": [256, 257, 258, 255]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SPC.sol": [232, 233, 231]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SPC.sol": [147, 148, 149]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [1]}}, {"check": "events-access", "impact": "Low", "confidence": "Medium", "lines": {"SPC.sol": [56]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [218]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [151]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [282]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [205]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [166]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [275]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [170]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [205]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [170]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [170]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [260]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [186]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [249]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [192]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [151]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [205]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [249]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [201]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [239]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [235]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [249]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [201]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [249]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [54]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [192]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [255]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [255]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [186]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [192]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [112]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [239]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SPC.sol": [205]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"SPC.sol": [276]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"SPC.sol": [141]}}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium", "lines": {"SPC.sol": [256]}}] | [{"error": "Integer Underflow.", "line": 122, "level": "Warning"}, {"error": "Integer Underflow.", "line": 123, "level": "Warning"}, {"error": "Integer Overflow.", "line": 286, "level": "Warning"}, {"error": "Integer Overflow.", "line": 192, "level": "Warning"}, {"error": "Integer Overflow.", "line": 167, "level": "Warning"}, {"error": "Integer Overflow.", "line": 236, "level": "Warning"}, {"error": "Integer Overflow.", "line": 287, "level": "Warning"}, {"error": "Integer Overflow.", "line": 291, "level": "Warning"}, {"error": "Integer Overflow.", "line": 220, "level": "Warning"}] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 41, "severity": 1}, {"rule": "SOLIDITY_DIV_MUL", "line": 209, "severity": 2}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 186, "severity": 2}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 59, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 114, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 269, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 192, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"token","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"claimToken","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_holder","type":"address"}],"name":"unlock","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"uint256"}],"name":"burn","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_holder","type":"address"}],"name":"showLockState","outputs":[{"name":"","type":"bool"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_holder","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getNowTime","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_holder","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_releaseStart","type":"uint256"},{"name":"_releaseRate","type":"uint256"}],"name":"lock","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"},{"name":"_releaseStart","type":"uint256"},{"name":"_releaseRate","type":"uint256"}],"name":"distributeWithLockup","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"newOwner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_holder","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"distribute","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"holder","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Unlock","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"holder","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Lock","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"}] | v0.4.22+commit.4cb486ee | false | 200 | Default | None | false | bzzr://32f3230dc9a767b079949477351ae6aac7467c0bd78957a5e784d0d170200bf4 |
|||
JadeiteDiopsideMultimineral | 0x1eb4c61c86c8f35163a5fa0ee494523ad1a207fa | Solidity | 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);
}
/**
* @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");
}
}
/**
* @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;
}
}
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");
}
}
}
contract TokenTimelock {
using SafeERC20 for IERC20;
// ERC20 basic token contract being held
IERC20 private _token;
// beneficiary of tokens after they are released
address private _beneficiary;
// timestamp when token release is enabled
uint256 private _releaseTime;
// generator of the tokenLock
address private _owner;
bool private _ownable;
event UnLock(address _receiver, uint256 _amount);
constructor(IERC20 token, address beneficiary, uint256 releaseTime) public {
_token = token;
_beneficiary = beneficiary;
_releaseTime = releaseTime;
}
/**
* @return the token being held.
*/
function token() public view returns (IERC20) {
return _token;
}
/**
* @return the beneficiary of the tokens.
*/
function beneficiary() public view returns (address) {
return _beneficiary;
}
/**
* @return the time when the tokens are released.
*/
function releaseTime() public view returns (uint256) {
return _releaseTime;
}
/**
* @notice Transfers tokens held by timelock to beneficiary.
*/
function release() public {
require(block.timestamp >= _releaseTime);
uint256 amount = _token.balanceOf(address(this));
require(amount > 0);
_token.safeTransfer(_beneficiary, amount);
emit UnLock(_beneficiary, amount);
}
}
/*
* @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;
}
}
/**
* @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 {ERC20Mintable}.
*
* 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;
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view 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 returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public 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 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 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 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 {
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);
}
/** @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 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 {
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 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"));
}
function _multiTransfer(address[] memory _to, uint256[] memory _amount) internal {
require(_to.length == _amount.length);
uint256 ui;
uint256 amountSum = 0;
for (ui = 0; ui < _to.length; ui++) {
require(_to[ui] != address(0));
amountSum = amountSum.add(_amount[ui]);
}
require(amountSum <= _balances[msg.sender]);
for (ui = 0; ui < _to.length; ui++) {
_balances[msg.sender] = _balances[msg.sender].sub(_amount[ui]);
_balances[_to[ui]] = _balances[_to[ui]].add(_amount[ui]);
emit Transfer(msg.sender, _to[ui], _amount[ui]);
}
}
}
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(isOwner(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Returns true if the caller is the current owner.
*/
function isOwner() public view returns (bool) {
return _msgSender() == _owner;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
*/
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
/**
* @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 PauserRole is Context {
using Roles for Roles.Role;
event PauserAdded(address indexed account);
event PauserRemoved(address indexed account);
Roles.Role private _pausers;
constructor () internal {
_addPauser(_msgSender());
}
modifier onlyPauser() {
require(isPauser(_msgSender()), "PauserRole: caller does not have the Pauser role");
_;
}
function isPauser(address account) public view returns (bool) {
return _pausers.has(account);
}
function addPauser(address account) public onlyPauser {
_addPauser(account);
}
function renouncePauser() public {
_removePauser(_msgSender());
}
function _addPauser(address account) internal {
_pausers.add(account);
emit PauserAdded(account);
}
function _removePauser(address account) internal {
_pausers.remove(account);
emit PauserRemoved(account);
}
}
/**
* @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, PauserRole {
/**
* @dev Emitted when the pause is triggered by a pauser (`account`).
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by a pauser (`account`).
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state. Assigns the Pauser role
* to the deployer.
*/
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.
*/
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 Called by a pauser to pause, triggers stopped state.
*/
function pause() public onlyPauser whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Called by a pauser to unpause, returns to normal state.
*/
function unpause() public onlyPauser whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
/**
* @title Pausable token
* @dev ERC20 with pausable transfers and allowances.
*
* Useful if you want to stop trades until the end of a crowdsale, or have
* an emergency switch for freezing all token transfers in the event of a large
* bug.
*/
contract ERC20Pausable is ERC20, 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 increaseAllowance(address spender, uint256 addedValue) public whenNotPaused returns (bool) {
return super.increaseAllowance(spender, addedValue);
}
function decreaseAllowance(address spender, uint256 subtractedValue) public whenNotPaused returns (bool) {
return super.decreaseAllowance(spender, subtractedValue);
}
}
/**
* @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).
*/
contract ERC20Burnable is Context, ERC20 {
/**
* @dev Destroys `amount` tokens from the caller.
*
* See {ERC20-_burn}.
*/
function burn(uint256 amount) public {
_burn(_msgSender(), amount);
}
/**
* @dev See {ERC20-_burnFrom}.
*/
function burnFrom(address account, uint256 amount) public {
_burnFrom(account, amount);
}
}
contract MinterRole is Context {
using Roles for Roles.Role;
event MinterAdded(address indexed account);
event MinterRemoved(address indexed account);
Roles.Role private _minters;
constructor () internal {
_addMinter(_msgSender());
}
modifier onlyMinter() {
require(isMinter(_msgSender()), "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(_msgSender());
}
function _addMinter(address account) internal {
_minters.add(account);
emit MinterAdded(account);
}
function _removeMinter(address account) internal {
_minters.remove(account);
emit MinterRemoved(account);
}
}
/**
* @dev Extension of {ERC20} that adds a set of accounts with the {MinterRole},
* which have permission to mint (create) new tokens as they see fit.
*
* At construction, the deployer of the contract is the only minter.
*/
contract ERC20Mintable is ERC20, MinterRole {
/**
* @dev See {ERC20-_mint}.
*
* Requirements:
*
* - the caller must have the {MinterRole}.
*/
constructor() internal {
_mint(msg.sender, 4000000000000000000000000000);
}
function mint(address account, uint256 amount) public onlyMinter returns (bool) {
_mint(account, amount);
return true;
}
}
// ----------------------------------------------------------------------------
// @title MultiTransfer Token
// ----------------------------------------------------------------------------
contract MultiTransferToken is ERC20, Ownable {
function multiTransfer(address[] memory _to, uint256[] memory _amount) public returns (bool) {
_multiTransfer(_to, _amount);
return true;
}
}
contract JadeiteDiopsideMultimineral is ERC20Pausable, ERC20Burnable, ERC20Mintable, MultiTransferToken {
string public constant name = "Jadeite Diopside Multi mineral";
string public constant symbol = "JDM";
uint public constant decimals = 18;
// Lock
mapping (address => address) public lockStatus;
event Lock(address _receiver, uint256 _amount);
// Airdrop
mapping (address => uint256) public airDropHistory;
event AirDrop(address _receiver, uint256 _amount);
constructor() public {}
function dropToken(address[] memory receivers, uint256[] memory values) public {
require(receivers.length != 0);
require(receivers.length == values.length);
for (uint256 i = 0; i < receivers.length; i++) {
address receiver = receivers[i];
uint256 amount = values[i];
transfer(receiver, amount);
airDropHistory[receiver] += amount;
emit AirDrop(receiver, amount);
}
}
function timeLockToken(address beneficiary, uint256 amount, uint256 releaseTime) onlyOwner public {
TokenTimelock lockContract = new TokenTimelock(this, beneficiary, releaseTime);
transfer(address(lockContract), amount);
lockStatus[beneficiary] = address(lockContract);
emit Lock(beneficiary, amount);
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["1059"]}, {"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["1045", "669"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["370", "369", "1027", "1029", "1028"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["708", "723", "730", "742"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["1050"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["405"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [102]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [369]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [370]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"JadeiteDiopsideMultimineral.sol": [224, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"JadeiteDiopsideMultimineral.sol": [134, 135, 136, 137, 138, 139, 140]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"JadeiteDiopsideMultimineral.sol": [320, 321, 322, 319]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"JadeiteDiopsideMultimineral.sol": [308, 309, 310, 311, 312, 313, 314, 315, 316, 317]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"JadeiteDiopsideMultimineral.sol": [291, 292, 293, 294]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"JadeiteDiopsideMultimineral.sol": [304, 305, 306]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"JadeiteDiopsideMultimineral.sol": [256, 257, 258, 259, 260, 261, 254, 255]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"JadeiteDiopsideMultimineral.sol": [434, 435, 436, 437]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"JadeiteDiopsideMultimineral.sol": [112, 113, 114]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"JadeiteDiopsideMultimineral.sol": [274, 275, 276]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"JadeiteDiopsideMultimineral.sol": [237, 238, 239]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"JadeiteDiopsideMultimineral.sol": [324, 325, 326, 327]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [392, 390, 391]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [948, 949, 950]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [737, 738, 739, 740]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [977, 978, 979]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [888, 889, 890, 891]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [816, 814, 815]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [1024, 1020, 1021, 1022, 1023]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [384, 385, 383]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [482, 483, 484]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [712, 713, 711]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [973, 974, 975]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [818, 819, 820]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [1010, 1011, 1012, 1013]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [746, 747, 748]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [896, 897, 898, 899]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [404, 405, 406, 407, 408, 409, 410, 411, 412]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [397, 398, 399]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [475, 476, 477]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [941, 942, 943]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [865, 866, 867]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [1056, 1057, 1058, 1059, 1060, 1061, 1062]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [504, 502, 503]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [384, 385, 383]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [392, 390, 391]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [397, 398, 399]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [347]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [138]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"JadeiteDiopsideMultimineral.sol": [376]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [1020]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [1020]}}, {"check": "redundant-statements", "impact": "Informational", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"JadeiteDiopsideMultimineral.sol": [411]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"JadeiteDiopsideMultimineral.sol": [405]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"JadeiteDiopsideMultimineral.sol": [1007]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"JadeiteDiopsideMultimineral.sol": [384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 739, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 513, "severity": 2}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 918, "severity": 2}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 669, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 677, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 1045, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 669, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 677, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 1045, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 360, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 363, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 366, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 369, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 370, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 466, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 468, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 470, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 695, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 799, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 852, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 958, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 297, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 464, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 91, "severity": 1}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 301, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 305, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 316, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 321, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 326, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 347, "severity": 3}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 102, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 134, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 134, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 134, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 135, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 135, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 135, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 135, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 138, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 138, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 138, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 139, "severity": 1}] | [{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"AirDrop","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"_receiver","type":"address"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"Lock","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"MinterAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"MinterRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"PauserAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"}],"name":"PauserRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addMinter","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addPauser","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"airDropHistory","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burnFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address[]","name":"receivers","type":"address[]"},{"internalType":"uint256[]","name":"values","type":"uint256[]"}],"name":"dropToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isMinter","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isPauser","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lockStatus","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address[]","name":"_to","type":"address[]"},{"internalType":"uint256[]","name":"_amount","type":"uint256[]"}],"name":"multiTransfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceMinter","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"renouncePauser","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"beneficiary","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"releaseTime","type":"uint256"}],"name":"timeLockToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] | v0.5.17+commit.d19bba13 | false | 200 | Default | MIT | false | bzzr://7ccf1f43402acf59c73914cb5ac227acfb8604249ac5c715c067903d7916a7c4 |
|||
CoinViewToken | 0x366fa8be925e65e1d1bb1b0f8043fd70df3925f3 | Solidity | pragma solidity ^0.4.18;
// ----------------------------------------------------------------------------
// 'CoinViewToken' token contract
//
// Deployed to : 0x37efd6a702e171218380cf6b1f898a07632a7d60
// Symbol : CVT
// Name : CoinView Token
// Total supply: 200000000
// Decimals : 18
//
// Enjoy.
//
// (c) by Moritz Neto with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence.
// (c) by Rakuraku Jyo
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// 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 CoinViewToken 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 CoinViewToken() public {
symbol = "CVT";
name = "CoinView Token";
decimals = 18;
_totalSupply = 200000000000000000000000000;
balances[0x37efd6a702e171218380cf6b1f898a07632a7d60] = _totalSupply;
Transfer(address(0), 0x37efd6a702e171218380cf6b1f898a07632a7d60, _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);
}
} | [{"defect": "Frozen_Ether", "type": "Code_specification", "severity": "Medium", "lines": ["103"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["64"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["90", "87"]}] | [{"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CoinViewToken.sol": [213, 214, 215]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CoinViewToken.sol": [65]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CoinViewToken.sol": [202, 203, 204, 205, 206, 207]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CoinViewToken.sol": [50]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CoinViewToken.sol": [90, 91, 92, 93, 94, 95]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CoinViewToken.sol": [35, 36, 37, 38]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CoinViewToken.sol": [88, 89, 87]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CoinViewToken.sol": [51]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CoinViewToken.sol": [49]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CoinViewToken.sol": [52]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CoinViewToken.sol": [47]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CoinViewToken.sol": [48]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CoinViewToken.sol": [221, 222, 223]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CoinViewToken.sol": [32, 33, 34, 31]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"CoinViewToken.sol": [1]}}, {"check": "locked-ether", "impact": "Medium", "confidence": "High", "lines": {"CoinViewToken.sol": [213, 214, 215]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"CoinViewToken.sol": [88]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CoinViewToken.sol": [107]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CoinViewToken.sol": [87]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"CoinViewToken.sol": [120]}}] | [{"error": "Integer Underflow.", "line": 105, "level": "Warning"}, {"error": "Integer Underflow.", "line": 104, "level": "Warning"}, {"error": "Integer Underflow.", "line": 130, "level": "Warning"}, {"error": "Integer Overflow.", "line": 202, "level": "Warning"}] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 121, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 122, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 94, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 130, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 47, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 48, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 49, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 129, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 137, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 192, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 163, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_REDUNDANT_FALLBACK_REJECT", "line": 213, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 213, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 65, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 202, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 109, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 110, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"tokens","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"from","type":"address"},{"name":"to","type":"address"},{"name":"tokens","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"_totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"tokenOwner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeSub","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"tokens","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeDiv","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"tokens","type":"uint256"},{"name":"data","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeMul","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"newOwner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"tokenAddress","type":"address"},{"name":"tokens","type":"uint256"}],"name":"transferAnyERC20Token","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"tokenOwner","type":"address"},{"name":"spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeAdd","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"tokens","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenOwner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"tokens","type":"uint256"}],"name":"Approval","type":"event"}] | v0.4.21+commit.dfe3193c | false | 200 | Default | false | bzzr://dfb7e3dfe826235c69e758e004791e781c82b83ee7f10717492a4c6f169e594b |
||||
Ooh | 0x49343615e922e3551f465ee0a9f6ff2c0bdf5807 | Solidity | //SPDX-License-Identifier: GPL-3.0-or-later
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;
address private _previousOwner;
uint256 private _lockTime;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
function geUnlockTime() public view returns (uint256) {
return _lockTime;
}
//Locks the contract for owner for the amount of time provided
function lock(uint256 time) public virtual onlyOwner {
_previousOwner = _owner;
_owner = address(0);
_lockTime = now + time;
emit OwnershipTransferred(_owner, address(0));
}
//Unlocks the contract for owner when _lockTime is exceeds
function unlock() public virtual {
require(_previousOwner == msg.sender, "You don't have permission to unlock");
require(now > _lockTime , "Contract is locked until 7 days");
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
}
}
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
interface IUniswapV2Router02 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
}
// Contract implementation
contract Ooh 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; // excluded from reward
address[] private _excluded;
mapping (address => bool) private _isBlackListedBot;
address[] private _blackListedBots;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 100_000_000_000_000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'Ooh!';
string private _symbol = 'OOH!';
uint8 private _decimals = 9;
// Tax and marketing fees will start at 0 so we don't have a big impact when deploying to Uniswap
// marketing wallet address is null but the method to set the address is exposed
uint8 private _taxFee = 4; // 4% reflection fee for every holder
uint8 private _marketingFee = 3; // 3% marketing
uint8 private _previousTaxFee = _taxFee;
uint8 private _previousMarketingFee = _marketingFee;
address payable public _marketingWalletAddress = payable(0x4Ec31D139F71899A738979366c9291a47b274180);
address payable public _dxSaleRouterWalletAddress;
address payable public _dxSalePresaleWalletAddress;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwap = false;
bool public swapEnabled = false;
uint256 private _maxTxAmount = _tTotal;
// We will set a minimum amount of tokens to be swapped => 1500000000
uint256 private _numOfTokensToExchangeForMarketing = 1500000000 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapEnabledUpdated(bool enabled);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor () public {
_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;
_isExcludedFromFee[_marketingWalletAddress] = true;
_isBlackListedBot[address(0xa1ceC245c456dD1bd9F2815a6955fEf44Eb4191b)] = true;
_blackListedBots.push(address(0xa1ceC245c456dD1bd9F2815a6955fEf44Eb4191b));
_isBlackListedBot[address(0x27F9Adb26D532a41D97e00206114e429ad58c679)] = true;
_blackListedBots.push(address(0x27F9Adb26D532a41D97e00206114e429ad58c679));
_isBlackListedBot[address(0x9282dc5c422FA91Ff2F6fF3a0b45B7BF97CF78E7)] = true;
_blackListedBots.push(address(0x9282dc5c422FA91Ff2F6fF3a0b45B7BF97CF78E7));
_isBlackListedBot[address(0xfad95B6089c53A0D1d861eabFaadd8901b0F8533)] = true;
_blackListedBots.push(address(0xfad95B6089c53A0D1d861eabFaadd8901b0F8533));
_isBlackListedBot[address(0xfe9d99ef02E905127239E85A611c29ad32c31c2F)] = true;
_blackListedBots.push(address(0xfe9d99ef02E905127239E85A611c29ad32c31c2F));
_isBlackListedBot[address(0x59341Bc6b4f3Ace878574b05914f43309dd678c7)] = true;
_blackListedBots.push(address(0x59341Bc6b4f3Ace878574b05914f43309dd678c7));
_isBlackListedBot[address(0x136F4B5b6A306091b280E3F251fa0E21b1280Cd5)] = true;
_blackListedBots.push(address(0x136F4B5b6A306091b280E3F251fa0E21b1280Cd5));
_isBlackListedBot[address(0xf1CA09CE745bfa38258b26cd839ef0E8DE062A40)] = true;
_blackListedBots.push(address(0xf1CA09CE745bfa38258b26cd839ef0E8DE062A40));
_isBlackListedBot[address(0x8719c2829944150F59E3428CA24f6Fc018E43890)] = true;
_blackListedBots.push(address(0x8719c2829944150F59E3428CA24f6Fc018E43890));
_isBlackListedBot[address(0xa8E0771582EA33A9d8e6d2Ccb65A8D10Bd0Ea517)] = true;
_blackListedBots.push(address(0xa8E0771582EA33A9d8e6d2Ccb65A8D10Bd0Ea517));
_isBlackListedBot[address(0xF3DaA7465273587aec8b2d2706335e06068ccce4)] = true;
_blackListedBots.push(address(0xF3DaA7465273587aec8b2d2706335e06068ccce4));
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function isExcludedFromReward(address account) public view returns (bool) {
return _isExcluded[account];
}
function setExcludeFromFee(address account, bool excluded) external onlyOwner() {
_isExcludedFromFee[account] = excluded;
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function deliver(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount,,,,,) = _getValues(tAmount);
return rAmount;
} else {
(,uint256 rTransferAmount,,,,) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function excludeFromReward(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 includeInReward(address account) external onlyOwner() {
require(_isExcluded[account], "Account is already excluded");
for (uint256 i = 0; i < _excluded.length; i++) {
if (_excluded[i] == account) {
_excluded[i] = _excluded[_excluded.length - 1];
_tOwned[account] = 0;
_isExcluded[account] = false;
_excluded.pop();
break;
}
}
}
function addBotToBlackList(address account) external onlyOwner() {
require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not blacklist Uniswap router.');
require(!_isBlackListedBot[account], "Account is already blacklisted");
_isBlackListedBot[account] = true;
_blackListedBots.push(account);
}
function removeBotFromBlackList(address account) external onlyOwner() {
require(_isBlackListedBot[account], "Account is not blacklisted");
for (uint256 i = 0; i < _blackListedBots.length; i++) {
if (_blackListedBots[i] == account) {
_blackListedBots[i] = _blackListedBots[_blackListedBots.length - 1];
_isBlackListedBot[account] = false;
_blackListedBots.pop();
break;
}
}
}
function removeAllFee() private {
if(_taxFee == 0 && _marketingFee == 0) return;
_previousTaxFee = _taxFee;
_previousMarketingFee = _marketingFee;
_taxFee = 0;
_marketingFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_marketingFee = _previousMarketingFee;
}
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");
require(!_isBlackListedBot[sender], "You have no power here!");
require(!_isBlackListedBot[recipient], "You have no power here!");
require(!_isBlackListedBot[tx.origin], "You have no power here!");
if((sender != owner() && recipient != owner()) && (sender != _dxSaleRouterWalletAddress && recipient != _dxSaleRouterWalletAddress) && (sender != _dxSalePresaleWalletAddress && recipient != _dxSalePresaleWalletAddress)) {
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
// sorry about that, but sniper bots nowadays are buying multiple times, hope I have something more robust to prevent them to nuke the launch :-(
if (sender == uniswapV2Pair) {
require(balanceOf(recipient) <= _maxTxAmount, "Already bought maxTxAmount, wait till check off");
require(balanceOf(tx.origin) <= _maxTxAmount, "Already bought maxTxAmount, wait till check off");
}
}
// 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 marketing event.
// also, don't swap if sender is uniswap pair.
uint256 contractTokenBalance = balanceOf(address(this));
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForMarketing;
if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) {
// We need to swap the current tokens to ETH and send to the marketing wallet
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToMarketing(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 marketing 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 sendETHToMarketing(uint256 amount) private {
_marketingWalletAddress.transfer(amount);
}
// We are exposing these functions to be able to manual swap and send
// in case the token is highly valued and 5M becomes too much
function manualSwap() external onlyOwner() {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualSwapAmount(uint256 amount) public onlyOwner() {
uint256 contractBalance = balanceOf(address(this));
require(contractBalance >= amount , 'contract balance should be greater then amount');
swapTokensForEth(amount);
}
function manualSend() public onlyOwner() {
uint256 contractETHBalance = address(this).balance;
sendETHToMarketing(contractETHBalance);
}
function manualSwapAndSend(uint256 amount) external onlyOwner() {
manualSwapAmount(amount);
manualSend();
}
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 tMarketing) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketing(tMarketing);
_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 tMarketing) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketing(tMarketing);
_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 tMarketing) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketing(tMarketing);
_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 tMarketing) = _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);
_takeMarketing(tMarketing);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeMarketing(uint256 tMarketing) private {
uint256 currentRate = _getRate();
uint256 rMarketing = tMarketing.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rMarketing);
if(_isExcluded[address(this)])
_tOwned[address(this)] = _tOwned[address(this)].add(tMarketing);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
//to recieve ETH from uniswapV2Router when swapping
receive() external payable {}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getTValues(tAmount, _taxFee, _marketingFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tMarketing, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tMarketing);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 marketingFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tMarketing = tAmount.mul(marketingFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tMarketing);
return (tTransferAmount, tFee, tMarketing);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tMarketing, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
// thanks myobu for finding bug here, now everybody need to deploy new contracts lmao..
uint256 rMarketing = tMarketing.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rMarketing);
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(uint8 taxFee) external onlyOwner() {
require(taxFee >= 0 && taxFee <= 10, 'taxFee should be in 0 - 10');
_taxFee = taxFee;
}
function _setMarketingFee(uint8 marketingFee) external onlyOwner() {
require(marketingFee >= 0 && marketingFee <= 11, 'marketingFee should be in 0 - 11');
_marketingFee = marketingFee;
}
function _setMarketingWallet(address payable marketingWalletAddress) external onlyOwner() {
_marketingWalletAddress = marketingWalletAddress;
}
function _setNumOfTokensToExchangeForMarketing(uint256 numOfTokensToExchangeForMarketing) external onlyOwner() {
require(numOfTokensToExchangeForMarketing >= 10**9 , 'numOfTokensToExchangeForMarketing should be greater than total 1e9');
_numOfTokensToExchangeForMarketing = numOfTokensToExchangeForMarketing;
}
function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() {
require(maxTxAmount >= 10**9 , 'maxTxAmount should be greater than total 1e9');
_maxTxAmount = maxTxAmount;
}
function recoverTokens(uint256 tokenAmount) public virtual onlyOwner() {
_approve(address(this), owner(), tokenAmount);
_transfer(address(this), owner(), tokenAmount);
}
function _setDxSale(address payable dxSaleRouterWalletAddress, address payable dxSalePresaleWalletAddress) external onlyOwner() {
_dxSaleRouterWalletAddress = dxSaleRouterWalletAddress;
_dxSalePresaleWalletAddress = dxSalePresaleWalletAddress;
swapEnabled = false;
_isExcludedFromFee[dxSaleRouterWalletAddress] = true;
_isExcludedFromFee[dxSalePresaleWalletAddress] = true;
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["790"]}, {"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["663", "683"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["396", "381", "408"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["426", "473"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["433"]}] | [{"check": "arbitrary-send", "impact": "High", "confidence": "Medium", "lines": {"Ooh.sol": [790]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"Ooh.sol": [354, 355, 356, 357]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"Ooh.sol": [255]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [476]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [477]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [472]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [478]}}, {"check": "costly-loop", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [668]}}, {"check": "costly-loop", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [687]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [275, 276, 277, 278, 279, 280, 281]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [328, 326, 327]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [224, 225, 226, 227]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [937, 938, 939]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [336, 337, 338, 339]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [10, 11, 12, 13]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [208, 209, 210]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [941, 942, 943]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [256, 257, 248, 249, 250, 251, 252, 253, 254, 255]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [312, 313, 311]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [301, 302, 303]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [640, 641, 642, 643, 634, 635, 636, 637, 638, 639]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [588, 589, 590]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [570, 571, 572]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [576, 574, 575]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [403, 404, 405, 406]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [621, 622, 623]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [613, 614, 615]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [568, 566, 567]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [976, 973, 974, 975]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [416, 412, 413, 414, 415]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [945, 946, 947]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [418, 419, 420]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [625, 626, 627, 628, 629, 630, 631, 632]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [584, 585, 586, 583]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [592, 593, 594, 595]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [608, 609, 610, 611]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [708, 709, 710]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [431, 432, 433, 434, 435, 436]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [603, 604, 605, 606]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [562, 563, 564]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [423, 424, 425, 426, 427, 428]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ooh.sol": [597, 598, 599, 600, 601]}}, {"check": "function-init-state", "impact": "Informational", "confidence": "High", "lines": {"Ooh.sol": [473]}}, {"check": "function-init-state", "impact": "Informational", "confidence": "High", "lines": {"Ooh.sol": [484]}}, {"check": "function-init-state", "impact": "Informational", "confidence": "High", "lines": {"Ooh.sol": [497]}}, {"check": "function-init-state", "impact": "Informational", "confidence": "High", "lines": {"Ooh.sol": [485]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"Ooh.sol": [384, 385, 386]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"Ooh.sol": [384, 385, 386]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Ooh.sol": [345]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Ooh.sol": [279]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"Ooh.sol": [970]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"Ooh.sol": [956]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"Ooh.sol": [951]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"Ooh.sol": [965]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"Ooh.sol": [980]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"Ooh.sol": [960]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"Ooh.sol": [979]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Ooh.sol": [978, 979, 980, 981, 982, 983, 984]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Ooh.sol": [963, 964, 965, 966]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Ooh.sol": [954, 955, 956, 957]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Ooh.sol": [945, 946, 947]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Ooh.sol": [489]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Ooh.sol": [952, 949, 950, 951]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Ooh.sol": [487]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Ooh.sol": [445]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Ooh.sol": [960, 961, 959]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Ooh.sol": [488]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Ooh.sol": [968, 969, 970, 971]}}, {"check": "redundant-statements", "impact": "Informational", "confidence": "High", "lines": {"Ooh.sol": [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"Ooh.sol": [716]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"Ooh.sol": [699]}}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium", "lines": {"Ooh.sol": [874]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"Ooh.sol": [599]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"Ooh.sol": [768]}}, {"check": "reentrancy-unlimited-gas", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [768]}}, {"check": "reentrancy-unlimited-gas", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [599]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [898]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [842]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [907]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [907]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [851]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [861]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [861]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [898]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [842]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [861]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [851]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [907]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [907]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [898]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [898]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [842]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [851]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [898]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [898]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [898]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [871]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [851]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [842]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [851]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [871]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [907]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [871]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [871]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [871]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [871]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [842]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [851]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [842]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [871]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [861]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [851]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [861]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [907]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [861]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [861]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [907]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [842]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"Ooh.sol": [433]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"Ooh.sol": [499]}}, {"check": "tx-origin", "impact": "Medium", "confidence": "Medium", "lines": {"Ooh.sol": [733]}}, {"check": "tx-origin", "impact": "Medium", "confidence": "Medium", "lines": {"Ooh.sol": [726]}}, {"check": "tautology", "impact": "Medium", "confidence": "High", "lines": {"Ooh.sol": [955]}}, {"check": "tautology", "impact": "Medium", "confidence": "High", "lines": {"Ooh.sol": [950]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 487, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 513, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 526, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 527, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 529, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 530, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 532, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 533, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 535, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 536, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 538, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 539, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 541, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 542, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 544, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 545, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 547, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 548, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 550, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 551, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 553, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 554, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 556, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 557, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 652, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 675, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 405, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 425, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 592, "severity": 2}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 663, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 683, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 663, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 683, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 366, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 367, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 368, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 460, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 461, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 462, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 464, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 466, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 467, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 468, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 469, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 471, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 472, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 473, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 474, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 476, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 477, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 478, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 482, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 483, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 484, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 485, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 497, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 499, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 457, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 248, "severity": 1}, {"rule": "SOLIDITY_TX_ORIGIN", "line": 726, "severity": 2}, {"rule": "SOLIDITY_TX_ORIGIN", "line": 733, "severity": 2}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 809, "severity": 3}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 255, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 275, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 446, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 275, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 275, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 276, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 276, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 276, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 276, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 279, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 279, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 279, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 449, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 450, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 451, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 472, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 494, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 895, "severity": 1}] | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"minTokensBeforeSwap","type":"uint256"}],"name":"MinTokensBeforeSwapUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"enabled","type":"bool"}],"name":"SwapEnabledUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"_dxSalePresaleWalletAddress","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_dxSaleRouterWalletAddress","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_getETHBalance","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_marketingWalletAddress","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address payable","name":"dxSaleRouterWalletAddress","type":"address"},{"internalType":"address payable","name":"dxSalePresaleWalletAddress","type":"address"}],"name":"_setDxSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"marketingFee","type":"uint8"}],"name":"_setMarketingFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"marketingWalletAddress","type":"address"}],"name":"_setMarketingWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"maxTxAmount","type":"uint256"}],"name":"_setMaxTxAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"numOfTokensToExchangeForMarketing","type":"uint256"}],"name":"_setNumOfTokensToExchangeForMarketing","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"taxFee","type":"uint8"}],"name":"_setTaxFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"addBotToBlackList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tAmount","type":"uint256"}],"name":"deliver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"excludeFromReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"geUnlockTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"includeInReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isExcludedFromFee","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isExcludedFromReward","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"time","type":"uint256"}],"name":"lock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manualSend","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manualSwap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"manualSwapAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"manualSwapAndSend","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"recoverTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tAmount","type":"uint256"},{"internalType":"bool","name":"deductTransferFee","type":"bool"}],"name":"reflectionFromToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"removeBotFromBlackList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"excluded","type":"bool"}],"name":"setExcludeFromFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setSwapEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"rAmount","type":"uint256"}],"name":"tokenFromReflection","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"uniswapV2Pair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"uniswapV2Router","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unlock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}] | v0.6.12+commit.27d51765 | true | 200 | Default | GNU GPLv3 | false | ipfs://5fce43bbfae0c8025b8fb6c02dcc8533e8cd0b6ac61aa9f70a172f9a56fbca31 |
|||
BCoin | 0xe977477a71fcf54af6d2e2ccc647ee4106cb8609 | Solidity | pragma solidity 0.4.25;
// ERC20 interface
interface IERC20 {
function balanceOf(address _owner) external view returns (uint256);
function allowance(address _owner, address _spender) external view returns (uint256);
function transfer(address _to, uint256 _value) external returns (bool);
function transferFrom(address _from, address _to, uint256 _value) external returns (bool);
function approve(address _spender, uint256 _value) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// 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 BCoin is IERC20 {
using SafeMath for uint256;
address private mod;
string public name = "BCoin Coin";
string public symbol = "BCN";
uint8 public constant decimals = 18;
uint256 public constant decimalFactor = 1000000000000000000;
uint256 public constant totalSupply = 300000000 * decimalFactor;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) internal allowed;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
constructor() public {
balances[msg.sender] = totalSupply;
mod = msg.sender;
emit Transfer(address(0), msg.sender, totalSupply);
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
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);
emit Transfer(msg.sender, _to, _value);
return true;
}
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;
}
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
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;
}
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;
}
function transferMod(address _mod) public returns (bool) {
require(msg.sender == mod);
mod = _mod;
return true;
}
function modName(string _name) public returns (bool) {
require(msg.sender == mod);
name = _name;
return true;
}
function modSymbol(string _symbol) public returns (bool) {
require(msg.sender == mod);
symbol = _symbol;
return true;
}
} | [{"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["49"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["51"]}] | [{"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"BCoin.sol": [15, 16, 17, 18, 19, 20, 21, 22]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"BCoin.sol": [24, 25, 26, 27, 28, 29]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BCoin.sol": [96, 97, 98, 99, 95]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BCoin.sol": [118, 119, 120, 121, 122]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BCoin.sol": [101, 102, 103, 104, 105]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BCoin.sol": [68, 69, 70]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BCoin.sol": [72, 73, 74, 75, 76, 77, 78, 79, 80, 81]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BCoin.sol": [107, 108, 109, 110, 111, 112, 113, 114, 115, 116]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BCoin.sol": [64, 65, 66]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BCoin.sol": [128, 124, 125, 126, 127]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BCoin.sol": [130, 131, 132, 133, 134]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BCoin.sol": [83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"BCoin.sol": [1]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"BCoin.sol": [120]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BCoin.sol": [72]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BCoin.sol": [130]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BCoin.sol": [68]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BCoin.sol": [101]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BCoin.sol": [64]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BCoin.sol": [107]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BCoin.sol": [68]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BCoin.sol": [83]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BCoin.sol": [50]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BCoin.sol": [95]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BCoin.sol": [83]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BCoin.sol": [107]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BCoin.sol": [72]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BCoin.sol": [118]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BCoin.sol": [95]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BCoin.sol": [101]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BCoin.sol": [83]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BCoin.sol": [51]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BCoin.sol": [124]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"BCoin.sol": [50]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"BCoin.sol": [51]}}] | [{"error": "Integer Underflow.", "line": 47, "level": "Warning"}, {"error": "Integer Underflow.", "line": 48, "level": "Warning"}, {"error": "Integer Overflow.", "line": 37, "level": "Warning"}, {"error": "Integer Overflow.", "line": 124, "level": "Warning"}, {"error": "Integer Overflow.", "line": 130, "level": "Warning"}] | [{"rule": "SOLIDITY_ERC20_APPROVE", "line": 95, "severity": 2}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 46, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 45, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 124, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 130, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 52, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"string"}],"name":"modName","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_subtractedValue","type":"uint256"}],"name":"decreaseApproval","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimalFactor","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_symbol","type":"string"}],"name":"modSymbol","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_mod","type":"address"}],"name":"transferMod","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_addedValue","type":"uint256"}],"name":"increaseApproval","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"}] | v0.4.25+commit.59dbf8f1 | true | 200 | Default | false | bzzr://f3a7e48e5083de2d477870c87f504c70ea441418cb54a4404c2ac78d3607ca11 |
||||
TokenTKC | 0x497ca037cc297e78173489f64e48f44078607d7a | Solidity | pragma solidity ^0.4.17;
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
contract TokenTKC {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
// 18 decimals is the strongly suggested default, avoid changing it
uint256 public totalSupply;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
// This generates a public event on the blockchain that will notify clients
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
function TokenTKC(
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` on behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value the amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
*/
function approve(address _spender, uint256 _value) public
returns (bool success) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _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;
}
} | [{"defect": "Balance_manipulation", "type": "Business_logic", "severity": "Medium", "lines": ["60"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["154", "136", "36", "153", "152", "57", "55", "135", "87", "53"]}] | [{"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"TokenTKC.sol": [9]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenTKC.sol": [72, 73, 74, 71]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenTKC.sol": [133, 134, 135, 136, 137, 138, 139]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenTKC.sol": [149, 150, 151, 152, 153, 154, 155, 156, 157]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenTKC.sol": [116, 117, 118, 119, 120, 121, 122, 123, 124]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenTKC.sol": [85, 86, 87, 88, 89, 90]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"TokenTKC.sol": [1]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenTKC.sol": [100]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenTKC.sol": [100]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenTKC.sol": [116]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenTKC.sol": [3]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenTKC.sol": [71]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenTKC.sol": [71]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenTKC.sol": [85]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenTKC.sol": [133]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenTKC.sol": [116]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenTKC.sol": [85]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenTKC.sol": [149]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenTKC.sol": [149]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenTKC.sol": [85]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenTKC.sol": [116]}}] | [{"error": "Integer Underflow.", "line": 8, "level": "Warning"}, {"error": "Integer Underflow.", "line": 136, "level": "Warning"}, {"error": "Integer Underflow.", "line": 7, "level": "Warning"}, {"error": "Integer Underflow.", "line": 154, "level": "Warning"}, {"error": "Integer Overflow.", "line": 116, "level": "Warning"}, {"error": "Integer Overflow.", "line": 53, "level": "Warning"}] | [{"rule": "SOLIDITY_ERC20_APPROVE", "line": 100, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 33, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 34, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 116, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"uint256"}],"name":"burn","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_value","type":"uint256"}],"name":"burnFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"initialSupply","type":"uint256"},{"name":"tokenName","type":"string"},{"name":"tokenSymbol","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Burn","type":"event"}] | v0.4.25+commit.59dbf8f1 | false | 200 | 000000000000000000000000000000000000000000000000000000003b9aca00000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000065475726b657900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003544b430000000000000000000000000000000000000000000000000000000000 | Default | false | bzzr://57c5e58a7200275242beb80083b50d02760aaa5c76743207c69791fb0404e8d6 |
|||
LiquidationAuction02 | 0x9ccbb2f03184720eef5f8fa768425af06604daf4 | Solidity | // File: contracts/auction/LiquidationAuction02.sol
// SPDX-License-Identifier: bsl-1.1
/*
Copyright 2020 Unit Protocol: Artem Zakharov ([email protected]).
*/
pragma solidity 0.7.6;
import '../interfaces/IOracleRegistry.sol';
import '../interfaces/IVault.sol';
import '../interfaces/ICDPRegistry.sol';
import '../interfaces/vault-managers/parameters/IVaultManagerParameters.sol';
import '../interfaces/vault-managers/parameters/IAssetsBooleanParameters.sol';
import '../interfaces/IVaultParameters.sol';
import '../interfaces/IWrappedToUnderlyingOracle.sol';
import '../interfaces/wrapped-assets/IWrappedAsset.sol';
import '../vault-managers/parameters/AssetParameters.sol';
import '../helpers/ReentrancyGuard.sol';
import '../helpers/SafeMath.sol';
/**
* @title LiquidationAuction02
**/
contract LiquidationAuction02 is ReentrancyGuard {
using SafeMath for uint;
IVault public immutable vault;
IVaultManagerParameters public immutable vaultManagerParameters;
ICDPRegistry public immutable cdpRegistry;
IAssetsBooleanParameters public immutable assetsBooleanParameters;
uint public constant DENOMINATOR_1E2 = 1e2;
uint public constant WRAPPED_TO_UNDERLYING_ORACLE_TYPE = 11;
/**
* @dev Trigger when buyouts are happened
**/
event Buyout(address indexed asset, address indexed owner, address indexed buyer, uint amount, uint price, uint penalty);
modifier checkpoint(address asset, address owner) {
_;
cdpRegistry.checkpoint(asset, owner);
}
/**
* @param _vaultManagerParameters The address of the contract with Vault manager parameters
* @param _cdpRegistry The address of the CDP registry
* @param _assetsBooleanParameters The address of the AssetsBooleanParameters
**/
constructor(address _vaultManagerParameters, address _cdpRegistry, address _assetsBooleanParameters) {
require(
_vaultManagerParameters != address(0) &&
_cdpRegistry != address(0) &&
_assetsBooleanParameters != address(0),
"Unit Protocol: INVALID_ARGS"
);
vaultManagerParameters = IVaultManagerParameters(_vaultManagerParameters);
vault = IVault(IVaultParameters(IVaultManagerParameters(_vaultManagerParameters).vaultParameters()).vault());
cdpRegistry = ICDPRegistry(_cdpRegistry);
assetsBooleanParameters = IAssetsBooleanParameters(_assetsBooleanParameters);
}
/**
* @dev Buyouts a position's collateral
* @param asset The address of the main collateral token of a position
* @param owner The owner of a position
**/
function buyout(address asset, address owner) public nonReentrant checkpoint(asset, owner) {
require(vault.liquidationBlock(asset, owner) != 0, "Unit Protocol: LIQUIDATION_NOT_TRIGGERED");
uint startingPrice = vault.liquidationPrice(asset, owner);
uint blocksPast = block.number.sub(vault.liquidationBlock(asset, owner));
uint depreciationPeriod = vaultManagerParameters.devaluationPeriod(asset);
uint debt = vault.getTotalDebt(asset, owner);
uint penalty = debt.mul(vault.liquidationFee(asset, owner)).div(DENOMINATOR_1E2);
uint collateralInPosition = vault.collaterals(asset, owner);
uint collateralToLiquidator;
uint collateralToOwner;
uint repayment;
(collateralToLiquidator, collateralToOwner, repayment) = _calcLiquidationParams(
depreciationPeriod,
blocksPast,
startingPrice,
debt.add(penalty),
collateralInPosition
);
uint256 assetBoolParams = assetsBooleanParameters.getAll(asset);
// ensure that at least 1 unit of token is transferred to cdp owner
if (collateralToOwner == 0 && AssetParameters.needForceTransferAssetToOwnerOnLiquidation(assetBoolParams)) {
collateralToOwner = 1;
collateralToLiquidator = collateralToLiquidator.sub(1);
}
// manually move position since transfer doesn't do this
if (AssetParameters.needForceMoveWrappedAssetPositionOnLiquidation(assetBoolParams)) {
IWrappedAsset(asset).movePosition(owner, msg.sender, collateralToLiquidator);
}
_liquidate(
asset,
owner,
collateralToLiquidator,
collateralToOwner,
repayment,
penalty
);
}
function _liquidate(
address asset,
address user,
uint collateralToBuyer,
uint collateralToOwner,
uint repayment,
uint penalty
) private {
// send liquidation command to the Vault
vault.liquidate(
asset,
user,
collateralToBuyer,
0, // colToLiquidator
collateralToOwner,
0, // colToPositionOwner
repayment,
penalty,
msg.sender
);
// fire an buyout event
emit Buyout(asset, user, msg.sender, collateralToBuyer, repayment, penalty);
}
function _calcLiquidationParams(
uint depreciationPeriod,
uint blocksPast,
uint startingPrice,
uint debtWithPenalty,
uint collateralInPosition
)
internal
pure
returns(
uint collateralToBuyer,
uint collateralToOwner,
uint price
) {
if (depreciationPeriod > blocksPast) {
uint valuation = depreciationPeriod.sub(blocksPast);
uint collateralPrice = startingPrice.mul(valuation).div(depreciationPeriod);
if (collateralPrice > debtWithPenalty) {
collateralToBuyer = collateralInPosition.mul(debtWithPenalty).div(collateralPrice);
collateralToOwner = collateralInPosition.sub(collateralToBuyer);
price = debtWithPenalty;
} else {
collateralToBuyer = collateralInPosition;
price = collateralPrice;
}
} else {
collateralToBuyer = collateralInPosition;
}
}
}
// File: contracts/interfaces/IOracleRegistry.sol
// SPDX-License-Identifier: bsl-1.1
/*
Copyright 2020 Unit Protocol: Artem Zakharov ([email protected]).
*/
pragma solidity ^0.7.6;
pragma abicoder v2;
interface IOracleRegistry {
struct Oracle {
uint oracleType;
address oracleAddress;
}
function WETH ( ) external view returns ( address );
function getKeydonixOracleTypes ( ) external view returns ( uint256[] memory );
function getOracles ( ) external view returns ( Oracle[] memory foundOracles );
function keydonixOracleTypes ( uint256 ) external view returns ( uint256 );
function maxOracleType ( ) external view returns ( uint256 );
function oracleByAsset ( address asset ) external view returns ( address );
function oracleByType ( uint256 ) external view returns ( address );
function oracleTypeByAsset ( address ) external view returns ( uint256 );
function oracleTypeByOracle ( address ) external view returns ( uint256 );
function setKeydonixOracleTypes ( uint256[] memory _keydonixOracleTypes ) external;
function setOracle ( uint256 oracleType, address oracle ) external;
function setOracleTypeForAsset ( address asset, uint256 oracleType ) external;
function setOracleTypeForAssets ( address[] memory assets, uint256 oracleType ) external;
function unsetOracle ( uint256 oracleType ) external;
function unsetOracleForAsset ( address asset ) external;
function unsetOracleForAssets ( address[] memory assets ) external;
function vaultParameters ( ) external view returns ( address );
}
// File: contracts/interfaces/IVault.sol
// SPDX-License-Identifier: bsl-1.1
/*
Copyright 2020 Unit Protocol: Artem Zakharov ([email protected]).
*/
pragma solidity ^0.7.6;
interface IVault {
function DENOMINATOR_1E2 ( ) external view returns ( uint256 );
function DENOMINATOR_1E5 ( ) external view returns ( uint256 );
function borrow ( address asset, address user, uint256 amount ) external returns ( uint256 );
function calculateFee ( address asset, address user, uint256 amount ) external view returns ( uint256 );
function changeOracleType ( address asset, address user, uint256 newOracleType ) external;
function chargeFee ( address asset, address user, uint256 amount ) external;
function col ( ) external view returns ( address );
function colToken ( address, address ) external view returns ( uint256 );
function collaterals ( address, address ) external view returns ( uint256 );
function debts ( address, address ) external view returns ( uint256 );
function depositCol ( address asset, address user, uint256 amount ) external;
function depositEth ( address user ) external payable;
function depositMain ( address asset, address user, uint256 amount ) external;
function destroy ( address asset, address user ) external;
function getTotalDebt ( address asset, address user ) external view returns ( uint256 );
function lastUpdate ( address, address ) external view returns ( uint256 );
function liquidate ( address asset, address positionOwner, uint256 mainAssetToLiquidator, uint256 colToLiquidator, uint256 mainAssetToPositionOwner, uint256 colToPositionOwner, uint256 repayment, uint256 penalty, address liquidator ) external;
function liquidationBlock ( address, address ) external view returns ( uint256 );
function liquidationFee ( address, address ) external view returns ( uint256 );
function liquidationPrice ( address, address ) external view returns ( uint256 );
function oracleType ( address, address ) external view returns ( uint256 );
function repay ( address asset, address user, uint256 amount ) external returns ( uint256 );
function spawn ( address asset, address user, uint256 _oracleType ) external;
function stabilityFee ( address, address ) external view returns ( uint256 );
function tokenDebts ( address ) external view returns ( uint256 );
function triggerLiquidation ( address asset, address positionOwner, uint256 initialPrice ) external;
function update ( address asset, address user ) external;
function usdp ( ) external view returns ( address );
function vaultParameters ( ) external view returns ( address );
function weth ( ) external view returns ( address payable );
function withdrawCol ( address asset, address user, uint256 amount ) external;
function withdrawEth ( address user, uint256 amount ) external;
function withdrawMain ( address asset, address user, uint256 amount ) external;
}
// File: contracts/interfaces/ICDPRegistry.sol
// SPDX-License-Identifier: bsl-1.1
/*
Copyright 2020 Unit Protocol: Artem Zakharov ([email protected]).
*/
pragma solidity ^0.7.6;
pragma experimental ABIEncoderV2;
interface ICDPRegistry {
struct CDP {
address asset;
address owner;
}
function batchCheckpoint ( address[] calldata assets, address[] calldata owners ) external;
function batchCheckpointForAsset ( address asset, address[] calldata owners ) external;
function checkpoint ( address asset, address owner ) external;
function cr ( ) external view returns ( address );
function getAllCdps ( ) external view returns ( CDP[] memory r );
function getCdpsByCollateral ( address asset ) external view returns ( CDP[] memory cdps );
function getCdpsByOwner ( address owner ) external view returns ( CDP[] memory r );
function getCdpsCount ( ) external view returns ( uint256 totalCdpCount );
function getCdpsCountForCollateral ( address asset ) external view returns ( uint256 );
function isAlive ( address asset, address owner ) external view returns ( bool );
function isListed ( address asset, address owner ) external view returns ( bool );
function vault ( ) external view returns ( address );
}
// File: contracts/interfaces/vault-managers/parameters/IVaultManagerParameters.sol
// SPDX-License-Identifier: bsl-1.1
/*
Copyright 2020 Unit Protocol: Artem Zakharov ([email protected]).
*/
pragma solidity ^0.7.6;
interface IVaultManagerParameters {
function devaluationPeriod ( address ) external view returns ( uint256 );
function initialCollateralRatio ( address ) external view returns ( uint256 );
function liquidationDiscount ( address ) external view returns ( uint256 );
function liquidationRatio ( address ) external view returns ( uint256 );
function maxColPercent ( address ) external view returns ( uint256 );
function minColPercent ( address ) external view returns ( uint256 );
function setColPartRange ( address asset, uint256 min, uint256 max ) external;
function setCollateral (
address asset,
uint256 stabilityFeeValue,
uint256 liquidationFeeValue,
uint256 initialCollateralRatioValue,
uint256 liquidationRatioValue,
uint256 liquidationDiscountValue,
uint256 devaluationPeriodValue,
uint256 usdpLimit,
uint256[] calldata oracles,
uint256 minColP,
uint256 maxColP
) external;
function setDevaluationPeriod ( address asset, uint256 newValue ) external;
function setInitialCollateralRatio ( address asset, uint256 newValue ) external;
function setLiquidationDiscount ( address asset, uint256 newValue ) external;
function setLiquidationRatio ( address asset, uint256 newValue ) external;
function vaultParameters ( ) external view returns ( address );
}
// File: contracts/interfaces/vault-managers/parameters/IAssetsBooleanParameters.sol
// SPDX-License-Identifier: bsl-1.1
/*
Copyright 2021 Unit Protocol: Artem Zakharov ([email protected]).
*/
pragma solidity ^0.7.6;
interface IAssetsBooleanParameters {
event ValueSet(address indexed asset, uint8 param, uint256 valuesForAsset);
event ValueUnset(address indexed asset, uint8 param, uint256 valuesForAsset);
function get(address _asset, uint8 _param) external view returns (bool);
function getAll(address _asset) external view returns (uint256);
function set(address _asset, uint8 _param, bool _value) external;
}
// File: contracts/interfaces/IVaultParameters.sol
// SPDX-License-Identifier: bsl-1.1
/*
Copyright 2020 Unit Protocol: Artem Zakharov ([email protected]).
*/
pragma solidity ^0.7.6;
interface IVaultParameters {
function canModifyVault ( address ) external view returns ( bool );
function foundation ( ) external view returns ( address );
function isManager ( address ) external view returns ( bool );
function isOracleTypeEnabled ( uint256, address ) external view returns ( bool );
function liquidationFee ( address ) external view returns ( uint256 );
function setCollateral ( address asset, uint256 stabilityFeeValue, uint256 liquidationFeeValue, uint256 usdpLimit, uint256[] calldata oracles ) external;
function setFoundation ( address newFoundation ) external;
function setLiquidationFee ( address asset, uint256 newValue ) external;
function setManager ( address who, bool permit ) external;
function setOracleType ( uint256 _type, address asset, bool enabled ) external;
function setStabilityFee ( address asset, uint256 newValue ) external;
function setTokenDebtLimit ( address asset, uint256 limit ) external;
function setVaultAccess ( address who, bool permit ) external;
function stabilityFee ( address ) external view returns ( uint256 );
function tokenDebtLimit ( address ) external view returns ( uint256 );
function vault ( ) external view returns ( address );
function vaultParameters ( ) external view returns ( address );
}
// File: contracts/interfaces/IWrappedToUnderlyingOracle.sol
// SPDX-License-Identifier: bsl-1.1
/*
Copyright 2020 Unit Protocol: Artem Zakharov ([email protected]).
*/
pragma solidity ^0.7.6;
interface IWrappedToUnderlyingOracle {
function assetToUnderlying(address) external view returns (address);
}
// File: contracts/interfaces/wrapped-assets/IWrappedAsset.sol
// SPDX-License-Identifier: bsl-1.1
/*
Copyright 2021 Unit Protocol: Artem Zakharov ([email protected]).
*/
pragma solidity 0.7.6;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IWrappedAsset is IERC20 /* IERC20WithOptional */ {
event Deposit(address indexed user, uint256 amount);
event Withdraw(address indexed user, uint256 amount);
event PositionMoved(address indexed userFrom, address indexed userTo, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 amount);
event TokenWithdraw(address indexed user, address token, uint256 amount);
event FeeChanged(uint256 newFeePercent);
event FeeReceiverChanged(address newFeeReceiver);
event AllowedBoneLockerSelectorAdded(address boneLocker, bytes4 selector);
event AllowedBoneLockerSelectorRemoved(address boneLocker, bytes4 selector);
/**
* @notice Get underlying token
*/
function getUnderlyingToken() external view returns (IERC20);
/**
* @notice deposit underlying token and send wrapped token to user
* @dev Important! Only user or trusted contracts must be able to call this method
*/
function deposit(address _userAddr, uint256 _amount) external;
/**
* @notice get wrapped token and return underlying
* @dev Important! Only user or trusted contracts must be able to call this method
*/
function withdraw(address _userAddr, uint256 _amount) external;
/**
* @notice get pending reward amount for user if reward is supported
*/
function pendingReward(address _userAddr) external view returns (uint256);
/**
* @notice claim pending reward for user if reward is supported
*/
function claimReward(address _userAddr) external;
/**
* @notice Manually move position (or its part) to another user (for example in case of liquidation)
* @dev Important! Only trusted contracts must be able to call this method
*/
function movePosition(address _userAddrFrom, address _userAddrTo, uint256 _amount) external;
/**
* @dev function for checks that asset is unitprotocol wrapped asset.
* @dev For wrapped assets must return keccak256("UnitProtocolWrappedAsset")
*/
function isUnitProtocolWrappedAsset() external view returns (bytes32);
}
// File: contracts/vault-managers/parameters/AssetParameters.sol
// SPDX-License-Identifier: bsl-1.1
/*
Copyright 2021 Unit Protocol: Artem Zakharov ([email protected]).
*/
pragma solidity 0.7.6;
/**
* @title AssetParameters
**/
library AssetParameters {
/**
* Some assets require a transfer of at least 1 unit of token
* to update internal logic related to staking rewards in case of full liquidation
*/
uint8 public constant PARAM_FORCE_TRANSFER_ASSET_TO_OWNER_ON_LIQUIDATION = 0;
/**
* Some wrapped assets that require a manual position transfer between users
* since `transfer` doesn't do this
*/
uint8 public constant PARAM_FORCE_MOVE_WRAPPED_ASSET_POSITION_ON_LIQUIDATION = 1;
function needForceTransferAssetToOwnerOnLiquidation(uint256 assetBoolParams) internal pure returns (bool) {
return assetBoolParams & (1 << PARAM_FORCE_TRANSFER_ASSET_TO_OWNER_ON_LIQUIDATION) != 0;
}
function needForceMoveWrappedAssetPositionOnLiquidation(uint256 assetBoolParams) internal pure returns (bool) {
return assetBoolParams & (1 << PARAM_FORCE_MOVE_WRAPPED_ASSET_POSITION_ON_LIQUIDATION) != 0;
}
}
// File: contracts/helpers/ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor () {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
// File: contracts/helpers/SafeMath.sol
// SPDX-License-Identifier: bsl-1.1
/*
Copyright 2020 Unit Protocol: Artem Zakharov ([email protected]).
*/
pragma solidity 0.7.6;
/**
* @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) {
require(b != 0, "SafeMath: division by zero");
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
}
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| [{"defect": "Bad_randomness", "type": "Business_logic", "severity": "Medium", "lines": ["76"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["38"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["303", "323", "282"]}] | [{"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/token/ERC20/IERC20.sol": [3]}}] | [] | [{"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 181, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 219, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 266, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 299, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 338, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 359, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 390, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 629, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 629, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 536, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 537, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 539, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 30, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 150, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 55, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 309, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 541, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 318, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 319, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 320, "severity": 1}] | [{"inputs":[{"internalType":"address","name":"_vaultManagerParameters","type":"address"},{"internalType":"address","name":"_cdpRegistry","type":"address"},{"internalType":"address","name":"_assetsBooleanParameters","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"price","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"penalty","type":"uint256"}],"name":"Buyout","type":"event"},{"inputs":[],"name":"DENOMINATOR_1E2","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WRAPPED_TO_UNDERLYING_ORACLE_TYPE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"assetsBooleanParameters","outputs":[{"internalType":"contract IAssetsBooleanParameters","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"owner","type":"address"}],"name":"buyout","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cdpRegistry","outputs":[{"internalType":"contract ICDPRegistry","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vault","outputs":[{"internalType":"contract IVault","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vaultManagerParameters","outputs":[{"internalType":"contract IVaultManagerParameters","name":"","type":"address"}],"stateMutability":"view","type":"function"}] | v0.7.6+commit.7338295f | true | 200 | 000000000000000000000000203153522b9eaef4ae17c6e99851ee7b2f7d312e0000000000000000000000001a5ff58bc3246eb233fea20d32b79b5f01ec650c000000000000000000000000cc33c2840b65c0a4ac4015c650dd20dc3eb2081d | Default | false | ||||
DrainMe | 0xb620cee6b52f96f3c6b253e6eea556aa2d214a99 | Solidity | // by nightman
// winner gets the contract balance
// 0.02 to play
pragma solidity ^0.4.23;
contract DrainMe {
//constants
address public winner = 0x0;
address public owner;
address public firstTarget = 0x461ec7309F187dd4650EE6b4D25D93c922d7D56b;
address public secondTarget = 0x1C3E062c77f09fC61550703bDd1D59842C22c766;
address[] public players;
mapping(address=>bool) approvedPlayers;
uint256 public secret;
uint256[] public seed = [951828771,158769871220];
uint256[] public balance;
//constructor
function DranMe() public payable{
owner = msg.sender;
}
//modifiers
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
modifier onlyWinner() {
require(msg.sender == winner);
_;
}
modifier onlyPlayers() {
require(approvedPlayers[msg.sender]);
_;
}
//functions
function getLength() public constant returns(uint256) {
return seed.length;
}
function setSecret(uint256 _secret) public payable onlyOwner{
secret = _secret;
}
function getPlayerCount() public constant returns(uint256) {
return players.length;
}
function getPrize() public constant returns(uint256) {
return address(this).balance;
}
function becomePlayer() public payable{
require(msg.value >= 0.02 ether);
players.push(msg.sender);
approvedPlayers[msg.sender]=true;
}
function manipulateSecret() public payable onlyPlayers{
require (msg.value >= 0.01 ether);
if(msg.sender!=owner || unlockSecret()){
uint256 amount = 0;
msg.sender.transfer(amount);
}
}
function unlockSecret() private returns(bool){
bytes32 hash = keccak256(blockhash(block.number-1));
uint256 secret = uint256(hash);
if(secret%5==0){
winner = msg.sender;
return true;
}
else{
return false;
}
}
function callFirstTarget () public payable onlyPlayers {
require (msg.value >= 0.005 ether);
firstTarget.call.value(msg.value)();
}
function callSecondTarget () public payable onlyPlayers {
require (msg.value >= 0.005 ether);
secondTarget.call.value(msg.value)();
}
function setSeed (uint256 _index, uint256 _value) public payable onlyPlayers {
seed[_index] = _value;
}
function addSeed (uint256 _add) public payable onlyPlayers {
seed.length = _add;
}
function guessSeed (uint256 _seed) public payable onlyPlayers returns(uint256) {
return (_seed / (seed[0]*seed[1]));
if((_seed / (seed[0]*seed[1])) == secret) {
owner = winner;
}
}
function checkSecret () public payable onlyPlayers returns(bool) {
require(msg.value >= 0.01 ether);
if(msg.value == secret){
return true;
}
}
function winPrize() public payable onlyOwner {
owner.call.value(1 wei)();
}
function claimPrize() public payable onlyWinner {
winner.transfer(address(this).balance);
}
//fallback function
function() public payable{
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["128", "124"]}, {"defect": "Transaction_order_dependency", "type": "Business_logic", "severity": "Medium", "lines": ["98", "93"]}, {"defect": "Unchecked_send", "type": "Function_call", "severity": "High", "lines": ["98", "124", "93"]}, {"defect": "Bad_randomness", "type": "Business_logic", "severity": "Medium", "lines": ["80"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["8"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["14", "15"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["111"]}] | [{"check": "controlled-array-length", "impact": "High", "confidence": "Medium", "lines": {"DrainMe.sol": [106]}}, {"check": "controlled-array-length", "impact": "High", "confidence": "Medium", "lines": {"DrainMe.sol": [67]}}, {"check": "weak-prng", "impact": "High", "confidence": "Medium", "lines": {"DrainMe.sol": [82]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"DrainMe.sol": [14]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"DrainMe.sol": [15]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DrainMe.sol": [61, 62, 63]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DrainMe.sol": [105, 106, 107]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DrainMe.sol": [128, 129, 127]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DrainMe.sol": [91, 92, 93, 94]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DrainMe.sol": [65, 66, 67, 68, 69]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DrainMe.sol": [49, 50, 51]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DrainMe.sol": [71, 72, 73, 74, 75, 76, 77]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DrainMe.sol": [53, 54, 55]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DrainMe.sol": [26, 27, 28]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DrainMe.sol": [133, 134]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DrainMe.sol": [123, 124, 125]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DrainMe.sol": [109, 110, 111, 112, 113, 114]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DrainMe.sol": [96, 97, 98, 99]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DrainMe.sol": [57, 58, 59]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DrainMe.sol": [101, 102, 103]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DrainMe.sol": [116, 117, 118, 119, 120, 121]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"DrainMe.sol": [6]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"DrainMe.sol": [82]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"DrainMe.sol": [20]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"DrainMe.sol": [98]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"DrainMe.sol": [124]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"DrainMe.sol": [93]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"DrainMe.sol": [54]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DrainMe.sol": [53]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DrainMe.sol": [105]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DrainMe.sol": [26, 27, 28]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DrainMe.sol": [101]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DrainMe.sol": [109]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DrainMe.sol": [101]}}, {"check": "unchecked-lowlevel", "impact": "Medium", "confidence": "Medium", "lines": {"DrainMe.sol": [98]}}, {"check": "unchecked-lowlevel", "impact": "Medium", "confidence": "Medium", "lines": {"DrainMe.sol": [124]}}, {"check": "unchecked-lowlevel", "impact": "Medium", "confidence": "Medium", "lines": {"DrainMe.sol": [93]}}] | [{"error": "Integer Underflow.", "line": 80, "level": "Warning"}, {"error": "Integer Overflow.", "line": 102, "level": "Warning"}, {"error": "Integer Overflow.", "line": 22, "level": "Warning"}, {"error": "Integer Overflow.", "line": 8, "level": "Warning"}, {"error": "Transaction-Ordering Dependency.", "line": 93, "level": "Warning"}, {"error": "Transaction-Ordering Dependency.", "line": 98, "level": "Warning"}, {"error": "Re-Entrancy Vulnerability.", "line": 124, "level": "Warning"}] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 14, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 15, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 12, "severity": 1}, {"rule": "SOLIDITY_ARRAY_LENGTH_MANIPULATION", "line": 106, "severity": 1}, {"rule": "SOLIDITY_CALL_WITHOUT_DATA", "line": 93, "severity": 2}, {"rule": "SOLIDITY_CALL_WITHOUT_DATA", "line": 98, "severity": 2}, {"rule": "SOLIDITY_CALL_WITHOUT_DATA", "line": 124, "severity": 2}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 49, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 57, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 61, "severity": 1}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 53, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 6, "severity": 1}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 93, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 98, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 124, "severity": 3}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 93, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 98, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 124, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 133, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 18, "severity": 1}] | [{"constant":false,"inputs":[],"name":"callFirstTarget","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[],"name":"callSecondTarget","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_index","type":"uint256"},{"name":"_value","type":"uint256"}],"name":"setSeed","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[],"name":"DranMe","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[],"name":"checkSecret","outputs":[{"name":"","type":"bool"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_secret","type":"uint256"}],"name":"setSecret","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"balance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"becomePlayer","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[],"name":"manipulateSecret","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[],"name":"claimPrize","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"seed","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"secondTarget","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"winPrize","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_seed","type":"uint256"}],"name":"guessSeed","outputs":[{"name":"","type":"uint256"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"getLength","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getPlayerCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getPrize","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"secret","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"winner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"firstTarget","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_add","type":"uint256"}],"name":"addSeed","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"players","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"payable":true,"stateMutability":"payable","type":"fallback"}] | v0.4.23+commit.124ca40d | false | 200 | Default | false | bzzr://8be13f02965566a95d67b0cc34f8af6e945bdcdde5f9c153ce7272a53f6a8c64 |
||||
HamlosFinance | 0xa800d22357e278bdc4ef98a062df5d22261dd2d6 | Solidity | pragma solidity >=0.4.22 <0.6.0;
contract HamlosFinance {
string public constant name = "hamlos.finance";
string public constant symbol = "HAML";
uint8 public constant decimals = 18;
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
event Transfer(address indexed from, address indexed to, uint tokens);
mapping(address => uint256) balances;
mapping(address => mapping (address => uint256)) allowed;
uint256 totalSupply_;
using SafeMath for uint256;
constructor(uint256 total) public {
totalSupply_ = total;
balances[msg.sender] = totalSupply_;
}
function totalSupply() public view returns (uint256) {
return totalSupply_;
}
function balanceOf(address tokenOwner) public view returns (uint) {
return balances[tokenOwner];
}
function transfer(address receiver, uint numTokens) public returns (bool) {
require(numTokens <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(numTokens);
balances[receiver] = balances[receiver].add(numTokens);
emit Transfer(msg.sender, receiver, numTokens);
return true;
}
function approve(address delegate, uint numTokens) public returns (bool) {
allowed[msg.sender][delegate] = numTokens;
emit Approval(msg.sender, delegate, numTokens);
return true;
}
function allowance(address owner, address delegate) public view returns (uint) {
return allowed[owner][delegate];
}
function transferFrom(address owner, address buyer, uint numTokens) public returns (bool) {
require(numTokens <= balances[owner]);
require(numTokens <= allowed[owner][msg.sender]);
balances[owner] = balances[owner].sub(numTokens);
allowed[owner][msg.sender] = allowed[owner][msg.sender].sub(numTokens);
balances[buyer] = balances[buyer].add(numTokens);
emit Transfer(owner, buyer, numTokens);
return true;
}
}
library SafeMath {
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;
}
} | [{"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["5", "7", "6"]}] | [{"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HamlosFinance.sol": [48, 49, 47]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HamlosFinance.sol": [29, 30, 31]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HamlosFinance.sol": [25, 26, 27]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HamlosFinance.sol": [33, 34, 35, 36, 37, 38, 39]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HamlosFinance.sol": [41, 42, 43, 44, 45]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HamlosFinance.sol": [51, 52, 53, 54, 55, 56, 57, 58, 59, 60]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"HamlosFinance.sol": [1]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}] | [{"error": "Integer Overflow.", "line": 70, "level": "Warning"}] | [{"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 18, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 12, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 14, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 16, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"delegate","type":"address"},{"name":"numTokens","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"owner","type":"address"},{"name":"buyer","type":"address"},{"name":"numTokens","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"tokenOwner","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"receiver","type":"address"},{"name":"numTokens","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"owner","type":"address"},{"name":"delegate","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"total","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenOwner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"tokens","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"tokens","type":"uint256"}],"name":"Transfer","type":"event"}] | v0.4.26+commit.4563c3fc | true | 200 | 000000000000000000000000000000000000000000084595161401484a000000 | Default | MIT | false | bzzr://ae90843819245b3d54ea9aab448ec6c8988bf770b0d3654880a532fa33dbe43b |
||
DiviesLong | 0xd2344f06ce022a7424619b2af222e71b65824975 | Solidity | pragma solidity ^0.4.24;
// File: contracts/interface/DiviesInterface.sol
interface DiviesInterface {
function deposit() external payable;
}
// File: contracts/library/SafeMath.sol
/**
* @title SafeMath v0.1.9
* @dev Math operations with safety checks that throw on error
* change notes: original SafeMath library from OpenZeppelin modified by Inventor
* - added sqrt
* - added sq
* - added pwr
* - changed asserts to requires with error log outputs
* - removed div, its useless
*/
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;
require(c / a == b, "SafeMath mul failed");
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)
{
require(b <= a, "SafeMath sub failed");
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b)
internal
pure
returns (uint256 c)
{
c = a + b;
require(c >= a, "SafeMath add failed");
return c;
}
/**
* @dev gives square root of given x.
*/
function sqrt(uint256 x)
internal
pure
returns (uint256 y)
{
uint256 z = ((add(x,1)) / 2);
y = x;
while (z < y)
{
y = z;
z = ((add((x / z),z)) / 2);
}
}
/**
* @dev gives square. multiplies x by x
*/
function sq(uint256 x)
internal
pure
returns (uint256)
{
return (mul(x,x));
}
/**
* @dev x to the power of y
*/
function pwr(uint256 x, uint256 y)
internal
pure
returns (uint256)
{
if (x==0)
return (0);
else if (y==0)
return (1);
else
{
uint256 z = x;
for (uint256 i=1; i < y; i++)
z = mul(z,x);
return (z);
}
}
}
// File: contracts/library/UintCompressor.sol
library UintCompressor {
using SafeMath for *;
function insert(uint256 _var, uint256 _include, uint256 _start, uint256 _end)
internal
pure
returns(uint256)
{
// check conditions
require(_end < 77 && _start < 77, "start/end must be less than 77");
require(_end >= _start, "end must be >= start");
// format our start/end points
_end = exponent(_end).mul(10);
_start = exponent(_start);
// check that the include data fits into its segment
require(_include < (_end / _start));
// build middle
if (_include > 0)
_include = _include.mul(_start);
return((_var.sub((_var / _start).mul(_start))).add(_include).add((_var / _end).mul(_end)));
}
function extract(uint256 _input, uint256 _start, uint256 _end)
internal
pure
returns(uint256)
{
// check conditions
require(_end < 77 && _start < 77, "start/end must be less than 77");
require(_end >= _start, "end must be >= start");
// format our start/end points
_end = exponent(_end).mul(10);
_start = exponent(_start);
// return requested section
return((((_input / _start).mul(_start)).sub((_input / _end).mul(_end))) / _start);
}
function exponent(uint256 _position)
private
pure
returns(uint256)
{
return((10).pwr(_position));
}
}
// File: contracts/interface/HourglassInterface.sol
interface HourglassInterface {
function() payable external;
function buy(address _playerAddress) payable external returns(uint256);
function sell(uint256 _amountOfTokens) external;
function reinvest() external;
function withdraw() external;
function exit() external;
function dividendsOf(address _playerAddress) external view returns(uint256);
function balanceOf(address _playerAddress) external view returns(uint256);
function transfer(address _toAddress, uint256 _amountOfTokens) external returns(bool);
function stakingRequirement() external view returns(uint256);
}
// File: contracts/DiviesLong.sol
/**
* ┌──────────────────────────────────────────────────────────────────────┐
* │ Divies!, is a contract that adds an external dividend system to P3D. │
* │ All eth sent to this contract, can be distributed to P3D holders. │
* │ Uses msg.sender as masternode for initial buy order. │
* └──────────────────────────────────────────────────────────────────────┘
* ┌────────────────────┐
* │ Setup Instructions │
* └────────────────────┘
* (Step 1) import this contracts interface into your contract
*
* import "./DiviesInterface.sol";
*
* (Step 2) set up the interface and point it to this contract
*
* DiviesInterface private Divies = DiviesInterface(0xc7029Ed9EBa97A096e72607f4340c34049C7AF48);
* ┌────────────────────┐
* │ Usage Instructions │
* └────────────────────┘
* call as follows anywhere in your code:
*
* Divies.deposit.value(amount)();
* ex: Divies.deposit.value(232000000000000000000)();
*/
contract DiviesLong {
using SafeMath for uint256;
using UintCompressor for uint256;
//TODO:
HourglassInterface constant P3Dcontract_ = HourglassInterface(0x97550CE17666bB49349EF0E50f9fDb88353EDb64);
uint256 public pusherTracker_ = 100;
mapping (address => Pusher) public pushers_;
struct Pusher
{
uint256 tracker;
uint256 time;
}
uint256 public rateLimiter_;
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// MODIFIERS
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
modifier isHuman() {
address _addr = msg.sender;
require (_addr == tx.origin);
uint256 _codeLength;
assembly {_codeLength := extcodesize(_addr)}
require(_codeLength == 0, "sorry humans only");
_;
}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// BALANCE
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
function balances()
public
view
returns(uint256)
{
return (address(this).balance);
}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// DEPOSIT
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
function deposit()
external
payable
{
}
// used so the distribute function can call hourglass's withdraw
function() external payable {
// don't send it
revert();
}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// EVENTS
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
event onDistribute(
address pusher,
uint256 startingBalance,
uint256 masternodePayout,
uint256 finalBalance,
uint256 compressedData
);
/* compression key
[0-14] - timestamp
[15-29] - caller pusher tracker
[30-44] - global pusher tracker
[45-46] - percent
[47] - greedy
*/
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// DISTRIBUTE
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
function distribute(uint256 _percent)
public
isHuman()
{
// make sure _percent is within boundaries
require(_percent > 0 && _percent < 100, "please pick a percent between 1 and 99");
// data setup
address _pusher = msg.sender;
uint256 _bal = address(this).balance;
uint256 _mnPayout;
uint256 _compressedData;
// limit pushers greed (use "if" instead of require for level 42 top kek)
if (
pushers_[_pusher].tracker <= pusherTracker_.sub(100) && // pusher is greedy: wait your turn
pushers_[_pusher].time.add(1 hours) < now // pusher is greedy: its not even been 1 hour
)
{
// update pushers wait que
pushers_[_pusher].tracker = pusherTracker_;
pusherTracker_++;
// setup mn payout for event
if (P3Dcontract_.balanceOf(_pusher) >= P3Dcontract_.stakingRequirement())
_mnPayout = (_bal / 10) / 3;
// setup _stop. this will be used to tell the loop to stop
uint256 _stop = (_bal.mul(100 - _percent)) / 100;
// buy & sell
P3Dcontract_.buy.value(_bal)(_pusher);
P3Dcontract_.sell(P3Dcontract_.balanceOf(address(this)));
// setup tracker. this will be used to tell the loop to stop
uint256 _tracker = P3Dcontract_.dividendsOf(address(this));
// reinvest/sell loop
while (_tracker >= _stop)
{
// lets burn some tokens to distribute dividends to p3d holders
P3Dcontract_.reinvest();
P3Dcontract_.sell(P3Dcontract_.balanceOf(address(this)));
// update our tracker with estimates (yea. not perfect, but cheaper on gas)
_tracker = (_tracker.mul(81)) / 100;
}
// withdraw
P3Dcontract_.withdraw();
} else {
_compressedData = _compressedData.insert(1, 47, 47);
}
// update pushers timestamp (do outside of "if" for super saiyan level top kek)
pushers_[_pusher].time = now;
// prep event compression data
_compressedData = _compressedData.insert(now, 0, 14);
_compressedData = _compressedData.insert(pushers_[_pusher].tracker, 15, 29);
_compressedData = _compressedData.insert(pusherTracker_, 30, 44);
_compressedData = _compressedData.insert(_percent, 45, 46);
// fire event
emit onDistribute(_pusher, _bal, _mnPayout, address(this).balance, _compressedData);
}
} | [{"defect": "Frozen_Ether", "type": "Code_specification", "severity": "Medium", "lines": ["224"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["224"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["238", "339", "332", "82"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["329", "332"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["318"]}] | [{"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"DiviesLong.sol": [238]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"DiviesLong.sol": [160, 161, 162, 163, 164, 165, 166, 167, 152, 153, 154, 155, 156, 157, 158, 159]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"DiviesLong.sol": [77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"DiviesLong.sol": [96, 97, 98, 99, 100, 94, 95]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"DiviesLong.sol": [42, 43, 44, 45, 46, 47]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"DiviesLong.sol": [166]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"DiviesLong.sol": [149]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DiviesLong.sol": [304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DiviesLong.sol": [256, 257, 258, 259, 260, 261, 262]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"DiviesLong.sol": [1]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "missing-inheritance", "impact": "Informational", "confidence": "High", "lines": {"DiviesLong.sol": [5, 6, 7]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"DiviesLong.sol": [345]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"DiviesLong.sol": [346]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DiviesLong.sol": [304]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DiviesLong.sol": [169]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DiviesLong.sol": [129]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DiviesLong.sol": [152]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DiviesLong.sol": [129]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DiviesLong.sol": [288, 289, 290, 291, 285, 286, 287]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DiviesLong.sol": [129]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DiviesLong.sol": [129]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DiviesLong.sol": [152]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DiviesLong.sol": [152]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DiviesLong.sol": [229]}}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium", "lines": {"DiviesLong.sol": [359]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"DiviesLong.sol": [368]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"DiviesLong.sol": [320, 319]}}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium", "lines": {"DiviesLong.sol": [315]}}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium", "lines": {"DiviesLong.sol": [314]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"DiviesLong.sol": [335]}}] | [{"error": "Integer Overflow.", "line": 232, "level": "Warning"}] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 229, "severity": 1}, {"rule": "SOLIDITY_DIV_MUL", "line": 149, "severity": 2}, {"rule": "SOLIDITY_DIV_MUL", "line": 149, "severity": 2}, {"rule": "SOLIDITY_DIV_MUL", "line": 166, "severity": 2}, {"rule": "SOLIDITY_DIV_MUL", "line": 166, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 84, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 342, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_REDUNDANT_FALLBACK_REJECT", "line": 276, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 127, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 225, "severity": 1}, {"rule": "SOLIDITY_TX_ORIGIN", "line": 245, "severity": 2}, {"rule": "SOLIDITY_VISIBILITY", "line": 229, "severity": 1}] | [{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"pushers_","outputs":[{"name":"tracker","type":"uint256"},{"name":"time","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"pusherTracker_","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"balances","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_percent","type":"uint256"}],"name":"distribute","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"rateLimiter_","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"deposit","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"pusher","type":"address"},{"indexed":false,"name":"startingBalance","type":"uint256"},{"indexed":false,"name":"masternodePayout","type":"uint256"},{"indexed":false,"name":"finalBalance","type":"uint256"},{"indexed":false,"name":"compressedData","type":"uint256"}],"name":"onDistribute","type":"event"}] | v0.4.24+commit.e67f0147 | true | 200 | Default | false | bzzr://7cf25f4d22934e12eeb0ada09f5f23a018d612985e9040c52fc4bce1cfe360e8 |
||||
EpisodeManager | 0x29c2b4170d0d418adeab0c6ca454383e538c9b8d | Solidity | pragma solidity 0.4.19;
contract InterfaceRandao {
function getRandom(uint256 _campaignID) external returns (uint256);
}
contract InterfaceWallet {
function changeState(uint256 _id, uint8 _state) public returns (bool);
function changeBranch(uint256 _id, uint8 _branch) public returns (bool);
function getHolder(uint256 _id) public view returns (address);
}
contract EpisodeManager {
address public owner;
address public wallet;
//max token supply
uint256 public cap = 50;
address public randaoAddress;
address public lotteryAddress;
InterfaceWallet public lottery = InterfaceWallet(0x0);
InterfaceRandao public randao = InterfaceRandao(0x0);
bool public started = false;
uint256 public episodesNum = 0;
//Episode - (branch => (step => random and command))
struct CommandAndRandom {
uint256 random;
string command;
bool isSet;
}
//Episode - (branches => (branch and cost))
struct BranchAndCost {
uint256 price;
bool isBranch;
}
struct Episode {
//(branch => (step => random and command))
mapping (uint256 => mapping(uint256 => CommandAndRandom)) data;
//(branches => (branch and cost))
mapping (uint256 => BranchAndCost) branches;
bool isEpisode;
}
mapping (uint256 => Episode) public episodes;
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function EpisodeManager(address _randao, address _wallet) public {
require(_randao != address(0));
require(_wallet != address(0));
owner = msg.sender;
wallet = _wallet;
randaoAddress = _randao;
randao = InterfaceRandao(_randao);
}
function setLottery(address _lottery) public {
require(!started);
lotteryAddress = _lottery;
lottery = InterfaceWallet(_lottery);
started = true;
}
function changeRandao(address _randao) public onlyOwner {
randaoAddress = _randao;
randao = InterfaceRandao(_randao);
}
function addEpisode() public onlyOwner returns (bool) {
episodesNum++;
episodes[episodesNum].isEpisode = true;
return true;
}
function addEpisodeData(
uint256 _branch,
uint256 _step,
uint256 _campaignID,
string _command) public onlyOwner returns (bool)
{
require(_branch > 0);
require(_step > 0);
require(_campaignID > 0);
require(episodes[episodesNum].isEpisode);
require(!episodes[episodesNum].data[_branch][_step].isSet);
episodes[episodesNum].data[_branch][_step].random = randao.getRandom(_campaignID);
episodes[episodesNum].data[_branch][_step].command = _command;
episodes[episodesNum].data[_branch][_step].isSet = true;
return true;
}
function addNewBranchInEpisode(uint256 _branch, uint256 _price) public onlyOwner returns (bool) {
require(_branch > 0);
require(!episodes[episodesNum].branches[_branch].isBranch);
episodes[episodesNum].branches[_branch].price = _price;
episodes[episodesNum].branches[_branch].isBranch = true;
return true;
}
function changeBranch(uint256 _id, uint8 _branch) public payable returns(bool) {
require(_branch > 0);
require(episodes[episodesNum].branches[_branch].isBranch);
require((msg.sender == lottery.getHolder(_id)) || (msg.sender == owner));
if (episodes[episodesNum].branches[_branch].price == 0) {
lottery.changeBranch(_id, _branch);
} else {
require(msg.value == episodes[episodesNum].branches[_branch].price);
lottery.changeBranch(_id, _branch);
forwardFunds();
}
return true;
}
function changeState(uint256 _id, uint8 _state) public onlyOwner returns (bool) {
require(_id > 0 && _id <= cap);
require(_state <= 1);
return lottery.changeState(_id, _state);
}
function getEpisodeDataRandom(uint256 _episodeID, uint256 _branch, uint256 _step) public view returns (uint256) {
return episodes[_episodeID].data[_branch][_step].random;
}
function getEpisodeDataCommand(uint256 _episodeID, uint256 _branch, uint256 _step) public view returns (string) {
return episodes[_episodeID].data[_branch][_step].command;
}
function getEpisodeBranchData(uint256 _episodeID, uint256 _branch) public view returns (uint256) {
return episodes[_episodeID].branches[_branch].price;
}
// send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms
function forwardFunds() internal {
wallet.transfer(msg.value);
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["152"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["9", "4"]}] | [{"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"EpisodeManager.sol": [21]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"EpisodeManager.sol": [11]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"EpisodeManager.sol": [10]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"EpisodeManager.sol": [137, 138, 139]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"EpisodeManager.sol": [76, 77, 78, 79]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"EpisodeManager.sol": [108, 109, 110, 111, 112, 113, 114]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"EpisodeManager.sol": [141, 142, 143]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"EpisodeManager.sol": [128, 129, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"EpisodeManager.sol": [88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"EpisodeManager.sol": [81, 82, 83, 84, 85, 86]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"EpisodeManager.sol": [69, 70, 71, 72, 73, 74]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"EpisodeManager.sol": [131, 132, 133, 134, 135]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"EpisodeManager.sol": [145, 146, 147]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"EpisodeManager.sol": [12]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [1]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"EpisodeManager.sol": [77]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"EpisodeManager.sol": [71]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [116]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [116]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [108]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [145]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [91]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [92]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [69]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [131]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [137]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [137]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [141]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [90]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [141]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [145]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [76]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [131]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [137]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [141]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [89]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"EpisodeManager.sol": [108]}}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium", "lines": {"EpisodeManager.sol": [103]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"EpisodeManager.sol": [125]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"EpisodeManager.sol": [122]}}] | [{"error": "Integer Underflow.", "line": 142, "level": "Warning"}, {"error": "Integer Overflow.", "line": 88, "level": "Warning"}, {"error": "Integer Overflow.", "line": 83, "level": "Warning"}, {"error": "Integer Overflow.", "line": 53, "level": "Warning"}, {"error": "Integer Overflow.", "line": 82, "level": "Warning"}, {"error": "Integer Overflow.", "line": 146, "level": "Warning"}, {"error": "Integer Overflow.", "line": 111, "level": "Warning"}, {"error": "Integer Overflow.", "line": 142, "level": "Warning"}, {"error": "Integer Overflow.", "line": 112, "level": "Warning"}] | [{"rule": "SOLIDITY_UPGRADE_TO_050", "line": 92, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 141, "severity": 1}] | [{"constant":false,"inputs":[{"name":"_randao","type":"address"}],"name":"changeRandao","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"started","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"randaoAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"cap","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lotteryAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_episodeID","type":"uint256"},{"name":"_branch","type":"uint256"},{"name":"_step","type":"uint256"}],"name":"getEpisodeDataRandom","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"wallet","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_episodeID","type":"uint256"},{"name":"_branch","type":"uint256"}],"name":"getEpisodeBranchData","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"randao","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_branch","type":"uint256"},{"name":"_price","type":"uint256"}],"name":"addNewBranchInEpisode","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_id","type":"uint256"},{"name":"_state","type":"uint8"}],"name":"changeState","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_id","type":"uint256"},{"name":"_branch","type":"uint8"}],"name":"changeBranch","outputs":[{"name":"","type":"bool"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"episodes","outputs":[{"name":"isEpisode","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"addEpisode","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_episodeID","type":"uint256"},{"name":"_branch","type":"uint256"},{"name":"_step","type":"uint256"}],"name":"getEpisodeDataCommand","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"lottery","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"episodesNum","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_branch","type":"uint256"},{"name":"_step","type":"uint256"},{"name":"_campaignID","type":"uint256"},{"name":"_command","type":"string"}],"name":"addEpisodeData","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_lottery","type":"address"}],"name":"setLottery","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_randao","type":"address"},{"name":"_wallet","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] | v0.4.19+commit.c4cbbb05 | false | 200 | 000000000000000000000000fe7e9141d1ec8d30a37f9908cd93eadd7a2d9d9b000000000000000000000000e46b5f1f3551bd3c6b29c38babc662b03d985c48 | Default | false | bzzr://c88a842f5340e47780e5eef124f9a5dd4e4e177db7eeae00aaa742c79957078f |
|||
Airdrop | 0xf8eeefc666bb25d1693edea2c82a835a53712cd2 | Solidity | pragma solidity ^0.4.23;
interface WAVEliteToken {
function transfer(address to, uint256 value) external returns (bool);
}
contract Airdrop {
address public owner;
WAVEliteToken token;
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
constructor() public {
owner = msg.sender;
token = WAVEliteToken(0x0a8c316420f8d27812beae70faa42f0522c868b1);
}
function send(address[] dests, uint256[] values) public onlyOwner returns(uint256) {
uint256 i = 0;
while (i < dests.length) {
token.transfer(dests[i], values[i]);
i += 1;
}
return i;
}
} | [] | [{"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Airdrop.sol": [32, 33, 34, 26, 27, 28, 29, 30, 31]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Airdrop.sol": [1]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"Airdrop.sol": [29]}}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium", "lines": {"Airdrop.sol": [29]}}] | [{"error": "Integer Overflow.", "line": 26, "level": "Warning"}] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 23, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 28, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 28, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 26, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 26, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 13, "severity": 1}] | [{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"dests","type":"address[]"},{"name":"values","type":"uint256[]"}],"name":"send","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] | v0.4.23+commit.124ca40d | false | 200 | Default | false | bzzr://52f56c7930bb0e55e0dc5d8a8899b075bac8272bda26b5575bb0f9ef18116a97 |
||||
RockFlameBTC | 0x9d5918f61c9398c6b1932c76005d3b19bf10805a | Solidity | // File: RockFlameBTC.sol
pragma solidity ^0.4.24;
import "./SafeMath.sol";
interface ERC20 {
function balanceOf(address who) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
contract RockFlameBTC {
using SafeMath for uint256;
// BCNT token contract
ERC20 public BCNTToken;
// Roles
address public bincentiveHot; // i.e., Platform Owner
address public bincentiveCold;
address[] public rockInvestors;
uint256 public numMidwayQuitInvestors;
uint256 public numAUMDistributedInvestors; // i.e., number of investors that already received AUM
// Contract(Fund) Status
// 0: not initialized
// 1: initialized
// 2: not enough fund came in in time
// 3: fundStarted(skipped)
// 4: running
// 5: stoppped
// 6: closed
uint256 public fundStatus;
// Money
uint256 public totalRockInvestedAmount;
mapping(address => uint256) public rockInvestedAmount;
uint256 public BCNTLockAmount;
uint256 public returnedBTCAmounts;
// Events
event Deposit(address indexed investor, uint256 amount);
event StartFund(uint256 num_investors, uint256 totalInvestedAmount, uint256 BCNTLockAmount);
event AbortFund(uint256 num_investors, uint256 totalInvestedAmount);
event MidwayQuit(address indexed investor, uint256 investAmount, uint256 BCNTWithdrawAmount);
event ReturnAUM(uint256 amountBTC);
event DistributeAUM(address indexed to, uint256 amountBTC);
// Modifiers
modifier initialized() {
require(fundStatus == 1);
_;
}
// modifier fundStarted() {
// require(fundStatus == 3);
// _;
// }
modifier running() {
require(fundStatus == 4);
_;
}
modifier stopped() {
require(fundStatus == 5);
_;
}
// modifier afterStartedBeforeStopped() {
// require((fundStatus >= 3) && (fundStatus < 5));
// _;
// }
modifier closedOrAborted() {
require((fundStatus == 6) || (fundStatus == 2));
_;
}
modifier isBincentive() {
require(
(msg.sender == bincentiveHot) || (msg.sender == bincentiveCold)
);
_;
}
modifier isBincentiveCold() {
require(msg.sender == bincentiveCold);
_;
}
modifier isInvestor() {
// bincentive is not investor
require(msg.sender != bincentiveHot);
require(msg.sender != bincentiveCold);
require(rockInvestedAmount[msg.sender] > 0);
_;
}
// Getter Functions
// Investor Deposit
function deposit(address[] investors, uint256[] depositBTCAmounts) initialized isBincentive public {
require(investors.length > 0, "Must has at least one investor");
require(investors.length == depositBTCAmounts.length, "Input not of the same length");
address investor;
uint256 depositBTCAmount;
for(uint i = 0; i < investors.length; i++) {
investor = investors[i];
depositBTCAmount = depositBTCAmounts[i];
require((investor != bincentiveHot) && (investor != bincentiveCold));
totalRockInvestedAmount = totalRockInvestedAmount.add(depositBTCAmount);
if(rockInvestedAmount[investor] == 0) {
rockInvestors.push(investor);
}
rockInvestedAmount[investor] = rockInvestedAmount[investor].add(depositBTCAmount);
emit Deposit(investor, depositBTCAmount);
}
}
// Start Investing
function start(uint256 _BCNTLockAmount) initialized isBincentive public {
// Transfer and lock BCNT into the contract
require(BCNTToken.transferFrom(bincentiveCold, address(this), _BCNTLockAmount));
BCNTLockAmount = _BCNTLockAmount;
// Run it
fundStatus = 4;
emit StartFund(rockInvestors.length, totalRockInvestedAmount, BCNTLockAmount);
}
// NOTE: might consider changing to withdrawal pattern
// Not Enough Fund
function notEnoughFund() initialized isBincentive public {
fundStatus = 2;
emit AbortFund(rockInvestors.length, totalRockInvestedAmount);
}
// Investor quit and withdraw
function midwayQuitByAdmin(address _investor) running isBincentive public {
require(_investor != bincentiveHot && _investor != bincentiveCold);
uint256 investor_amount = rockInvestedAmount[_investor];
rockInvestedAmount[_investor] = 0;
// Subtract total invest amount and transfer investor's share to `bincentiveCold`
uint256 totalAmount = totalRockInvestedAmount;
totalRockInvestedAmount = totalRockInvestedAmount.sub(investor_amount);
rockInvestedAmount[bincentiveCold] = rockInvestedAmount[bincentiveCold].add(investor_amount);
uint256 BCNTWithdrawAmount = BCNTLockAmount.mul(investor_amount).div(totalAmount);
BCNTLockAmount = BCNTLockAmount.sub(BCNTWithdrawAmount);
require(BCNTToken.transfer(_investor, BCNTWithdrawAmount));
numMidwayQuitInvestors = numMidwayQuitInvestors.add(1);
// Close the contract if every investor has quit
if(numMidwayQuitInvestors == rockInvestors.length) {
fundStatus = 6;
}
emit MidwayQuit(_investor, investor_amount, BCNTWithdrawAmount);
}
// Investor quit and withdraw
function midwayQuit() running isInvestor public {
uint256 investor_amount = rockInvestedAmount[msg.sender];
rockInvestedAmount[msg.sender] = 0;
// Subtract total invest amount and transfer investor's share to `bincentiveCold`
uint256 totalAmount = totalRockInvestedAmount;
totalRockInvestedAmount = totalRockInvestedAmount.sub(investor_amount);
rockInvestedAmount[bincentiveCold] = rockInvestedAmount[bincentiveCold].add(investor_amount);
uint256 BCNTWithdrawAmount = BCNTLockAmount.mul(investor_amount).div(totalAmount);
BCNTLockAmount = BCNTLockAmount.sub(BCNTWithdrawAmount);
require(BCNTToken.transfer(msg.sender, BCNTWithdrawAmount));
numMidwayQuitInvestors = numMidwayQuitInvestors.add(1);
// Close the contract if every investor has quit
if(numMidwayQuitInvestors == rockInvestors.length) {
fundStatus = 6;
}
emit MidwayQuit(msg.sender, investor_amount, BCNTWithdrawAmount);
}
// Return AUM
function returnAUM(uint256 BTCAmount) running isBincentiveCold public {
returnedBTCAmounts = BTCAmount;
emit ReturnAUM(BTCAmount);
fundStatus = 5;
}
// Distribute AUM
function distributeAUM(uint256 numInvestorsToDistribute) stopped isBincentive public {
require(numAUMDistributedInvestors.add(numInvestorsToDistribute) <= rockInvestors.length, "Distributing to more than total number of rockInvestors");
uint256 totalBTCReturned = returnedBTCAmounts;
// Count `bincentiveCold`'s share in total amount when distributing AUM
uint256 totalAmount = totalRockInvestedAmount.add(rockInvestedAmount[bincentiveCold]);
uint256 BTCDistributeAmount;
address investor;
uint256 investor_amount;
// Distribute BTC to rockInvestors
for(uint i = numAUMDistributedInvestors; i < (numAUMDistributedInvestors.add(numInvestorsToDistribute)); i++) {
investor = rockInvestors[i];
if(rockInvestedAmount[investor] == 0) continue;
investor_amount = rockInvestedAmount[investor];
rockInvestedAmount[investor] = 0;
BTCDistributeAmount = totalBTCReturned.mul(investor_amount).div(totalAmount);
emit DistributeAUM(investor, BTCDistributeAmount);
}
numAUMDistributedInvestors = numAUMDistributedInvestors.add(numInvestorsToDistribute);
// If all rockInvestors have received AUM,
// distribute AUM and return BCNT stake to `bincentiveCold` then close the fund.
if(numAUMDistributedInvestors >= rockInvestors.length) {
returnedBTCAmounts = 0;
totalRockInvestedAmount = 0;
// Distribute BTC and BCNT to `bincentiveCold`
if(rockInvestedAmount[bincentiveCold] > 0) {
investor_amount = rockInvestedAmount[bincentiveCold];
rockInvestedAmount[bincentiveCold] = 0;
BTCDistributeAmount = totalBTCReturned.mul(investor_amount).div(totalAmount);
emit DistributeAUM(bincentiveCold, BTCDistributeAmount);
}
// Transfer the BCNT stake left back to `bincentiveCold`
uint256 _BCNTLockAmount = BCNTLockAmount;
BCNTLockAmount = 0;
require(BCNTToken.transfer(bincentiveCold, _BCNTLockAmount));
fundStatus = 6;
}
}
// Constructor
constructor(
address _BCNTToken,
address _bincentiveHot,
address _bincentiveCold) public {
BCNTToken = ERC20(_BCNTToken);
bincentiveHot = _bincentiveHot;
bincentiveCold = _bincentiveCold;
// Initialized the contract
fundStatus = 1;
}
}
// File: SafeMath.sol
pragma solidity ^0.4.24;
/**
* @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;
}
}
| [{"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["116"]}] | [{"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SafeMath.sol": [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SafeMath.sol": [40, 41, 42, 39]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SafeMath.sol": [47, 48, 49, 50, 51]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SafeMath.sol": [32, 33, 34, 29, 30, 31]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"SafeMath.sol": [1]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}] | [] | [{"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 116, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 220, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 116, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 5, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 275, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 15, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 110, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 110, "severity": 1}] | [{"constant":true,"inputs":[],"name":"bincentiveHot","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"rockInvestors","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"midwayQuit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"BCNTLockAmount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"numMidwayQuitInvestors","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_investor","type":"address"}],"name":"midwayQuitByAdmin","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"BCNTToken","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"numInvestorsToDistribute","type":"uint256"}],"name":"distributeAUM","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"returnedBTCAmounts","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"BTCAmount","type":"uint256"}],"name":"returnAUM","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_BCNTLockAmount","type":"uint256"}],"name":"start","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalRockInvestedAmount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"rockInvestedAmount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"bincentiveCold","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"numAUMDistributedInvestors","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"fundStatus","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"investors","type":"address[]"},{"name":"depositBTCAmounts","type":"uint256[]"}],"name":"deposit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"notEnoughFund","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_BCNTToken","type":"address"},{"name":"_bincentiveHot","type":"address"},{"name":"_bincentiveCold","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"investor","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"num_investors","type":"uint256"},{"indexed":false,"name":"totalInvestedAmount","type":"uint256"},{"indexed":false,"name":"BCNTLockAmount","type":"uint256"}],"name":"StartFund","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"num_investors","type":"uint256"},{"indexed":false,"name":"totalInvestedAmount","type":"uint256"}],"name":"AbortFund","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"investor","type":"address"},{"indexed":false,"name":"investAmount","type":"uint256"},{"indexed":false,"name":"BCNTWithdrawAmount","type":"uint256"}],"name":"MidwayQuit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"amountBTC","type":"uint256"}],"name":"ReturnAUM","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"amountBTC","type":"uint256"}],"name":"DistributeAUM","type":"event"}] | v0.4.26+commit.4563c3fc | true | 200 | 0000000000000000000000009669890e48f330acd88b78d63e1a6b3482652cd9000000000000000000000000776e2337e323d11009cc4d484c7b39313f5c791f00000000000000000000000044620c73b430234104247dffdae4868b5bbe9e73 | Default | None | false | bzzr://fb19c1c1f38e0d5e14032971458c3d7e98cbc75d895941f63248a6390463362f |
||
FabCoin | 0xf2260ed15c59c9437848afed04645044a8d5e270 | Solidity | /**
*Submitted for verification at Etherscan.io on 2021-02-18
*/
pragma solidity ^0.4.26;
/**
* @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 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.
*/
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 {
if (newOwner != address(0)) {
owner = newOwner;
}
}
}
/**
* @title ERC20Basic
* @dev Simpler version of ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
contract ERC20Basic {
uint public _totalSupply;
function totalSupply() public constant returns (uint);
function balanceOf(address who) public constant returns (uint);
function transfer(address to, uint value) public;
event Transfer(address indexed from, address indexed to, uint value);
}
/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
contract ERC20 is ERC20Basic {
function allowance(address owner, address spender) public constant returns (uint);
function transferFrom(address from, address to, uint value) public;
function approve(address spender, uint value) public;
event Approval(address indexed owner, address indexed spender, uint value);
}
/**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/
contract BasicToken is Ownable, ERC20Basic {
using SafeMath for uint;
mapping(address => uint) public balances;
// additional variables for use if transaction fees ever became necessary
uint public basisPointsRate = 0;
uint public maximumFee = 0;
/**
* @dev Fix for the ERC20 short address attack.
*/
modifier onlyPayloadSize(uint size) {
require(!(msg.data.length < size + 4));
_;
}
/**
* @dev transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint _value) public onlyPayloadSize(2 * 32) {
uint fee = (_value.mul(basisPointsRate)).div(10000);
if (fee > maximumFee) {
fee = maximumFee;
}
uint sendAmount = _value.sub(fee);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(sendAmount);
if (fee > 0) {
balances[owner] = balances[owner].add(fee);
emit Transfer(msg.sender, owner, fee);
}
emit Transfer(msg.sender, _to, sendAmount);
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public constant returns (uint balance) {
return balances[_owner];
}
}
/**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based oncode by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/
contract StandardToken is BasicToken, ERC20 {
mapping (address => mapping (address => uint)) public allowed;
uint public constant MAX_UINT = 2**256 - 1;
/**
* @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 uint the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint _value) public onlyPayloadSize(3 * 32) {
uint256 _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// if (_value > _allowance) throw;
uint fee = (_value.mul(basisPointsRate)).div(10000);
if (fee > maximumFee) {
fee = maximumFee;
}
if (_allowance < MAX_UINT) {
allowed[_from][msg.sender] = _allowance.sub(_value);
}
uint sendAmount = _value.sub(fee);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(sendAmount);
if (fee > 0) {
balances[owner] = balances[owner].add(fee);
emit Transfer(_from, owner, fee);
}
emit Transfer(_from, _to, sendAmount);
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint _value) public onlyPayloadSize(2 * 32) {
// To change the approve amount you first have to reduce the addresses`
// allowance to zero by calling `approve(_spender, 0)` if it is not
// already 0 to mitigate the race condition described here:
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
require(!((_value != 0) && (allowed[msg.sender][_spender] != 0)));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
}
/**
* @dev Function to check the amount of tokens than 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 uint specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public constant returns (uint remaining) {
return allowed[_owner][_spender];
}
}
/**
* @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 BlackList is Ownable, BasicToken {
/////// Getters to allow the same blacklist to be used also by other contracts (including upgraded Tether) ///////
function getBlackListStatus(address _maker) external constant returns (bool) {
return isBlackListed[_maker];
}
function getOwner() external constant returns (address) {
return owner;
}
mapping (address => bool) public isBlackListed;
function addBlackList (address _evilUser) public onlyOwner {
isBlackListed[_evilUser] = true;
emit AddedBlackList(_evilUser);
}
function removeBlackList (address _clearedUser) public onlyOwner {
isBlackListed[_clearedUser] = false;
emit RemovedBlackList(_clearedUser);
}
function destroyBlackFunds (address _blackListedUser) public onlyOwner {
require(isBlackListed[_blackListedUser]);
uint dirtyFunds = balanceOf(_blackListedUser);
balances[_blackListedUser] = 0;
_totalSupply -= dirtyFunds;
emit DestroyedBlackFunds(_blackListedUser, dirtyFunds);
}
event DestroyedBlackFunds(address _blackListedUser, uint _balance);
event AddedBlackList(address _user);
event RemovedBlackList(address _user);
}
contract UpgradedStandardToken is StandardToken{
// those methods are called by the legacy contract
// and they must ensure msg.sender to be the contract address
function transferByLegacy(address from, address to, uint value) public;
function transferFromByLegacy(address sender, address from, address spender, uint value) public;
function approveByLegacy(address from, address spender, uint value) public;
}
contract FabCoin is Pausable, StandardToken, BlackList {
string public name;
string public symbol;
uint public decimals;
address public upgradedAddress;
bool public deprecated;
// The contract can be initialized with a number of tokens
// All the tokens are deposited to the owner address
//
// @param _balance Initial supply of the contract
// @param _name Token Name
// @param _symbol Token symbol
// @param _decimals Token decimals
constructor(uint _initialSupply, string _name, string _symbol, uint _decimals) public {
_totalSupply = _initialSupply;
name = _name;
symbol = _symbol;
decimals = _decimals;
balances[owner] = _initialSupply;
deprecated = false;
}
// Forward ERC20 methods to upgraded contract if this one is deprecated
function transfer(address _to, uint _value) public whenNotPaused {
require(!isBlackListed[msg.sender]);
if (deprecated) {
return UpgradedStandardToken(upgradedAddress).transferByLegacy(msg.sender, _to, _value);
} else {
return super.transfer(_to, _value);
}
}
// Forward ERC20 methods to upgraded contract if this one is deprecated
function transferFrom(address _from, address _to, uint _value) public whenNotPaused {
require(!isBlackListed[_from]);
if (deprecated) {
return UpgradedStandardToken(upgradedAddress).transferFromByLegacy(msg.sender, _from, _to, _value);
} else {
return super.transferFrom(_from, _to, _value);
}
}
// Forward ERC20 methods to upgraded contract if this one is deprecated
function balanceOf(address who) public constant returns (uint) {
if (deprecated) {
return UpgradedStandardToken(upgradedAddress).balanceOf(who);
} else {
return super.balanceOf(who);
}
}
// Forward ERC20 methods to upgraded contract if this one is deprecated
function approve(address _spender, uint _value) public onlyPayloadSize(2 * 32) {
if (deprecated) {
return UpgradedStandardToken(upgradedAddress).approveByLegacy(msg.sender, _spender, _value);
} else {
return super.approve(_spender, _value);
}
}
// Forward ERC20 methods to upgraded contract if this one is deprecated
function allowance(address _owner, address _spender) public constant returns (uint remaining) {
if (deprecated) {
return StandardToken(upgradedAddress).allowance(_owner, _spender);
} else {
return super.allowance(_owner, _spender);
}
}
// deprecate current contract in favour of a new one
function deprecate(address _upgradedAddress) public onlyOwner {
deprecated = true;
upgradedAddress = _upgradedAddress;
emit Deprecate(_upgradedAddress);
}
// deprecate current contract if favour of a new one
function totalSupply() public constant returns (uint) {
if (deprecated) {
return StandardToken(upgradedAddress).totalSupply();
} else {
return _totalSupply;
}
}
function setParams(uint newBasisPoints, uint newMaxFee) public onlyOwner {
// Ensure transparency by hardcoding limit beyond which fees can never be added
require(newBasisPoints < 20);
require(newMaxFee < 50);
basisPointsRate = newBasisPoints;
maximumFee = newMaxFee.mul(10**decimals);
emit Params(basisPointsRate, maximumFee);
}
// Called when contract is deprecated
event Deprecate(address newAddress);
// Called if contract ever adds fees
event Params(uint feeBasisPoints, uint maxFee);
} | [{"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["307"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["82"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["64", "275", "286", "281", "270", "270"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["408", "295"]}] | [{"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FabCoin.sol": [402, 403, 404, 405, 406, 407, 408, 409, 410, 411]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FabCoin.sol": [310]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FabCoin.sol": [256, 257, 254, 255]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FabCoin.sol": [394, 395, 396, 397, 398, 399, 400]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FabCoin.sol": [311]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FabCoin.sol": [387, 388, 389, 390, 391]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FabCoin.sol": [68, 69, 70, 71, 72]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FabCoin.sol": [264, 265, 262, 263]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FabCoin.sol": [312]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FabCoin.sol": [288, 289, 286, 287]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FabCoin.sol": [281, 282, 283, 284]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FabCoin.sol": [291, 292, 293, 294, 295, 296, 297]}}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High", "lines": {"FabCoin.sol": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 126, 127]}}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High", "lines": {"FabCoin.sol": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 126, 127]}}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High", "lines": {"FabCoin.sol": [369, 370, 371, 372, 373, 374, 375]}}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High", "lines": {"FabCoin.sol": [95]}}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High", "lines": {"FabCoin.sol": [85]}}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High", "lines": {"FabCoin.sol": [96]}}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High", "lines": {"FabCoin.sol": [199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209]}}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High", "lines": {"FabCoin.sol": [96]}}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High", "lines": {"FabCoin.sol": [340, 341, 342, 343, 344, 345, 346, 347]}}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High", "lines": {"FabCoin.sol": [199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209]}}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High", "lines": {"FabCoin.sol": [352, 353, 354, 355, 356, 357, 350, 351]}}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High", "lines": {"FabCoin.sol": [171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192]}}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High", "lines": {"FabCoin.sol": [171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192]}}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High", "lines": {"FabCoin.sol": [95]}}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High", "lines": {"FabCoin.sol": [85]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [5]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "events-access", "impact": "Low", "confidence": "Medium", "lines": {"FabCoin.sol": [70]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"FabCoin.sol": [389]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [281]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [217]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [199]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [126]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [217]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [378]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [171]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [171]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [286]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [350]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [199]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [378]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [291]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [126]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [271]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [340]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [350]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [82]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [146]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [369]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [369]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [340]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [171]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [387]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [350]}}, {"check": "unimplemented-functions", "impact": "Informational", "confidence": "High", "lines": {"FabCoin.sol": [311]}}] | [{"error": "Integer Underflow.", "line": 318, "level": "Warning"}, {"error": "Integer Underflow.", "line": 295, "level": "Warning"}, {"error": "Integer Underflow.", "line": 317, "level": "Warning"}] | [{"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 83, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 84, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 94, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 146, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 217, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 271, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 275, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 360, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 378, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 394, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 199, "severity": 2}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 369, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 402, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 5, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 105, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 330, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 330, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_upgradedAddress","type":"address"}],"name":"deprecate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"deprecated","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_evilUser","type":"address"}],"name":"addBlackList","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"upgradedAddress","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balances","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"maximumFee","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"_totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_maker","type":"address"}],"name":"getBlackListStatus","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowed","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"who","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getOwner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"newBasisPoints","type":"uint256"},{"name":"newMaxFee","type":"uint256"}],"name":"setParams","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"basisPointsRate","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"isBlackListed","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_clearedUser","type":"address"}],"name":"removeBlackList","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"MAX_UINT","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_blackListedUser","type":"address"}],"name":"destroyBlackFunds","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_initialSupply","type":"uint256"},{"name":"_name","type":"string"},{"name":"_symbol","type":"string"},{"name":"_decimals","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"name":"newAddress","type":"address"}],"name":"Deprecate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"feeBasisPoints","type":"uint256"},{"indexed":false,"name":"maxFee","type":"uint256"}],"name":"Params","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_blackListedUser","type":"address"},{"indexed":false,"name":"_balance","type":"uint256"}],"name":"DestroyedBlackFunds","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_user","type":"address"}],"name":"AddedBlackList","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_user","type":"address"}],"name":"RemovedBlackList","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[],"name":"Pause","type":"event"},{"anonymous":false,"inputs":[],"name":"Unpause","type":"event"}] | v0.4.26+commit.4563c3fc | false | 200 | 000000000000000000000000000000000000000000000000001b0028e44b0000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000007466162636f696e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034641420000000000000000000000000000000000000000000000000000000000 | Default | None | false | bzzr://6af36a560feee62b958ab00b4ba8833edea4436d362c68f8cf68cf60c0bd484a |
||
Token | 0x2596a46a28d05505fd8de34917451b08faea05b7 | Solidity | // Unattributed material copyright New Alchemy Limited, 2017. All rights reserved.
pragma solidity >=0.4.10;
// from Zeppelin
contract SafeMath {
function safeMul(uint a, uint b) internal returns (uint) {
uint c = a * b;
require(a == 0 || c / a == b);
return c;
}
function safeSub(uint a, uint b) internal returns (uint) {
require(b <= a);
return a - b;
}
function safeAdd(uint a, uint b) internal returns (uint) {
uint c = a + b;
require(c>=a && c>=b);
return c;
}
}
// end from Zeppelin
contract Owned {
address public owner;
address newOwner;
function Owned() {
owner = msg.sender;
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
function changeOwner(address _newOwner) onlyOwner {
newOwner = _newOwner;
}
function acceptOwnership() {
if (msg.sender == newOwner) {
owner = newOwner;
}
}
}
contract Pausable is Owned {
bool public paused;
function pause() onlyOwner {
paused = true;
}
function unpause() onlyOwner {
paused = false;
}
modifier notPaused() {
require(!paused);
_;
}
}
contract Finalizable is Owned {
bool public finalized;
function finalize() onlyOwner {
finalized = true;
}
modifier notFinalized() {
require(!finalized);
_;
}
}
contract IToken {
function transfer(address _to, uint _value) returns (bool);
function balanceOf(address owner) returns(uint);
}
// In case someone accidentally sends token to one of these contracts,
// add a way to get them back out.
contract TokenReceivable is Owned {
function claimTokens(address _token, address _to) onlyOwner returns (bool) {
IToken token = IToken(_token);
return token.transfer(_to, token.balanceOf(this));
}
function claimEther() onlyOwner {
owner.transfer(this.balance);
}
}
contract EventDefinitions {
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}
contract Token is Finalizable, TokenReceivable, SafeMath, EventDefinitions, Pausable {
// Set these appropriately before you deploy
string constant public name = "Token Report";
uint8 constant public decimals = 8;
string constant public symbol = "EDGE";
Controller public controller;
string public motd;
event Motd(string message);
// functions below this line are onlyOwner
// set "message of the day"
function setMotd(string _m) onlyOwner {
motd = _m;
Motd(_m);
}
function setController(address _c) onlyOwner notFinalized {
controller = Controller(_c);
}
// functions below this line are public
function balanceOf(address a) constant returns (uint) {
return controller.balanceOf(a);
}
function totalSupply() constant returns (uint) {
return controller.totalSupply();
}
function allowance(address _owner, address _spender) constant returns (uint) {
return controller.allowance(_owner, _spender);
}
function transfer(address _to, uint _value) onlyPayloadSize(2) notPaused returns (bool success) {
if (controller.transfer(msg.sender, _to, _value)) {
Transfer(msg.sender, _to, _value);
return true;
}
return false;
}
function transferFrom(address _from, address _to, uint _value) onlyPayloadSize(3) notPaused returns (bool success) {
if (controller.transferFrom(msg.sender, _from, _to, _value)) {
Transfer(_from, _to, _value);
return true;
}
return false;
}
function approve(address _spender, uint _value) onlyPayloadSize(2) notPaused returns (bool success) {
// promote safe user behavior
if (controller.approve(msg.sender, _spender, _value)) {
Approval(msg.sender, _spender, _value);
return true;
}
return false;
}
function increaseApproval (address _spender, uint _addedValue) onlyPayloadSize(2) notPaused returns (bool success) {
if (controller.increaseApproval(msg.sender, _spender, _addedValue)) {
uint newval = controller.allowance(msg.sender, _spender);
Approval(msg.sender, _spender, newval);
return true;
}
return false;
}
function decreaseApproval (address _spender, uint _subtractedValue) onlyPayloadSize(2) notPaused returns (bool success) {
if (controller.decreaseApproval(msg.sender, _spender, _subtractedValue)) {
uint newval = controller.allowance(msg.sender, _spender);
Approval(msg.sender, _spender, newval);
return true;
}
return false;
}
// fallback function simply forwards Ether to the controller's fallback
function () payable {
controller.fallback.value(msg.value)(msg.sender);
}
modifier onlyPayloadSize(uint numwords) {
assert(msg.data.length >= numwords * 32 + 4);
_;
}
function burn(uint _amount) notPaused {
controller.burn(msg.sender, _amount);
Transfer(msg.sender, 0x0, _amount);
}
// functions below this line are onlyController
modifier onlyController() {
assert(msg.sender == address(controller));
_;
}
// In the future, when the controller supports multiple token
// heads, allow the controller to reconstitute the transfer and
// approval history.
function controllerTransfer(address _from, address _to, uint _value) onlyController {
Transfer(_from, _to, _value);
}
function controllerApprove(address _owner, address _spender, uint _value) onlyController {
Approval(_owner, _spender, _value);
}
}
contract Controller is Owned, TokenReceivable, Finalizable {
Ledger public ledger;
Token public token;
function Controller() {
}
// functions below this line are onlyOwner
function setToken(address _token) onlyOwner {
token = Token(_token);
}
function setLedger(address _ledger) onlyOwner {
ledger = Ledger(_ledger);
}
modifier onlyToken() {
require(msg.sender == address(token));
_;
}
modifier onlyLedger() {
require(msg.sender == address(ledger));
_;
}
// public functions
function totalSupply() constant returns (uint) {
return ledger.totalSupply();
}
function balanceOf(address _a) constant returns (uint) {
return ledger.balanceOf(_a);
}
function allowance(address _owner, address _spender) constant returns (uint) {
return ledger.allowance(_owner, _spender);
}
// functions below this line are onlyLedger
// let the ledger send transfer events (the most obvious case
// is when we mint directly to the ledger and need the Transfer()
// events to appear in the token)
function ledgerTransfer(address from, address to, uint val) onlyLedger {
token.controllerTransfer(from, to, val);
}
// functions below this line are onlyToken
function transfer(address _from, address _to, uint _value) onlyToken returns (bool success) {
return ledger.transfer(_from, _to, _value);
}
function transferFrom(address _spender, address _from, address _to, uint _value) onlyToken returns (bool success) {
return ledger.transferFrom(_spender, _from, _to, _value);
}
function approve(address _owner, address _spender, uint _value) onlyToken returns (bool success) {
return ledger.approve(_owner, _spender, _value);
}
function increaseApproval (address _owner, address _spender, uint _addedValue) onlyToken returns (bool success) {
return ledger.increaseApproval(_owner, _spender, _addedValue);
}
function decreaseApproval (address _owner, address _spender, uint _subtractedValue) onlyToken returns (bool success) {
return ledger.decreaseApproval(_owner, _spender, _subtractedValue);
}
function burn(address _owner, uint _amount) onlyToken {
ledger.burn(_owner, _amount);
}
// code below is dedicated to whitelist sale logic
// mapping of address to contribution amount whitelist
mapping (address => uint) public whitelist;
mapping (address => uint) public exchg;
function addToWhitelist(address addr, uint rate, uint weimax) onlyOwner {
exchg[addr] = rate;
whitelist[addr] = weimax;
}
// token fallback function forwards to this
function fallback(address orig) payable onlyToken {
uint max = whitelist[orig];
uint denom = exchg[orig];
require(denom != 0);
require(msg.value <= max);
whitelist[orig] = max - msg.value;
uint tkn = msg.value / denom;
ledger.controllerMint(orig, tkn);
token.controllerTransfer(0, orig, tkn);
}
}
contract Ledger is Owned, SafeMath, Finalizable {
Controller public controller;
mapping(address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
uint public totalSupply;
uint public mintingNonce;
bool public mintingStopped;
// functions below this line are onlyOwner
function Ledger() {
}
function setController(address _controller) onlyOwner notFinalized {
controller = Controller(_controller);
}
function stopMinting() onlyOwner {
mintingStopped = true;
}
function multiMint(uint nonce, uint256[] bits) onlyOwner {
require(!mintingStopped);
if (nonce != mintingNonce) return;
mintingNonce += 1;
uint256 lomask = (1 << 96) - 1;
uint created = 0;
for (uint i=0; i<bits.length; i++) {
address a = address(bits[i]>>96);
uint value = bits[i]&lomask;
balanceOf[a] = balanceOf[a] + value;
controller.ledgerTransfer(0, a, value);
created += value;
}
totalSupply += created;
}
// functions below this line are onlyController
modifier onlyController() {
require(msg.sender == address(controller));
_;
}
function controllerMint(address to, uint amt) onlyController {
require(!mintingStopped);
balanceOf[to] = safeAdd(balanceOf[to], amt);
totalSupply = safeAdd(totalSupply, amt);
}
function transfer(address _from, address _to, uint _value) onlyController returns (bool success) {
if (balanceOf[_from] < _value) return false;
balanceOf[_from] = safeSub(balanceOf[_from], _value);
balanceOf[_to] = safeAdd(balanceOf[_to], _value);
return true;
}
function transferFrom(address _spender, address _from, address _to, uint _value) onlyController returns (bool success) {
if (balanceOf[_from] < _value) return false;
var allowed = allowance[_from][_spender];
if (allowed < _value) return false;
balanceOf[_to] = safeAdd(balanceOf[_to], _value);
balanceOf[_from] = safeSub(balanceOf[_from], _value);
allowance[_from][_spender] = safeSub(allowed, _value);
return true;
}
function approve(address _owner, address _spender, uint _value) onlyController returns (bool success) {
// require user to set to zero before resetting to nonzero
if ((_value != 0) && (allowance[_owner][_spender] != 0)) {
return false;
}
allowance[_owner][_spender] = _value;
return true;
}
function increaseApproval (address _owner, address _spender, uint _addedValue) onlyController returns (bool success) {
uint oldValue = allowance[_owner][_spender];
allowance[_owner][_spender] = safeAdd(oldValue, _addedValue);
return true;
}
function decreaseApproval (address _owner, address _spender, uint _subtractedValue) onlyController returns (bool success) {
uint oldValue = allowance[_owner][_spender];
if (_subtractedValue > oldValue) {
allowance[_owner][_spender] = 0;
} else {
allowance[_owner][_spender] = safeSub(oldValue, _subtractedValue);
}
return true;
}
function burn(address _owner, uint _amount) onlyController {
balanceOf[_owner] = safeSub(balanceOf[_owner], _amount);
totalSupply = safeSub(totalSupply, _amount);
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["93"]}, {"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["342"]}, {"defect": "Frozen_Ether", "type": "Code_specification", "severity": "Medium", "lines": ["215", "102"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["102", "79"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["104", "106", "105", "182"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["29"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["347", "339", "349", "308", "345", "309"]}] | [{"check": "shadowing-builtin", "impact": "Low", "confidence": "High", "lines": {"Token.sol": [303, 304, 305, 306, 307, 308, 309, 310, 311, 312]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Token.sol": [6, 7, 8, 9, 10]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [328, 329, 330]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [133, 134, 135]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [248, 249, 250]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [224, 225, 226]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [69, 70, 71]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [411, 412, 413, 414]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [261, 262, 263]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [228, 229, 230]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [42, 43, 44, 45, 46]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [52, 53, 54]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [365, 366, 367, 368, 369, 370, 371]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [280, 281, 279]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [40, 38, 39]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [244, 245, 246]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [303, 304, 305, 306, 307, 308, 309, 310, 311, 312]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [288, 289, 287]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [129, 130, 131]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [395, 396, 397, 398, 399]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [192, 193, 190, 191]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [160, 153, 154, 155, 156, 157, 158, 159]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [267, 268, 269]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [120, 121, 119]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [210, 211, 212]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [252, 253, 254]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [56, 57, 58]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [81]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [171, 172, 173, 174, 175, 176, 177, 178]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [137, 138, 139, 140, 141, 142, 143]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [125, 126, 127]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [385, 386, 387, 388, 389, 390, 391, 392, 393]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [145, 146, 147, 148, 149, 150, 151]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [297, 298, 299, 300]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [88, 89, 90, 87]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [92, 93, 94]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [283, 284, 285]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [275, 276, 277]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [162, 163, 164, 165, 166, 167, 168, 169]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [401, 402, 403, 404, 405, 406, 407, 408, 409]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [332, 333, 334]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [181, 182, 183]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [208, 206, 207]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [114, 115, 116, 117]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [80]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [272, 273, 271]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Token.sol": [359, 360, 361, 362, 363]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [2]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "missing-inheritance", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [80, 81, 82, 79]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"Token.sol": [39]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"Token.sol": [346]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [114]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [373]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [275]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [252]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [252]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [373]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [271]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [267]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [87]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [38]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [162]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [395]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [385]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [287]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [210]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [271]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [271]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [411]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [287]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [133]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [401]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [275]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [385]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [210]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [228]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [190]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [401]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [271]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [267]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [411]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [385]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [279]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [162]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [206]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [171]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [87]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [395]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [206]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [206]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [267]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [279]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [137]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [283]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [283]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [365]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [210]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [153]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [145]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [328]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [373]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [145]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [365]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [279]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [153]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [365]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [401]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [171]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [145]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [137]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [395]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [224]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [119]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [133]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [283]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [373]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [275]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Token.sol": [248]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"Token.sol": [165]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"Token.sol": [156]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"Token.sol": [147]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"Token.sol": [174]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"Token.sol": [192]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"Token.sol": [139]}}] | [{"error": "Integer Overflow.", "line": 336, "level": "Warning"}, {"error": "Integer Underflow.", "line": 108, "level": "Warning"}, {"error": "Integer Overflow.", "line": 114, "level": "Warning"}, {"error": "Transaction-Ordering Dependency.", "line": 182, "level": "Warning"}, {"error": "Transaction-Ordering Dependency.", "line": 93, "level": "Warning"}] | [{"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 125, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 129, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 133, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 244, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 248, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 252, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 153, "severity": 2}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 275, "severity": 2}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 342, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 342, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 114, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 119, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 224, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 228, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 328, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 29, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 38, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 42, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 52, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 56, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 69, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 80, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 81, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 87, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 92, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 114, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 119, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 125, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 129, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 133, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 137, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 145, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 153, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 162, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 171, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 181, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 190, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 206, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 210, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 219, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 224, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 228, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 244, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 248, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 252, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 261, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 267, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 271, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 275, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 279, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 283, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 287, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 297, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 303, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 325, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 328, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 332, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 336, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 359, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 365, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 373, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 385, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 395, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 401, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 411, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 27, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_amount","type":"uint256"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"finalize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"claimEther","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"motd","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"paused","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_m","type":"string"}],"name":"setMotd","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_subtractedValue","type":"uint256"}],"name":"decreaseApproval","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"},{"name":"_to","type":"address"}],"name":"claimTokens","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"controllerApprove","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_c","type":"address"}],"name":"setController","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"controllerTransfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"changeOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"finalized","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_addedValue","type":"uint256"}],"name":"increaseApproval","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"controller","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"message","type":"string"}],"name":"Motd","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"}] | v0.4.18+commit.9cf6e910 | true | 200 | Default | false | bzzr://92102a032d8e67b85d3a935a386f590a03c327c5105fa232ac4f9358ab2f6a0f |
||||
LiquidityPool | 0x5cecdbdfb96463045b07d07aaa4fc2f1316f7e47 | Solidity | // SPDX-License-Identifier: MIT
pragma solidity 0.6.10;
/**
* @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 {
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);
}
// Liquidity pool allows a user to stake Uniswap liquidity tokens (tokens representaing shares of ETH and PAMP tokens in the Uniswap liquidity pool)
// Users receive rewards in tokens for locking up their liquidity
contract LiquidityPool {
using SafeMath for uint256;
IERC20 public uniswapPair;
IERC20 public pampToken;
address public owner;
uint public minStakeDurationDays;
uint public rewardAdjustmentFactor;
bool public stakingEnabled;
bool public exponentialRewardsEnabled;
uint public exponentialDaysMax;
struct staker {
uint startTimestamp; // Unix timestamp of when the tokens were initially staked
uint poolTokenBalance; // Balance of Uniswap liquidity tokens
}
mapping(address => staker) public stakers;
modifier onlyOwner() {
require(owner == msg.sender, "Caller is not the owner");
_;
}
constructor(address _uniswapPair, address _pampToken) public {
uniswapPair = IERC20(_uniswapPair);
pampToken = IERC20(_pampToken);
minStakeDurationDays = 1;
owner = msg.sender;
rewardAdjustmentFactor = 4E21;
stakingEnabled = true;
exponentialRewardsEnabled = false;
exponentialDaysMax = 10;
}
function stakeLiquidityTokens(uint256 numPoolTokensToStake) external {
require(numPoolTokensToStake > 0);
require(stakingEnabled, "Staking is currently disabled.");
uint previousBalance = uniswapPair.balanceOf(address(this));
uniswapPair.transferFrom(msg.sender, address(this), numPoolTokensToStake); // Transfer liquidity tokens from the sender to this contract
uint postBalance = uniswapPair.balanceOf(address(this));
require(previousBalance.add(numPoolTokensToStake) == postBalance); // This is a sanity check and likely not required as the Uniswap token is ERC20
staker storage thisStaker = stakers[msg.sender]; // Get the sender's information
if(thisStaker.startTimestamp == 0 || thisStaker.poolTokenBalance == 0) {
thisStaker.startTimestamp = block.timestamp;
} else { // If the sender is currently staking, adding to his balance results in a holding time penalty
uint percent = mulDiv(1000000, numPoolTokensToStake, thisStaker.poolTokenBalance); // This is not really 'percent' it is just a number that represents the totalAmount as a fraction of the recipientBalance
assert(percent > 0);
if(percent > 1) {
percent = percent.div(2); // We divide the 'penalty' by 2 so that the penalty is not as bad
}
if(percent.add(thisStaker.startTimestamp) > block.timestamp) { // We represent the 'percent' or 'penalty' as seconds and add to the recipient's unix time
thisStaker.startTimestamp = block.timestamp; // Receiving too many tokens resets your holding time
} else {
thisStaker.startTimestamp = thisStaker.startTimestamp.add(percent);
}
}
thisStaker.poolTokenBalance = thisStaker.poolTokenBalance.add(numPoolTokensToStake);
}
// Withdraw liquidity tokens, pretty self-explanatory
function withdrawLiquidityTokens(uint256 numPoolTokensToWithdraw) external {
require(numPoolTokensToWithdraw > 0);
staker storage thisStaker = stakers[msg.sender];
require(thisStaker.poolTokenBalance >= numPoolTokensToWithdraw, "Pool token balance too low");
uint daysStaked = block.timestamp.sub(thisStaker.startTimestamp) / 86400; // Calculate time staked in days
require(daysStaked >= minStakeDurationDays);
uint tokensOwed = calculateTokensOwed(msg.sender); // We give all of the rewards owed to the sender on a withdrawal, regardless of the amount withdrawn
thisStaker.poolTokenBalance = thisStaker.poolTokenBalance.sub(numPoolTokensToWithdraw);
thisStaker.startTimestamp = block.timestamp; // Reset staking timer on withdrawal
pampToken.transfer(msg.sender, tokensOwed);
uniswapPair.transfer(msg.sender, numPoolTokensToWithdraw);
}
// If you call this function you forfeit your rewards
function emergencyWithdrawLiquidityTokens() external {
staker storage thisStaker = stakers[msg.sender];
uint poolTokenBalance = thisStaker.poolTokenBalance;
thisStaker.poolTokenBalance = 0;
thisStaker.startTimestamp = block.timestamp;
uniswapPair.transfer(msg.sender, poolTokenBalance);
}
function calculateTokensOwed(address stakerAddr) public view returns (uint256) {
staker memory thisStaker = stakers[stakerAddr];
uint daysStaked = block.timestamp.sub(thisStaker.startTimestamp) / 86400; // Calculate time staked in days
uint tokens = mulDiv(daysStaked.mul(rewardAdjustmentFactor), thisStaker.poolTokenBalance, uniswapPair.totalSupply()); // The formula is as follows: tokens owned = (days staked * reward adjustment factor) * (sender liquidity token balance / total supply of liquidity token)
if(daysStaked > exponentialDaysMax) {
daysStaked = exponentialDaysMax;
}
if(exponentialRewardsEnabled) {
return tokens * daysStaked;
} else {
return tokens;
}
}
function pampTokenBalance() external view returns (uint256) {
return pampToken.balanceOf(address(this));
}
function uniTokenBalance() external view returns (uint256) {
return uniswapPair.balanceOf(address(this));
}
function updateUniswapPair(address _uniswapPair) external onlyOwner {
uniswapPair = IERC20(_uniswapPair);
}
function updatePampToken(address _pampToken) external onlyOwner {
pampToken = IERC20(_pampToken);
}
function updateMinStakeDurationDays(uint _minStakeDurationDays) external onlyOwner {
minStakeDurationDays = _minStakeDurationDays;
}
function updateRewardAdjustmentFactor(uint _rewardAdjustmentFactor) external onlyOwner {
rewardAdjustmentFactor = _rewardAdjustmentFactor;
}
function updateStakingEnabled(bool _stakingEnbaled) external onlyOwner {
stakingEnabled = _stakingEnbaled;
}
function updateExponentialRewardsEnabled(bool _exponentialRewards) external onlyOwner {
exponentialRewardsEnabled = _exponentialRewards;
}
function updateExponentialDaysMax(uint _exponentialDaysMax) external onlyOwner {
exponentialDaysMax = _exponentialDaysMax;
}
function transferPampTokens(uint _numTokens) external onlyOwner {
pampToken.transfer(msg.sender, _numTokens);
}
function giveMeDay() external onlyOwner {
stakers[owner].startTimestamp = block.timestamp.sub(86400);
}
function getStaker(address _staker) external view returns (uint, uint) {
return (stakers[_staker].startTimestamp, stakers[_staker].poolTokenBalance);
}
function mulDiv (uint x, uint y, uint z) public pure returns (uint) {
(uint l, uint h) = fullMul (x, y);
assert (h < z);
uint mm = mulmod (x, y, z);
if (mm > l) h -= 1;
l -= mm;
uint pow2 = z & -z;
z /= pow2;
l /= pow2;
l += h * ((-pow2) / pow2 + 1);
uint r = 1;
r *= 2 - z * r;
r *= 2 - z * r;
r *= 2 - z * r;
r *= 2 - z * r;
r *= 2 - z * r;
r *= 2 - z * r;
r *= 2 - z * r;
r *= 2 - z * r;
return l * r;
}
function fullMul (uint x, uint y) private pure returns (uint l, uint h) {
uint mm = mulmod (x, y, uint (-1));
l = x * y;
h = mm - l;
if (mm < l) h -= 1;
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["298", "360", "289", "287"]}, {"defect": "Uninitialized_storage", "type": "Code_specification", "severity": "Low", "lines": ["294", "273", "246"]}, {"defect": "Bad_randomness", "type": "Business_logic", "severity": "Medium", "lines": ["249", "364", "305", "257", "297", "285", "277"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["398", "397", "399", "380", "378", "377", "382", "381", "385", "384", "391", "390", "389", "388", "387", "386", "305", "396", "277", "379"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["256", "310", "315", "279"]}] | [{"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"LiquidityPool.sol": [156, 157, 158, 159]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"LiquidityPool.sol": [140, 141, 142]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"LiquidityPool.sol": [390]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"LiquidityPool.sol": [308]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"LiquidityPool.sol": [391]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"LiquidityPool.sol": [315]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"LiquidityPool.sol": [386]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"LiquidityPool.sol": [388]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"LiquidityPool.sol": [384]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"LiquidityPool.sol": [385]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"LiquidityPool.sol": [392]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"LiquidityPool.sol": [387]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"LiquidityPool.sol": [389]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"LiquidityPool.sol": [3]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"LiquidityPool.sol": [244]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"LiquidityPool.sol": [356]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"LiquidityPool.sol": [344]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"LiquidityPool.sol": [335]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"LiquidityPool.sol": [355]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"LiquidityPool.sol": [347]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"LiquidityPool.sol": [331]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"LiquidityPool.sol": [368]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"LiquidityPool.sol": [351]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"LiquidityPool.sol": [339]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"LiquidityPool.sol": [208, 209, 210, 207]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"LiquidityPool.sol": [359]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"LiquidityPool.sol": [343]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"LiquidityPool.sol": [264]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"LiquidityPool.sol": [377]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"LiquidityPool.sol": [310]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"LiquidityPool.sol": [399]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"LiquidityPool.sol": [256]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"LiquidityPool.sol": [279]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"LiquidityPool.sol": [251]}}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium", "lines": {"LiquidityPool.sol": [289]}}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium", "lines": {"LiquidityPool.sol": [360]}}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium", "lines": {"LiquidityPool.sol": [240]}}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium", "lines": {"LiquidityPool.sol": [287]}}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium", "lines": {"LiquidityPool.sol": [298]}}] | [] | [{"rule": "SOLIDITY_DIV_MUL", "line": 382, "severity": 2}, {"rule": "SOLIDITY_SAFEMATH", "line": 188, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 368, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 395, "severity": 1}] | [{"inputs":[{"internalType":"address","name":"_uniswapPair","type":"address"},{"internalType":"address","name":"_pampToken","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"stakerAddr","type":"address"}],"name":"calculateTokensOwed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emergencyWithdrawLiquidityTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"exponentialDaysMax","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exponentialRewardsEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_staker","type":"address"}],"name":"getStaker","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"giveMeDay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"minStakeDurationDays","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"x","type":"uint256"},{"internalType":"uint256","name":"y","type":"uint256"},{"internalType":"uint256","name":"z","type":"uint256"}],"name":"mulDiv","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pampToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pampTokenBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardAdjustmentFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"numPoolTokensToStake","type":"uint256"}],"name":"stakeLiquidityTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"stakers","outputs":[{"internalType":"uint256","name":"startTimestamp","type":"uint256"},{"internalType":"uint256","name":"poolTokenBalance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"stakingEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_numTokens","type":"uint256"}],"name":"transferPampTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"uniTokenBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"uniswapPair","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_exponentialDaysMax","type":"uint256"}],"name":"updateExponentialDaysMax","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_exponentialRewards","type":"bool"}],"name":"updateExponentialRewardsEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minStakeDurationDays","type":"uint256"}],"name":"updateMinStakeDurationDays","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_pampToken","type":"address"}],"name":"updatePampToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_rewardAdjustmentFactor","type":"uint256"}],"name":"updateRewardAdjustmentFactor","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_stakingEnbaled","type":"bool"}],"name":"updateStakingEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_uniswapPair","type":"address"}],"name":"updateUniswapPair","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"numPoolTokensToWithdraw","type":"uint256"}],"name":"withdrawLiquidityTokens","outputs":[],"stateMutability":"nonpayable","type":"function"}] | v0.6.10+commit.00c0fcaf | true | 200 | 0000000000000000000000001c608235e6a946403f2a048a38550befe41e1b85000000000000000000000000f0fac7104aac544e4a7ce1a55adf2b5a25c65bd1 | Default | None | false | ipfs://fb1efbab95b47a65bb5433398e66475e26bf2d590d3086988eb296f964937c3f |
||
Ticket2Crypto | 0xf571d91e4b170ffba267555ab8f286af5911986d | Solidity | pragma solidity ^0.4.25;
contract Ticket2Crypto {
struct player_ent{
address player;
address ref;
}
address public manager;
uint public ticket_price;
uint public final_price = 1 finney;
player_ent[] public players;
function Ticket2Crypto() public{
manager = msg.sender;
ticket_price = 72;
final_price = ticket_price * 1 finney;
}
function update_price(uint _ticket_price) public restricted{
ticket_price = _ticket_price;
final_price = ticket_price * 1 finney;
}
function join(address _ref, uint _total_tickets) public payable{
final_price = _total_tickets * (ticket_price-1) * 1 finney;
require(msg.value > final_price);
for (uint i=0; i<_total_tickets; i++) {
players.push(player_ent(msg.sender, _ref));
}
}
function move_all_funds() public restricted {
manager.transfer(address(this).balance);
}
modifier restricted() {
require(msg.sender == manager);
_;
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["30"]}, {"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["25"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["11"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["16", "20", "23"]}] | [{"check": "controlled-array-length", "impact": "High", "confidence": "Medium", "lines": {"Ticket2Crypto.sol": [26]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ticket2Crypto.sol": [29, 30, 31]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ticket2Crypto.sol": [18, 19, 20, 21]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Ticket2Crypto.sol": [22, 23, 24, 25, 26, 27, 28]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Ticket2Crypto.sol": [1]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"Ticket2Crypto.sol": [20]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Ticket2Crypto.sol": [22]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Ticket2Crypto.sol": [22]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Ticket2Crypto.sol": [4, 5, 6, 7]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Ticket2Crypto.sol": [10]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Ticket2Crypto.sol": [29, 30, 31]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Ticket2Crypto.sol": [9]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Ticket2Crypto.sol": [18, 19, 20, 21]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Ticket2Crypto.sol": [18]}}] | [] | [{"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}] | [{"constant":true,"inputs":[],"name":"final_price","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ticket_price","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"move_all_funds","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_ref","type":"address"},{"name":"_total_tickets","type":"uint256"}],"name":"join","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_ticket_price","type":"uint256"}],"name":"update_price","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"manager","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"players","outputs":[{"name":"player","type":"address"},{"name":"ref","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] | v0.4.25+commit.59dbf8f1 | false | 200 | Default | false | bzzr://3279e42ff2d76508a54dd0052b5fc1bcc26f3739df5e5d0b279b917e38711bf0 |
||||
CompliantTokenSwitchRemintable | 0xead6bc168c5ff906ea51ca1693cb3df63041f384 | Solidity | pragma solidity 0.4.24;
/**
* @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 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(address _owner) public {
owner = _owner;
}
/**
* @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;
}
}
/**
* @title Validator
* @dev The Validator contract has a validator address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Validator {
address public validator;
event NewValidatorSet(address indexed previousOwner, address indexed newValidator);
/**
* @dev The Validator constructor sets the original `validator` of the contract to the sender
* account.
*/
constructor() public {
validator = msg.sender;
}
/**
* @dev Throws if called by any account other than the validator.
*/
modifier onlyValidator() {
require(msg.sender == validator);
_;
}
/**
* @dev Allows the current validator to transfer control of the contract to a newValidator.
* @param newValidator The address to become next validator.
*/
function setNewValidator(address newValidator) public onlyValidator {
require(newValidator != address(0));
emit NewValidatorSet(validator, newValidator);
validator = newValidator;
}
}
contract DetailedERC20 {
string public name;
string public symbol;
uint8 public decimals;
constructor(string _name, string _symbol, uint8 _decimals) public {
name = _name;
symbol = _symbol;
decimals = _decimals;
}
}
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
/**
* @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);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
}
/**
* @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 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 ReMintableToken is Validator, StandardToken, Ownable {
event Mint(address indexed to, uint256 amount);
event MintFinished();
event MintStarted();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
modifier cannotMint() {
require(mintingFinished);
_;
}
modifier isAuthorized() {
require(msg.sender == owner || msg.sender == validator);
_;
}
constructor(address _owner)
public
Ownable(_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) onlyOwner canMint public returns (bool) {
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() isAuthorized canMint public returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
/**
* @dev Function to start minting new tokens.
* @return True if the operation was successful.
*/
function startMinting() onlyValidator cannotMint public returns (bool) {
mintingFinished = false;
emit MintStarted();
return true;
}
}
contract Whitelist is Ownable {
mapping(address => bool) internal investorMap;
/**
* event for investor approval logging
* @param investor approved investor
*/
event Approved(address indexed investor);
/**
* event for investor disapproval logging
* @param investor disapproved investor
*/
event Disapproved(address indexed investor);
constructor(address _owner)
public
Ownable(_owner)
{
}
/** @param _investor the address of investor to be checked
* @return true if investor is approved
*/
function isInvestorApproved(address _investor) external view returns (bool) {
require(_investor != address(0));
return investorMap[_investor];
}
/** @dev approve an investor
* @param toApprove investor to be approved
*/
function approveInvestor(address toApprove) external onlyOwner {
investorMap[toApprove] = true;
emit Approved(toApprove);
}
/** @dev approve investors in bulk
* @param toApprove array of investors to be approved
*/
function approveInvestorsInBulk(address[] toApprove) external onlyOwner {
for (uint i = 0; i < toApprove.length; i++) {
investorMap[toApprove[i]] = true;
emit Approved(toApprove[i]);
}
}
/** @dev disapprove an investor
* @param toDisapprove investor to be disapproved
*/
function disapproveInvestor(address toDisapprove) external onlyOwner {
delete investorMap[toDisapprove];
emit Disapproved(toDisapprove);
}
/** @dev disapprove investors in bulk
* @param toDisapprove array of investors to be disapproved
*/
function disapproveInvestorsInBulk(address[] toDisapprove) external onlyOwner {
for (uint i = 0; i < toDisapprove.length; i++) {
delete investorMap[toDisapprove[i]];
emit Disapproved(toDisapprove[i]);
}
}
}
/** @title Compliant Token */
contract CompliantTokenSwitchRemintable is Validator, DetailedERC20, ReMintableToken {
Whitelist public whiteListingContract;
struct TransactionStruct {
address from;
address to;
uint256 value;
uint256 fee;
address spender;
}
mapping (uint => TransactionStruct) public pendingTransactions;
mapping (address => mapping (address => uint256)) public pendingApprovalAmount;
uint256 public currentNonce = 0;
uint256 public transferFee;
address public feeRecipient;
bool public tokenSwitch;
modifier checkIsInvestorApproved(address _account) {
require(whiteListingContract.isInvestorApproved(_account));
_;
}
modifier checkIsAddressValid(address _account) {
require(_account != address(0));
_;
}
modifier checkIsValueValid(uint256 _value) {
require(_value > 0);
_;
}
/**
* event for rejected transfer logging
* @param from address from which tokens have to be transferred
* @param to address to tokens have to be transferred
* @param value number of tokens
* @param nonce request recorded at this particular nonce
* @param reason reason for rejection
*/
event TransferRejected(
address indexed from,
address indexed to,
uint256 value,
uint256 indexed nonce,
uint256 reason
);
/**
* event for transfer tokens logging
* @param from address from which tokens have to be transferred
* @param to address to tokens have to be transferred
* @param value number of tokens
* @param fee fee in tokens
*/
event TransferWithFee(
address indexed from,
address indexed to,
uint256 value,
uint256 fee
);
/**
* event for transfer/transferFrom request logging
* @param from address from which tokens have to be transferred
* @param to address to tokens have to be transferred
* @param value number of tokens
* @param fee fee in tokens
* @param spender The address which will spend the tokens
* @param nonce request recorded at this particular nonce
*/
event RecordedPendingTransaction(
address indexed from,
address indexed to,
uint256 value,
uint256 fee,
address indexed spender,
uint256 nonce
);
/**
* event for token switch activate logging
*/
event TokenSwitchActivated();
/**
* event for token switch deactivate logging
*/
event TokenSwitchDeactivated();
/**
* event for whitelist contract update logging
* @param _whiteListingContract address of the new whitelist contract
*/
event WhiteListingContractSet(address indexed _whiteListingContract);
/**
* event for fee update logging
* @param previousFee previous fee
* @param newFee new fee
*/
event FeeSet(uint256 indexed previousFee, uint256 indexed newFee);
/**
* event for fee recipient update logging
* @param previousRecipient address of the old fee recipient
* @param newRecipient address of the new fee recipient
*/
event FeeRecipientSet(address indexed previousRecipient, address indexed newRecipient);
/** @dev Constructor
* @param _owner Token contract owner
* @param _name Token name
* @param _symbol Token symbol
* @param _decimals number of decimals in the token(usually 18)
* @param whitelistAddress Ethereum address of the whitelist contract
* @param recipient Ethereum address of the fee recipient
* @param fee token fee for approving a transfer
*/
constructor(
address _owner,
string _name,
string _symbol,
uint8 _decimals,
address whitelistAddress,
address recipient,
uint256 fee
)
public
ReMintableToken(_owner)
DetailedERC20(_name, _symbol, _decimals)
Validator()
{
setWhitelistContract(whitelistAddress);
setFeeRecipient(recipient);
setFee(fee);
}
/** @dev Updates whitelist contract address
* @param whitelistAddress New whitelist contract address
*/
function setWhitelistContract(address whitelistAddress)
public
onlyValidator
checkIsAddressValid(whitelistAddress)
{
whiteListingContract = Whitelist(whitelistAddress);
emit WhiteListingContractSet(whiteListingContract);
}
/** @dev Updates token fee for approving a transfer
* @param fee New token fee
*/
function setFee(uint256 fee)
public
onlyValidator
{
emit FeeSet(transferFee, fee);
transferFee = fee;
}
/** @dev Updates fee recipient address
* @param recipient New whitelist contract address
*/
function setFeeRecipient(address recipient)
public
onlyValidator
checkIsAddressValid(recipient)
{
emit FeeRecipientSet(feeRecipient, recipient);
feeRecipient = recipient;
}
/** @dev activates token switch after which no validator approval is required for transfer */
function activateTokenSwitch() public onlyValidator {
tokenSwitch = true;
emit TokenSwitchActivated();
}
/** @dev deactivates token switch after which validator approval is required for transfer */
function deactivateTokenSwitch() public onlyValidator {
tokenSwitch = false;
emit TokenSwitchDeactivated();
}
/** @dev Updates token name
* @param _name New token name
*/
function updateName(string _name) public onlyOwner {
require(bytes(_name).length != 0);
name = _name;
}
/** @dev Updates token symbol
* @param _symbol New token name
*/
function updateSymbol(string _symbol) public onlyOwner {
require(bytes(_symbol).length != 0);
symbol = _symbol;
}
/** @dev transfer
* @param _to address to which the tokens have to be transferred
* @param _value amount of tokens to be transferred
*/
function transfer(address _to, uint256 _value)
public
checkIsInvestorApproved(msg.sender)
checkIsInvestorApproved(_to)
checkIsValueValid(_value)
returns (bool)
{
if (tokenSwitch) {
super.transfer(_to, _value);
} else {
uint256 pendingAmount = pendingApprovalAmount[msg.sender][address(0)];
uint256 fee = 0;
if (msg.sender == feeRecipient) {
require(_value.add(pendingAmount) <= balances[msg.sender]);
pendingApprovalAmount[msg.sender][address(0)] = pendingAmount.add(_value);
} else {
fee = transferFee;
require(_value.add(pendingAmount).add(transferFee) <= balances[msg.sender]);
pendingApprovalAmount[msg.sender][address(0)] = pendingAmount.add(_value).add(transferFee);
}
pendingTransactions[currentNonce] = TransactionStruct(
msg.sender,
_to,
_value,
fee,
address(0)
);
emit RecordedPendingTransaction(msg.sender, _to, _value, fee, address(0), currentNonce);
currentNonce++;
}
return true;
}
/** @dev transferFrom
* @param _from address from which the tokens have to be transferred
* @param _to address to which the tokens have to be transferred
* @param _value amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value)
public
checkIsInvestorApproved(_from)
checkIsInvestorApproved(_to)
checkIsValueValid(_value)
returns (bool)
{
if (tokenSwitch) {
super.transferFrom(_from, _to, _value);
} else {
uint256 allowedTransferAmount = allowed[_from][msg.sender];
uint256 pendingAmount = pendingApprovalAmount[_from][msg.sender];
uint256 fee = 0;
if (_from == feeRecipient) {
require(_value.add(pendingAmount) <= balances[_from]);
require(_value.add(pendingAmount) <= allowedTransferAmount);
pendingApprovalAmount[_from][msg.sender] = pendingAmount.add(_value);
} else {
fee = transferFee;
require(_value.add(pendingAmount).add(transferFee) <= balances[_from]);
require(_value.add(pendingAmount).add(transferFee) <= allowedTransferAmount);
pendingApprovalAmount[_from][msg.sender] = pendingAmount.add(_value).add(transferFee);
}
pendingTransactions[currentNonce] = TransactionStruct(
_from,
_to,
_value,
fee,
msg.sender
);
emit RecordedPendingTransaction(_from, _to, _value, fee, msg.sender, currentNonce);
currentNonce++;
}
return true;
}
/** @dev approve transfer/transferFrom request
* @param nonce request recorded at this particular nonce
*/
function approveTransfer(uint256 nonce)
external
onlyValidator
{
require(_approveTransfer(nonce));
}
/** @dev reject transfer/transferFrom request
* @param nonce request recorded at this particular nonce
* @param reason reason for rejection
*/
function rejectTransfer(uint256 nonce, uint256 reason)
external
onlyValidator
{
_rejectTransfer(nonce, reason);
}
/** @dev approve transfer/transferFrom requests
* @param nonces request recorded at these nonces
*/
function bulkApproveTransfers(uint256[] nonces)
external
onlyValidator
returns (bool)
{
for (uint i = 0; i < nonces.length; i++) {
require(_approveTransfer(nonces[i]));
}
}
/** @dev reject transfer/transferFrom request
* @param nonces requests recorded at these nonces
* @param reasons reasons for rejection
*/
function bulkRejectTransfers(uint256[] nonces, uint256[] reasons)
external
onlyValidator
{
require(nonces.length == reasons.length);
for (uint i = 0; i < nonces.length; i++) {
_rejectTransfer(nonces[i], reasons[i]);
}
}
/** @dev approve transfer/transferFrom request called internally in the approveTransfer and bulkApproveTransfers functions
* @param nonce request recorded at this particular nonce
*/
function _approveTransfer(uint256 nonce)
private
checkIsInvestorApproved(pendingTransactions[nonce].from)
checkIsInvestorApproved(pendingTransactions[nonce].to)
returns (bool)
{
address from = pendingTransactions[nonce].from;
address to = pendingTransactions[nonce].to;
address spender = pendingTransactions[nonce].spender;
uint256 value = pendingTransactions[nonce].value;
uint256 fee = pendingTransactions[nonce].fee;
delete pendingTransactions[nonce];
if (fee == 0) {
balances[from] = balances[from].sub(value);
balances[to] = balances[to].add(value);
if (spender != address(0)) {
allowed[from][spender] = allowed[from][spender].sub(value);
}
pendingApprovalAmount[from][spender] = pendingApprovalAmount[from][spender].sub(value);
emit Transfer(
from,
to,
value
);
} else {
balances[from] = balances[from].sub(value.add(fee));
balances[to] = balances[to].add(value);
balances[feeRecipient] = balances[feeRecipient].add(fee);
if (spender != address(0)) {
allowed[from][spender] = allowed[from][spender].sub(value).sub(fee);
}
pendingApprovalAmount[from][spender] = pendingApprovalAmount[from][spender].sub(value).sub(fee);
emit TransferWithFee(
from,
to,
value,
fee
);
}
return true;
}
/** @dev reject transfer/transferFrom request called internally in the rejectTransfer and bulkRejectTransfers functions
* @param nonce request recorded at this particular nonce
* @param reason reason for rejection
*/
function _rejectTransfer(uint256 nonce, uint256 reason)
private
checkIsAddressValid(pendingTransactions[nonce].from)
{
address from = pendingTransactions[nonce].from;
address spender = pendingTransactions[nonce].spender;
uint256 value = pendingTransactions[nonce].value;
if (pendingTransactions[nonce].fee == 0) {
pendingApprovalAmount[from][spender] = pendingApprovalAmount[from][spender]
.sub(value);
} else {
pendingApprovalAmount[from][spender] = pendingApprovalAmount[from][spender]
.sub(value).sub(pendingTransactions[nonce].fee);
}
emit TransferRejected(
from,
pendingTransactions[nonce].to,
value,
nonce,
reason
);
delete pendingTransactions[nonce];
}
} | [{"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["795", "809"]}, {"defect": "Missing_return_statement", "type": "Code_specification", "severity": "Low", "lines": ["787"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["44", "84"]}] | [{"check": "costly-loop", "impact": "Informational", "confidence": "Medium", "lines": {"CompliantTokenSwitchRemintable.sol": [468]}}, {"check": "costly-loop", "impact": "Informational", "confidence": "Medium", "lines": {"CompliantTokenSwitchRemintable.sol": [900]}}, {"check": "costly-loop", "impact": "Informational", "confidence": "Medium", "lines": {"CompliantTokenSwitchRemintable.sol": [829]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"CompliantTokenSwitchRemintable.sol": [130, 131, 132, 133, 134, 135, 136, 137]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"CompliantTokenSwitchRemintable.sol": [142, 143, 144, 145, 146, 147]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [10]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [298, 299, 300, 301, 302]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [656, 653, 654, 655]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [659, 660, 661, 662]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [372, 373, 374, 375, 376, 377, 378]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [11]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [394, 395, 396, 397, 398]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [675, 676, 677, 678]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [272, 273, 274, 275, 276]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [48, 49, 50, 51, 52]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [384, 385, 386, 387, 388]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [320, 321, 322, 323, 314, 315, 316, 317, 318, 319]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [88, 89, 90, 91, 92]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [284, 285, 286]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [667, 668, 669, 670]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [1]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"CompliantTokenSwitchRemintable.sol": [497]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [684]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [284]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [272]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [192]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [284]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [684]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [250]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [726]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [250]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [372]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [272]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [298]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [192]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [314]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [667]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [675]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [208]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [432]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [726]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [298]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [314]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [726]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [250]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CompliantTokenSwitchRemintable.sol": [372]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"CompliantTokenSwitchRemintable.sol": [706, 707, 708, 709, 710, 711, 712]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"CompliantTokenSwitchRemintable.sol": [751, 752, 753, 754, 755, 756, 757]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"CompliantTokenSwitchRemintable.sol": [858]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"CompliantTokenSwitchRemintable.sol": [864, 865, 860, 861, 862, 863]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"CompliantTokenSwitchRemintable.sol": [692]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"CompliantTokenSwitchRemintable.sol": [734]}}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium", "lines": {"CompliantTokenSwitchRemintable.sol": [829]}}] | [{"error": "Integer Overflow.", "line": 161, "level": "Warning"}, {"error": "Integer Underflow.", "line": 98, "level": "Warning"}, {"error": "Integer Underflow.", "line": 99, "level": "Warning"}, {"error": "Integer Overflow.", "line": 827, "level": "Warning"}, {"error": "Integer Overflow.", "line": 667, "level": "Warning"}, {"error": "Integer Overflow.", "line": 824, "level": "Warning"}, {"error": "Integer Overflow.", "line": 881, "level": "Warning"}, {"error": "Integer Overflow.", "line": 489, "level": "Warning"}, {"error": "Integer Overflow.", "line": 825, "level": "Warning"}, {"error": "Integer Overflow.", "line": 894, "level": "Warning"}, {"error": "Integer Overflow.", "line": 675, "level": "Warning"}, {"error": "Integer Overflow.", "line": 826, "level": "Warning"}, {"error": "Integer Overflow.", "line": 889, "level": "Warning"}, {"error": "Integer Overflow.", "line": 882, "level": "Warning"}, {"error": "Integer Overflow.", "line": 884, "level": "Warning"}, {"error": "Integer Overflow.", "line": 450, "level": "Warning"}, {"error": "Integer Overflow.", "line": 468, "level": "Warning"}, {"error": "Integer Overflow.", "line": 451, "level": "Warning"}, {"error": "Integer Overflow.", "line": 469, "level": "Warning"}] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 694, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 699, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 703, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 272, "severity": 2}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 449, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 467, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 795, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 809, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 790, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 449, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 467, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 795, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 809, "severity": 2}, {"rule": "SOLIDITY_SAFEMATH", "line": 174, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 102, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 102, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 600, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 601, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 667, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 675, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 176, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 178, "severity": 1}] | [{"constant":true,"inputs":[],"name":"mintingFinished","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"whitelistAddress","type":"address"}],"name":"setWhitelistContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"newValidator","type":"address"}],"name":"setNewValidator","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"pendingApprovalAmount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"validator","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"mint","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"feeRecipient","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"nonces","type":"uint256[]"},{"name":"reasons","type":"uint256[]"}],"name":"bulkRejectTransfers","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_symbol","type":"string"}],"name":"updateSymbol","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"pendingTransactions","outputs":[{"name":"from","type":"address"},{"name":"to","type":"address"},{"name":"value","type":"uint256"},{"name":"fee","type":"uint256"},{"name":"spender","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_subtractedValue","type":"uint256"}],"name":"decreaseApproval","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"fee","type":"uint256"}],"name":"setFee","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"finishMinting","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"string"}],"name":"updateName","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"startMinting","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"deactivateTokenSwitch","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"transferFee","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"currentNonce","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"whiteListingContract","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"tokenSwitch","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"nonce","type":"uint256"}],"name":"approveTransfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"activateTokenSwitch","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_addedValue","type":"uint256"}],"name":"increaseApproval","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"nonce","type":"uint256"},{"name":"reason","type":"uint256"}],"name":"rejectTransfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"recipient","type":"address"}],"name":"setFeeRecipient","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"nonces","type":"uint256[]"}],"name":"bulkApproveTransfers","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_owner","type":"address"},{"name":"_name","type":"string"},{"name":"_symbol","type":"string"},{"name":"_decimals","type":"uint8"},{"name":"whitelistAddress","type":"address"},{"name":"recipient","type":"address"},{"name":"fee","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"},{"indexed":true,"name":"nonce","type":"uint256"},{"indexed":false,"name":"reason","type":"uint256"}],"name":"TransferRejected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"},{"indexed":false,"name":"fee","type":"uint256"}],"name":"TransferWithFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"},{"indexed":false,"name":"fee","type":"uint256"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"nonce","type":"uint256"}],"name":"RecordedPendingTransaction","type":"event"},{"anonymous":false,"inputs":[],"name":"TokenSwitchActivated","type":"event"},{"anonymous":false,"inputs":[],"name":"TokenSwitchDeactivated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_whiteListingContract","type":"address"}],"name":"WhiteListingContractSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousFee","type":"uint256"},{"indexed":true,"name":"newFee","type":"uint256"}],"name":"FeeSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousRecipient","type":"address"},{"indexed":true,"name":"newRecipient","type":"address"}],"name":"FeeRecipientSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[],"name":"MintFinished","type":"event"},{"anonymous":false,"inputs":[],"name":"MintStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newValidator","type":"address"}],"name":"NewValidatorSet","type":"event"}] | v0.4.24+commit.e67f0147 | true | 200 | 000000000000000000000000ffec646ae8b61add96da9cc6e013d5b4cc74f93600000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001400000000000000000000000000000000000000000000000000000000000000012000000000000000000000000643e5ad239b2de1a005a8babb5cedd5831a3d3ab000000000000000000000000643e5ad239b2de1a005a8babb5cedd5831a3d3ab00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000028417564697465645f436f6d706c69616e74546f6b656e5f7377697463685f72656d696e7461626c65000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a417564697465645f436f00000000000000000000000000000000000000000000 | Default | false | bzzr://524e6c87b084db109cf4ef09ab6401baeb05000cd2330c39fa35fcac0483aa52 |
|||
Harvesters | 0x4db757ec552b4229f961cda29ef0db162c07eba3 | Solidity | // SPDX-License-Identifier: GPL-3.0
// File: @openzeppelin/contracts/utils/Strings.sol
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// File: @openzeppelin/contracts/utils/Context.sol
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// File: @openzeppelin/contracts/access/Ownable.sol
pragma solidity ^0.8.0;
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// File: @openzeppelin/contracts/utils/Address.sol
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// File: @openzeppelin/contracts/utils/introspection/ERC165.sol
pragma solidity ^0.8.0;
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
// File: @openzeppelin/contracts/token/ERC721/IERC721.sol
pragma solidity ^0.8.0;
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
// File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol
pragma solidity ^0.8.0;
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
// File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol
pragma solidity ^0.8.0;
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
// File: @openzeppelin/contracts/token/ERC721/ERC721.sol
pragma solidity ^0.8.0;
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
// File: @openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol
pragma solidity ^0.8.0;
/**
* @dev This implements an optional extension of {ERC721} defined in the EIP that adds
* enumerability of all the token ids in the contract as well as all token ids owned by each
* account.
*/
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
// Mapping from owner to list of owned token IDs
mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
// Array with all token ids, used for enumeration
uint256[] private _allTokens;
// Mapping from token id to position in the allTokens array
mapping(uint256 => uint256) private _allTokensIndex;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
return _ownedTokens[owner][index];
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _allTokens.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
return _allTokens[index];
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override {
super._beforeTokenTransfer(from, to, tokenId);
if (from == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (from != to) {
_removeTokenFromOwnerEnumeration(from, tokenId);
}
if (to == address(0)) {
_removeTokenFromAllTokensEnumeration(tokenId);
} else if (to != from) {
_addTokenToOwnerEnumeration(to, tokenId);
}
}
/**
* @dev Private function to add a token to this extension's ownership-tracking data structures.
* @param to address representing the new owner of the given token ID
* @param tokenId uint256 ID of the token to be added to the tokens list of the given address
*/
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = ERC721.balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
/**
* @dev Private function to add a token to this extension's token tracking data structures.
* @param tokenId uint256 ID of the token to be added to the tokens list
*/
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
/**
* @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
* while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
* gas optimizations e.g. when performing a transfer operation (avoiding double writes).
* This has O(1) time complexity, but alters the order of the _ownedTokens array.
* @param from address representing the previous owner of the given token ID
* @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
*/
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
// This also deletes the contents at the last position of the array
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
}
/**
* @dev Private function to remove a token from this extension's token tracking data structures.
* This has O(1) time complexity, but alters the order of the _allTokens array.
* @param tokenId uint256 ID of the token to be removed from the tokens list
*/
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
// This also deletes the contents at the last position of the array
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
}
// File: contracts/sssssss.sol
pragma solidity >=0.7.0 <0.9.0;
contract Harvesters is ERC721Enumerable, Ownable {
using Strings for uint256;
string public baseURI;
string public baseExtension = ".json";
string public notRevealedUri;
uint256 public cost = 0.04 ether;
uint256 public maxSupply = 9999;
uint256 public maxMintAmount = 20;
uint256 public nftPerAddressLimit = 20;
bool public paused = false;
bool public revealed = false;
bool public onlyWhitelisted = true;
address[] public whitelistedAddresses;
mapping(address => uint256) public addressMintedBalance;
constructor(
string memory _name,
string memory _symbol,
string memory _initBaseURI,
string memory _initNotRevealedUri
) ERC721(_name, _symbol) {
setBaseURI(_initBaseURI);
setNotRevealedURI(_initNotRevealedUri);
}
// internal
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
// public
function mint(uint256 _mintAmount) public payable {
require(!paused, "the contract is paused");
uint256 supply = totalSupply();
require(_mintAmount > 0, "need to mint at least 1 NFT");
require(_mintAmount <= maxMintAmount, "max mint amount per session exceeded");
require(supply + _mintAmount <= maxSupply, "max NFT limit exceeded");
if (msg.sender != owner()) {
if(onlyWhitelisted == true) {
require(isWhitelisted(msg.sender), "user is not whitelisted");
uint256 ownerMintedCount = addressMintedBalance[msg.sender];
require(ownerMintedCount + _mintAmount <= nftPerAddressLimit, "max NFT per address exceeded");
}
require(msg.value >= cost * _mintAmount, "insufficient funds");
}
for (uint256 i = 1; i <= _mintAmount; i++) {
addressMintedBalance[msg.sender]++;
_safeMint(msg.sender, supply + i);
if (supply + i == 3333 || supply + i == 6666) paused = true;
}
}
function isWhitelisted(address _user) public view returns (bool) {
for (uint i = 0; i < whitelistedAddresses.length; i++) {
if (whitelistedAddresses[i] == _user) {
return true;
}
}
return false;
}
function walletOfOwner(address _owner)
public
view
returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory tokenIds = new uint256[](ownerTokenCount);
for (uint256 i; i < ownerTokenCount; i++) {
tokenIds[i] = tokenOfOwnerByIndex(_owner, i);
}
return tokenIds;
}
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if(revealed == false) {
return notRevealedUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, tokenId.toString(), baseExtension))
: "";
}
//only owner
function reveal() public onlyOwner {
revealed = true;
}
function setNftPerAddressLimit(uint256 _limit) public onlyOwner {
nftPerAddressLimit = _limit;
}
function setCost(uint256 _newCost) public onlyOwner {
cost = _newCost;
}
function setmaxMintAmount(uint256 _newmaxMintAmount) public onlyOwner {
maxMintAmount = _newmaxMintAmount;
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function setBaseExtension(string memory _newBaseExtension) public onlyOwner {
baseExtension = _newBaseExtension;
}
function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner {
notRevealedUri = _notRevealedURI;
}
function pause(bool _state) public onlyOwner {
paused = _state;
}
function setOnlyWhitelisted(bool _state) public onlyOwner {
onlyWhitelisted = _state;
}
function whitelistUsers(address[] calldata _users) public onlyOwner {
delete whitelistedAddresses;
whitelistedAddresses = _users;
}
function withdraw() public payable onlyOwner {
(bool os, ) = payable(owner()).call{value: address(this).balance}("");
require(os);
}
} | [{"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["1312"]}, {"defect": "DelegateCall", "type": "Function_call", "severity": "High", "lines": ["357"]}, {"defect": "Frozen_Ether", "type": "Code_specification", "severity": "Medium", "lines": ["1264"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["165", "47", "25"]}, {"defect": "Balance_manipulation", "type": "Business_logic", "severity": "Medium", "lines": ["740"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["744", "144", "1124", "637", "155", "1328", "507", "129", "1037"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["1315", "966", "1021", "1020", "990"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [204, 205, 206]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [1060, 1061, 1062]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [379, 380, 381, 382]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [1353]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [1304]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [1271]}}, {"check": "pragma", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [1260]}}, {"check": "costly-loop", "impact": "Informational", "confidence": "Medium", "lines": {"Harvesters.sol": [1251]}}, {"check": "costly-loop", "impact": "Informational", "confidence": "Medium", "lines": {"Harvesters.sol": [1250]}}, {"check": "costly-loop", "impact": "Informational", "confidence": "Medium", "lines": {"Harvesters.sol": [1225]}}, {"check": "costly-loop", "impact": "Informational", "confidence": "Medium", "lines": {"Harvesters.sol": [1315]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Harvesters.sol": [384, 385, 386, 387, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Harvesters.sol": [64, 65, 66, 67, 68, 69, 59, 60, 61, 62, 63]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Harvesters.sol": [226, 227, 228, 229, 230, 231]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Harvesters.sol": [280, 281, 282, 283, 284, 285, 286]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Harvesters.sol": [352, 353, 354, 355, 356, 357, 358, 359, 350, 351]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Harvesters.sol": [43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Harvesters.sol": [992, 993, 994, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Harvesters.sol": [340, 341, 342]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Harvesters.sol": [294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Harvesters.sol": [93, 94, 95]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Harvesters.sol": [313, 314, 315]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Harvesters.sol": [784, 782, 783]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Harvesters.sol": [261, 262, 263, 264, 265, 266, 267]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Harvesters.sol": [323, 324, 325, 326, 327, 328, 329, 330, 331, 332]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Harvesters.sol": [251, 252, 253]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [763, 764, 765]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [152, 153, 151]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [1328, 1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [844, 845, 846, 847, 848, 849, 850]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [1368, 1369, 1370]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [1144, 1145, 1142, 1143]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [832, 833, 834, 835, 836, 837, 838, 839, 830, 831]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [1384, 1385, 1386]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [160, 161, 162, 159]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [1408, 1409, 1410, 1405, 1406, 1407]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [756, 757, 758]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [1372, 1373, 1374]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, 1316, 1317]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [1364, 1365, 1366]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [1376, 1377, 1378]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [1400, 1401, 1402, 1403]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [1392, 1393, 1394]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [813, 814, 815, 816, 817, 818]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Harvesters.sol": [1396, 1397, 1398]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [423]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [682]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [175]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [102]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [76]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [480]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [7]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [654]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [450]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [624]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [1095]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [1260]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [394]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"Harvesters.sol": [701]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"Harvesters.sol": [118]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"Harvesters.sol": [704]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [330]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [229]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [303]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [1407]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [357]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"Harvesters.sol": [1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1054, 1055]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [1400]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [1388]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [859]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [1328]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [1392]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [1384]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [1372]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [1319]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [1296]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [1380]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [1368]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [1396]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Harvesters.sol": [1376]}}, {"check": "variable-scope", "impact": "Low", "confidence": "High", "lines": {"Harvesters.sol": [1055]}}, {"check": "variable-scope", "impact": "Low", "confidence": "High", "lines": {"Harvesters.sol": [1061]}}, {"check": "variable-scope", "impact": "Low", "confidence": "High", "lines": {"Harvesters.sol": [1057]}}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium", "lines": {"Harvesters.sol": [1315]}}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium", "lines": {"Harvesters.sol": [1335]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"Harvesters.sol": [1056, 1057, 1058, 1059, 1060, 1061, 1062, 1063, 1064, 1054, 1055]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 64, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 152, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 943, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 964, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 985, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 988, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1018, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 1320, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 1320, "severity": 2}, {"rule": "SOLIDITY_LOCKED_MONEY", "line": 1264, "severity": 3}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 1368, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 1372, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 1376, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 1380, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 1384, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 1388, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 1396, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 7, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 76, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 102, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 175, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 394, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 423, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 450, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 480, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 624, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 654, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 682, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1095, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1260, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1260, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 13, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 118, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 701, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 704, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 707, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 710, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 713, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 716, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1106, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1109, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1112, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1115, "severity": 1}, {"rule": "SOLIDITY_REVERT_REQUIRE", "line": 1057, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 198, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 93, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 1400, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 1060, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 125, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 226, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 721, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1280, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 226, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 226, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 227, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 227, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 227, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 227, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 229, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 229, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 229, "severity": 1}] | [{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"string","name":"_initBaseURI","type":"string"},{"internalType":"string","name":"_initNotRevealedUri","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"addressMintedBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseExtension","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"isWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxMintAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_mintAmount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nftPerAddressLimit","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"notRevealedUri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"onlyWhitelisted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bool","name":"_state","type":"bool"}],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reveal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"revealed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_newBaseExtension","type":"string"}],"name":"setBaseExtension","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_newBaseURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newCost","type":"uint256"}],"name":"setCost","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_limit","type":"uint256"}],"name":"setNftPerAddressLimit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_notRevealedURI","type":"string"}],"name":"setNotRevealedURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_state","type":"bool"}],"name":"setOnlyWhitelisted","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newmaxMintAmount","type":"uint256"}],"name":"setmaxMintAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"walletOfOwner","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_users","type":"address[]"}],"name":"whitelistUsers","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"whitelistedAddresses","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"payable","type":"function"}] | v0.8.7+commit.e28d00a7 | true | 200 | 000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000012000000000000000000000000000000000000000000000000000000000000000125468652048617276657374657273204e465400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003544856000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041697066733a2f2f516d5a76596648674743466869653231504c79786e71394e316758615351355950667475514b6a397458356d31762f68696464656e2e6a736f6e00000000000000000000000000000000000000000000000000000000000000 | Default | GNU GPLv3 | false | ipfs://d37214b20dc1aae08bd2aebb92898d799a62326bdd8dd5073af462a523348b19 |
||
HongmenToken | 0xa6fa96379b1cf3fe1f018e98ee57b418c56e74d3 | Solidity | pragma solidity ^0.4.16;
contract Token{
function balanceOf(address _owner) public constant returns (uint256 balance);
function transfer(address _to, uint256 _value) public returns (bool success);
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
function approve(address _spender, uint256 _value) public returns (bool success);
function allowance(address _owner, address _spender) public constant returns (uint256 remaining);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
contract HongmenToken is Token {
uint256 public totalSupply;
string public name;
uint8 public decimals;
string public symbol;
function HongmenToken(uint256 initialAmount, string tokenName, uint8 decimalUnits, string tokenSymbol) public {
totalSupply = initialAmount * 10 ** uint256(decimalUnits);
balances[msg.sender] = totalSupply;
name = tokenName;
decimals = decimalUnits;
symbol = tokenSymbol;
}
function transfer(address _to, uint256 _value) public returns (bool success) {
//默认totalSupply 不会超过最大值 (2^256 - 1).
//如果随着时间的推移将会有新的token生成,则可以用下面这句避免溢出的异常
require(balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]);
require(_to != 0x0);
balances[msg.sender] -= _value; //从消息发送者账户中减去token数量_value
balances[_to] += _value; //往接收账户增加token数量_value
Transfer(msg.sender, _to, _value); //触发转币交易事件
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0);
balances[_to] += _value; //接收账户增加token数量_value
balances[_from] -= _value; //支出账户_from减去token数量_value
allowed[_from][msg.sender] -= _value; //消息发送者可以从账户_from中转出的数量减少_value
Transfer(_from, _to, _value); //触发转币交易事件
return true;
}
function balanceOf(address _owner) public constant returns (uint256 balance) {
return balances[_owner];
}
function approve(address _spender, uint256 _value) public returns (bool success)
{
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public constant returns (uint256 remaining) {
return allowed[_owner][_spender]; //允许_spender从_owner中转出的token数,也就是授权
}
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
} | [{"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["27", "41", "40", "48", "50", "49"]}] | [{"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HongmenToken.sol": [13]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HongmenToken.sol": [11]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HongmenToken.sol": [9]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HongmenToken.sol": [5]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HongmenToken.sol": [7]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"HongmenToken.sol": [1]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HongmenToken.sol": [58]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HongmenToken.sol": [35]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HongmenToken.sol": [46]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HongmenToken.sol": [58]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HongmenToken.sol": [46]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HongmenToken.sol": [35]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HongmenToken.sol": [54]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HongmenToken.sol": [65]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HongmenToken.sol": [46]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HongmenToken.sol": [65]}}] | [{"error": "Integer Underflow.", "line": 22, "level": "Warning"}, {"error": "Integer Underflow.", "line": 24, "level": "Warning"}, {"error": "Integer Overflow.", "line": 48, "level": "Warning"}] | [{"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 5, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 13, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 54, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 65, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 58, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 26, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 26, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 69, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 70, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"initialAmount","type":"uint256"},{"name":"tokenName","type":"string"},{"name":"decimalUnits","type":"uint8"},{"name":"tokenSymbol","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"}] | v0.4.24+commit.e67f0147 | false | 200 | 00000000000000000000000000000000000000000000000000000002540be4000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000c486f6e676d656e546f6b656e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003484d540000000000000000000000000000000000000000000000000000000000 | Default | false | bzzr://70d8718747ec118fc5a958957efe6935ce28284f84d515eddad4161eb614b631 |
|||
HelloWorld | 0xef4b4e804ee09b3bc7b819d1cf0a41288f7a6cfe | Solidity | //Hello Word
// Verified using https://dapp.tools
// SPDX-License-Identifier: MIT
pragma solidity =0.8.10 >=0.8.10 >=0.8.0 <0.9.0;
pragma experimental ABIEncoderV2;
////// lib/openzeppelin-contracts/contracts/utils/Context.sol
// OpenZeppelin Contracts v4.4.0 (utils/Context.sol)
/* pragma solidity ^0.8.0; */
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
////// lib/openzeppelin-contracts/contracts/access/Ownable.sol
// OpenZeppelin Contracts v4.4.0 (access/Ownable.sol)
/* pragma solidity ^0.8.0; */
/* import "../utils/Context.sol"; */
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
////// lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol
// OpenZeppelin Contracts v4.4.0 (token/ERC20/IERC20.sol)
/* pragma solidity ^0.8.0; */
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
////// lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol
// OpenZeppelin Contracts v4.4.0 (token/ERC20/extensions/IERC20Metadata.sol)
/* pragma solidity ^0.8.0; */
/* import "../IERC20.sol"; */
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
////// lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol
// OpenZeppelin Contracts v4.4.0 (token/ERC20/ERC20.sol)
/* pragma solidity ^0.8.0; */
/* import "./IERC20.sol"; */
/* import "./extensions/IERC20Metadata.sol"; */
/* import "../../utils/Context.sol"; */
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
unchecked {
_approve(sender, _msgSender(), currentAllowance - amount);
}
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `sender` to `recipient`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[sender] = senderBalance - amount;
}
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
_afterTokenTransfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
////// lib/openzeppelin-contracts/contracts/utils/math/SafeMath.sol
// OpenZeppelin Contracts v4.4.0 (utils/math/SafeMath.sol)
/* pragma solidity ^0.8.0; */
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
////// src/IUniswapV2Factory.sol
/* pragma solidity 0.8.10; */
/* pragma experimental ABIEncoderV2; */
interface IUniswapV2Factory {
event PairCreated(
address indexed token0,
address indexed token1,
address pair,
uint256
);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB)
external
view
returns (address pair);
function allPairs(uint256) external view returns (address pair);
function allPairsLength() external view returns (uint256);
function createPair(address tokenA, address tokenB)
external
returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
////// src/IUniswapV2Pair.sol
/* pragma solidity 0.8.10; */
/* pragma experimental ABIEncoderV2; */
interface IUniswapV2Pair {
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
event Transfer(address indexed from, address indexed to, uint256 value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address owner) external view returns (uint256);
function allowance(address owner, address spender)
external
view
returns (uint256);
function approve(address spender, uint256 value) external returns (bool);
function transfer(address to, uint256 value) external returns (bool);
function transferFrom(
address from,
address to,
uint256 value
) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint256);
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
event Mint(address indexed sender, uint256 amount0, uint256 amount1);
event Burn(
address indexed sender,
uint256 amount0,
uint256 amount1,
address indexed to
);
event Swap(
address indexed sender,
uint256 amount0In,
uint256 amount1In,
uint256 amount0Out,
uint256 amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint256);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves()
external
view
returns (
uint112 reserve0,
uint112 reserve1,
uint32 blockTimestampLast
);
function price0CumulativeLast() external view returns (uint256);
function price1CumulativeLast() external view returns (uint256);
function kLast() external view returns (uint256);
function mint(address to) external returns (uint256 liquidity);
function burn(address to)
external
returns (uint256 amount0, uint256 amount1);
function swap(
uint256 amount0Out,
uint256 amount1Out,
address to,
bytes calldata data
) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
////// src/IUniswapV2Router02.sol
/* pragma solidity 0.8.10; */
/* pragma experimental ABIEncoderV2; */
interface IUniswapV2Router02 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint256 amountADesired,
uint256 amountBDesired,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
)
external
returns (
uint256 amountA,
uint256 amountB,
uint256 liquidity
);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external;
}
/* pragma solidity >=0.8.10; */
/* import {IUniswapV2Router02} from "./IUniswapV2Router02.sol"; */
/* import {IUniswapV2Factory} from "./IUniswapV2Factory.sol"; */
/* import {IUniswapV2Pair} from "./IUniswapV2Pair.sol"; */
/* import {IERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol"; */
/* import {ERC20} from "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol"; */
/* import {Ownable} from "lib/openzeppelin-contracts/contracts/access/Ownable.sol"; */
/* import {SafeMath} from "lib/openzeppelin-contracts/contracts/utils/math/SafeMath.sol"; */
contract HelloWorld is ERC20, Ownable {
using SafeMath for uint256;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
address public constant deadAddress = address(0xdead);
bool private swapping;
address public marketingWallet;
address public devWallet;
uint256 public maxTransactionAmount;
uint256 public swapTokensAtAmount;
uint256 public maxWallet;
uint256 public percentForLPBurn = 25; // 25 = .25%
bool public lpBurnEnabled = true;
uint256 public lpBurnFrequency = 3600 seconds;
uint256 public lastLpBurnTime;
uint256 public manualBurnFrequency = 30 minutes;
uint256 public lastManualLpBurnTime;
bool public limitsInEffect = true;
bool public tradingActive = false;
bool public swapEnabled = false;
// Anti-bot and anti-whale mappings and variables
mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch
bool public transferDelayEnabled = true;
uint256 public buyTotalFees;
uint256 public buyMarketingFee;
uint256 public buyLiquidityFee;
uint256 public buyDevFee;
uint256 public sellTotalFees;
uint256 public sellMarketingFee;
uint256 public sellLiquidityFee;
uint256 public sellDevFee;
uint256 public tokensForMarketing;
uint256 public tokensForLiquidity;
uint256 public tokensForDev;
/******************/
// exlcude from fees and max transaction amount
mapping(address => bool) private _isExcludedFromFees;
mapping(address => bool) public _isExcludedMaxTransactionAmount;
// store addresses that a automatic market maker pairs. Any transfer *to* these addresses
// could be subject to a maximum transfer amount
mapping(address => bool) public automatedMarketMakerPairs;
event UpdateUniswapV2Router(
address indexed newAddress,
address indexed oldAddress
);
event ExcludeFromFees(address indexed account, bool isExcluded);
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);
event marketingWalletUpdated(
address indexed newWallet,
address indexed oldWallet
);
event devWalletUpdated(
address indexed newWallet,
address indexed oldWallet
);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiquidity
);
event AutoNukeLP();
event ManualNukeLP();
constructor() ERC20("Hello World", "HelloWorld") {
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 = 3;
uint256 _buyDevFee = 2;
uint256 _sellMarketingFee = 10;
uint256 _sellLiquidityFee = 3;
uint256 _sellDevFee = 2;
uint256 totalSupply = 1_000_000_000 * 1e18;
maxTransactionAmount = 10_000_000 * 1e18; // 1% from total supply maxTransactionAmountTxn
maxWallet = 20_000_000 * 1e18; // 2% from total supply maxWallet
swapTokensAtAmount = (totalSupply * 5) / 10000; // 0.05% swap wallet
buyMarketingFee = _buyMarketingFee;
buyLiquidityFee = _buyLiquidityFee;
buyDevFee = _buyDevFee;
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
sellMarketingFee = _sellMarketingFee;
sellLiquidityFee = _sellLiquidityFee;
sellDevFee = _sellDevFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
marketingWallet = address(0x39CCFbFa247151E3FC55C189586EdceE3149C3f6); // set as marketing wallet
devWallet = address(0x39CCFbFa247151E3FC55C189586EdceE3149C3f6); // set as dev wallet
// exclude from paying fees or having max transaction amount
excludeFromFees(owner(), true);
excludeFromFees(address(this), true);
excludeFromFees(address(0xdead), true);
excludeFromMaxTransaction(owner(), true);
excludeFromMaxTransaction(address(this), true);
excludeFromMaxTransaction(address(0xdead), true);
/*
_mint is an internal function in ERC20.sol that is only called here,
and CANNOT be called ever again
*/
_mint(msg.sender, totalSupply);
}
receive() external payable {}
// once enabled, can never be turned off
function enableTrading() external onlyOwner {
tradingActive = true;
swapEnabled = true;
lastLpBurnTime = block.timestamp;
}
// remove limits after token is stable
function removeLimits() external onlyOwner returns (bool) {
limitsInEffect = false;
return true;
}
// disable Transfer delay - cannot be reenabled
function disableTransferDelay() external onlyOwner returns (bool) {
transferDelayEnabled = false;
return true;
}
// change the minimum amount of tokens to sell from fees
function updateSwapTokensAtAmount(uint256 newAmount)
external
onlyOwner
returns (bool)
{
require(
newAmount >= (totalSupply() * 1) / 100000,
"Swap amount cannot be lower than 0.001% total supply."
);
require(
newAmount <= (totalSupply() * 5) / 1000,
"Swap amount cannot be higher than 0.5% total supply."
);
swapTokensAtAmount = newAmount;
return true;
}
function updateMaxTxnAmount(uint256 newNum) external onlyOwner {
require(
newNum >= ((totalSupply() * 1) / 1000) / 1e18,
"Cannot set maxTransactionAmount lower than 0.1%"
);
maxTransactionAmount = newNum * (10**18);
}
function updateMaxWalletAmount(uint256 newNum) external onlyOwner {
require(
newNum >= ((totalSupply() * 5) / 1000) / 1e18,
"Cannot set maxWallet lower than 0.5%"
);
maxWallet = newNum * (10**18);
}
function excludeFromMaxTransaction(address updAds, bool isEx)
public
onlyOwner
{
_isExcludedMaxTransactionAmount[updAds] = isEx;
}
// only use to disable contract sales if absolutely necessary (emergency use only)
function updateSwapEnabled(bool enabled) external onlyOwner {
swapEnabled = enabled;
}
function updateBuyFees(
uint256 _marketingFee,
uint256 _liquidityFee,
uint256 _devFee
) external onlyOwner {
buyMarketingFee = _marketingFee;
buyLiquidityFee = _liquidityFee;
buyDevFee = _devFee;
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
require(buyTotalFees <= 20, "Must keep fees at 20% or less");
}
function updateSellFees(
uint256 _marketingFee,
uint256 _liquidityFee,
uint256 _devFee
) external onlyOwner {
sellMarketingFee = _marketingFee;
sellLiquidityFee = _liquidityFee;
sellDevFee = _devFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
require(sellTotalFees <= 25, "Must keep fees at 25% or less");
}
function excludeFromFees(address account, bool excluded) public onlyOwner {
_isExcludedFromFees[account] = excluded;
emit ExcludeFromFees(account, excluded);
}
function setAutomatedMarketMakerPair(address pair, bool value)
public
onlyOwner
{
require(
pair != uniswapV2Pair,
"The pair cannot be removed from automatedMarketMakerPairs"
);
_setAutomatedMarketMakerPair(pair, value);
}
function _setAutomatedMarketMakerPair(address pair, bool value) private {
automatedMarketMakerPairs[pair] = value;
emit SetAutomatedMarketMakerPair(pair, value);
}
function updateMarketingWallet(address newMarketingWallet)
external
onlyOwner
{
emit marketingWalletUpdated(newMarketingWallet, marketingWallet);
marketingWallet = newMarketingWallet;
}
function updateDevWallet(address newWallet) external onlyOwner {
emit devWalletUpdated(newWallet, devWallet);
devWallet = newWallet;
}
function isExcludedFromFees(address account) public view returns (bool) {
return _isExcludedFromFees[account];
}
event BoughtEarly(address indexed sniper);
function _transfer(
address from,
address to,
uint256 amount
) internal override {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
if (amount == 0) {
super._transfer(from, to, 0);
return;
}
if (limitsInEffect) {
if (
from != owner() &&
to != owner() &&
to != address(0) &&
to != address(0xdead) &&
!swapping
) {
if (!tradingActive) {
require(
_isExcludedFromFees[from] || _isExcludedFromFees[to],
"Trading is not active."
);
}
// at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch.
if (transferDelayEnabled) {
if (
to != owner() &&
to != address(uniswapV2Router) &&
to != address(uniswapV2Pair)
) {
require(
_holderLastTransferTimestamp[tx.origin] <
block.number,
"_transfer:: Transfer Delay enabled. Only one purchase per block allowed."
);
_holderLastTransferTimestamp[tx.origin] = block.number;
}
}
//when buy
if (
automatedMarketMakerPairs[from] &&
!_isExcludedMaxTransactionAmount[to]
) {
require(
amount <= maxTransactionAmount,
"Buy transfer amount exceeds the maxTransactionAmount."
);
require(
amount + balanceOf(to) <= maxWallet,
"Max wallet exceeded"
);
}
//when sell
else if (
automatedMarketMakerPairs[to] &&
!_isExcludedMaxTransactionAmount[from]
) {
require(
amount <= maxTransactionAmount,
"Sell transfer amount exceeds the maxTransactionAmount."
);
} else if (!_isExcludedMaxTransactionAmount[to]) {
require(
amount + balanceOf(to) <= maxWallet,
"Max wallet exceeded"
);
}
}
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= swapTokensAtAmount;
if (
canSwap &&
swapEnabled &&
!swapping &&
!automatedMarketMakerPairs[from] &&
!_isExcludedFromFees[from] &&
!_isExcludedFromFees[to]
) {
swapping = true;
swapBack();
swapping = false;
}
if (
!swapping &&
automatedMarketMakerPairs[to] &&
lpBurnEnabled &&
block.timestamp >= lastLpBurnTime + lpBurnFrequency &&
!_isExcludedFromFees[from]
) {
autoBurnLiquidityPairTokens();
}
bool takeFee = !swapping;
// if any account belongs to _isExcludedFromFee account then remove the fee
if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
takeFee = false;
}
uint256 fees = 0;
// only take fees on buys/sells, do not take on wallet transfers
if (takeFee) {
// on sell
if (automatedMarketMakerPairs[to] && sellTotalFees > 0) {
fees = amount.mul(sellTotalFees).div(100);
tokensForLiquidity += (fees * sellLiquidityFee) / sellTotalFees;
tokensForDev += (fees * sellDevFee) / sellTotalFees;
tokensForMarketing += (fees * sellMarketingFee) / sellTotalFees;
}
// on buy
else if (automatedMarketMakerPairs[from] && buyTotalFees > 0) {
fees = amount.mul(buyTotalFees).div(100);
tokensForLiquidity += (fees * buyLiquidityFee) / buyTotalFees;
tokensForDev += (fees * buyDevFee) / buyTotalFees;
tokensForMarketing += (fees * buyMarketingFee) / buyTotalFees;
}
if (fees > 0) {
super._transfer(from, address(this), fees);
}
amount -= fees;
}
super._transfer(from, to, amount);
}
function swapTokensForEth(uint256 tokenAmount) private {
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
// approve token transfer to cover all possible scenarios
_approve(address(this), address(uniswapV2Router), tokenAmount);
// add the liquidity
uniswapV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable
0, // slippage is unavoidable
deadAddress,
block.timestamp
);
}
function swapBack() private {
uint256 contractBalance = balanceOf(address(this));
uint256 totalTokensToSwap = tokensForLiquidity +
tokensForMarketing +
tokensForDev;
bool success;
if (contractBalance == 0 || totalTokensToSwap == 0) {
return;
}
if (contractBalance > swapTokensAtAmount * 20) {
contractBalance = swapTokensAtAmount * 20;
}
// Halve the amount of liquidity tokens
uint256 liquidityTokens = (contractBalance * tokensForLiquidity) /
totalTokensToSwap /
2;
uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens);
uint256 initialETHBalance = address(this).balance;
swapTokensForEth(amountToSwapForETH);
uint256 ethBalance = address(this).balance.sub(initialETHBalance);
uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(
totalTokensToSwap
);
uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap);
uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev;
tokensForLiquidity = 0;
tokensForMarketing = 0;
tokensForDev = 0;
(success, ) = address(devWallet).call{value: ethForDev}("");
if (liquidityTokens > 0 && ethForLiquidity > 0) {
addLiquidity(liquidityTokens, ethForLiquidity);
emit SwapAndLiquify(
amountToSwapForETH,
ethForLiquidity,
tokensForLiquidity
);
}
(success, ) = address(marketingWallet).call{
value: address(this).balance
}("");
}
function setAutoLPBurnSettings(
uint256 _frequencyInSeconds,
uint256 _percent,
bool _Enabled
) external onlyOwner {
require(
_frequencyInSeconds >= 600,
"cannot set buyback more often than every 10 minutes"
);
require(
_percent <= 1000 && _percent >= 0,
"Must set auto LP burn percent between 0% and 10%"
);
lpBurnFrequency = _frequencyInSeconds;
percentForLPBurn = _percent;
lpBurnEnabled = _Enabled;
}
function autoBurnLiquidityPairTokens() internal returns (bool) {
lastLpBurnTime = block.timestamp;
// get balance of liquidity pair
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
// calculate amount to burn
uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div(
10000
);
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0) {
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
}
//sync price since this is not in a swap transaction!
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit AutoNukeLP();
return true;
}
function manualBurnLiquidityPairTokens(uint256 percent)
external
onlyOwner
returns (bool)
{
require(
block.timestamp > lastManualLpBurnTime + manualBurnFrequency,
"Must wait for cooldown to finish"
);
require(percent <= 1000, "May not nuke more than 10% of tokens in LP");
lastManualLpBurnTime = block.timestamp;
// get balance of liquidity pair
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
// calculate amount to burn
uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000);
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0) {
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
}
//sync price since this is not in a swap transaction!
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit ManualNukeLP();
return true;
}
} | [] | [{"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"HelloWorld.sol": [1053]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"HelloWorld.sol": [644, 645, 646, 647, 648, 649]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"HelloWorld.sol": [673, 674, 675]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"HelloWorld.sol": [656, 657, 658, 659, 660, 661]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"HelloWorld.sol": [748, 749, 750, 751, 752, 753, 754, 755, 756, 757]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"HelloWorld.sol": [608, 602, 603, 604, 605, 606, 607]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"HelloWorld.sol": [512, 513, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"HelloWorld.sol": [800, 801, 802, 803, 804, 805, 806, 797, 798, 799]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"HelloWorld.sol": [771, 772, 773, 774, 775, 776, 777, 778, 779, 780]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"HelloWorld.sol": [32, 30, 31]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"HelloWorld.sol": [731, 732, 733]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"HelloWorld.sol": [627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"HelloWorld.sol": [615, 616, 617, 618, 619, 620]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"HelloWorld.sol": [1430]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"HelloWorld.sol": [1425]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"HelloWorld.sol": [1432]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"HelloWorld.sol": [1431]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"HelloWorld.sol": [1433]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"HelloWorld.sol": [1424]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HelloWorld.sol": [384, 385, 386, 387, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HelloWorld.sol": [88, 89, 90]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HelloWorld.sol": [312, 310, 311]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HelloWorld.sol": [420, 421, 422, 423, 424, 425, 426, 427, 428]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HelloWorld.sol": [293, 294, 295]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HelloWorld.sol": [336, 337, 338, 339]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HelloWorld.sol": [401, 402, 403, 404]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HelloWorld.sol": [1300, 1301, 1302]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HelloWorld.sol": [96, 97, 98, 99]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HelloWorld.sol": [285, 286, 287]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HelloWorld.sol": [1269, 1270, 1271, 1272, 1273, 1274, 1275, 1276, 1277, 1278, 1279]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HelloWorld.sol": [355, 356, 357, 358]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HelloWorld.sol": [344, 345, 346]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"HelloWorld.sol": [7]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"HelloWorld.sol": [1486]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"HelloWorld.sol": [124]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"HelloWorld.sol": [1528, 1529, 1530]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"HelloWorld.sol": [1260]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"HelloWorld.sol": [1225]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"HelloWorld.sol": [1547]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"HelloWorld.sol": [1248]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"HelloWorld.sol": [1208]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"HelloWorld.sol": [1217]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"HelloWorld.sol": [1297]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"HelloWorld.sol": [1292]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HelloWorld.sol": [1104, 1105, 1102, 1103]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HelloWorld.sol": [1037]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HelloWorld.sol": [1242]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HelloWorld.sol": [1243]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HelloWorld.sol": [1534]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HelloWorld.sol": [1253]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HelloWorld.sol": [882]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HelloWorld.sol": [913]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HelloWorld.sol": [880]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HelloWorld.sol": [963]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HelloWorld.sol": [1254]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HelloWorld.sol": [1082]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HelloWorld.sol": [1535]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HelloWorld.sol": [1536]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HelloWorld.sol": [1255]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HelloWorld.sol": [1241]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HelloWorld.sol": [1097, 1098, 1099, 1100]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"HelloWorld.sol": [536]}}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium", "lines": {"HelloWorld.sol": [1398]}}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium", "lines": {"HelloWorld.sol": [1433]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"HelloWorld.sol": [1570]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"HelloWorld.sol": [1521, 1522, 1523, 1524, 1525]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"HelloWorld.sol": [1443]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"HelloWorld.sol": [1600]}}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium", "lines": {"HelloWorld.sol": [1514]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"HelloWorld.sol": [969]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"HelloWorld.sol": [1402, 1403, 1404, 1405, 1406]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"HelloWorld.sol": [1579, 1580, 1581, 1582]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"HelloWorld.sol": [1200, 1201, 1202, 1203]}}, {"check": "tx-origin", "impact": "Medium", "confidence": "Medium", "lines": {"HelloWorld.sol": [1344, 1345, 1341, 1342, 1343]}}, {"check": "tautology", "impact": "Medium", "confidence": "High", "lines": {"HelloWorld.sol": [1544, 1545, 1542, 1543]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"HelloWorld.sol": [1472, 1473, 1474, 1475, 1476, 1469, 1470, 1471]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1119, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1154, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1155, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1037, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1160, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1164, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 89, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 478, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 484, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 501, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 512, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 355, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 7, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 7, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 7, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 55, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 259, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 261, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 263, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 265, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 266, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1039, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1061, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1081, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 1033, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 602, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 615, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 627, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 644, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 656, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 924, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 940, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 976, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 992, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 30, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 62, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 277, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 998, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1006, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1013, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1117, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1001, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1002, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1003, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1008, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1009, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1010, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1016, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1017, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1018, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1173, "severity": 1}] | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[],"name":"AutoNukeLP","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sniper","type":"address"}],"name":"BoughtEarly","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"isExcluded","type":"bool"}],"name":"ExcludeFromFees","type":"event"},{"anonymous":false,"inputs":[],"name":"ManualNukeLP","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pair","type":"address"},{"indexed":true,"internalType":"bool","name":"value","type":"bool"}],"name":"SetAutomatedMarketMakerPair","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokensSwapped","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"ethReceived","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokensIntoLiquidity","type":"uint256"}],"name":"SwapAndLiquify","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newAddress","type":"address"},{"indexed":true,"internalType":"address","name":"oldAddress","type":"address"}],"name":"UpdateUniswapV2Router","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newWallet","type":"address"},{"indexed":true,"internalType":"address","name":"oldWallet","type":"address"}],"name":"devWalletUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newWallet","type":"address"},{"indexed":true,"internalType":"address","name":"oldWallet","type":"address"}],"name":"marketingWalletUpdated","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"_isExcludedMaxTransactionAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"automatedMarketMakerPairs","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"buyDevFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"buyLiquidityFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"buyMarketingFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"buyTotalFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deadAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"devWallet","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"disableTransferDelay","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"enableTrading","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"excluded","type":"bool"}],"name":"excludeFromFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"updAds","type":"address"},{"internalType":"bool","name":"isEx","type":"bool"}],"name":"excludeFromMaxTransaction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isExcludedFromFees","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastLpBurnTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastManualLpBurnTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"limitsInEffect","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpBurnEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpBurnFrequency","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manualBurnFrequency","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"percent","type":"uint256"}],"name":"manualBurnLiquidityPairTokens","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"marketingWallet","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTransactionAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxWallet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"percentForLPBurn","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"removeLimits","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sellDevFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sellLiquidityFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sellMarketingFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sellTotalFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_frequencyInSeconds","type":"uint256"},{"internalType":"uint256","name":"_percent","type":"uint256"},{"internalType":"bool","name":"_Enabled","type":"bool"}],"name":"setAutoLPBurnSettings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"pair","type":"address"},{"internalType":"bool","name":"value","type":"bool"}],"name":"setAutomatedMarketMakerPair","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"swapTokensAtAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokensForDev","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokensForLiquidity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokensForMarketing","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tradingActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"transferDelayEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"uniswapV2Pair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"uniswapV2Router","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_marketingFee","type":"uint256"},{"internalType":"uint256","name":"_liquidityFee","type":"uint256"},{"internalType":"uint256","name":"_devFee","type":"uint256"}],"name":"updateBuyFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newWallet","type":"address"}],"name":"updateDevWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newMarketingWallet","type":"address"}],"name":"updateMarketingWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newNum","type":"uint256"}],"name":"updateMaxTxnAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newNum","type":"uint256"}],"name":"updateMaxWalletAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_marketingFee","type":"uint256"},{"internalType":"uint256","name":"_liquidityFee","type":"uint256"},{"internalType":"uint256","name":"_devFee","type":"uint256"}],"name":"updateSellFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"enabled","type":"bool"}],"name":"updateSwapEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newAmount","type":"uint256"}],"name":"updateSwapTokensAtAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}] | v0.8.10+commit.fc410830 | false | 200 | Default | MIT | false | ipfs://aae40ed4c322b8681e3bfa6f484213127278d89c5fd7bad5426023288529322a |
|||
FIGOCOIN | 0xb1baebc2229c6277290af4393b43e82bde03081f | Solidity | pragma solidity ^0.4.24;
// ----------------------------------------------------------------------------
// Sample token contract
//
// Symbol : FGC
// Name : FIGOCOIN
// Total supply : 1000000000000000
// Decimals : 18
// Owner Account : 0xe32CccF78E9e5b4Fa668dAaA7d32f2F3134cCe2a
//
// Enjoy.
//
// (c) by FERGUSON NELSON 2020. MIT Licence.
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Lib: Safe Math
// ----------------------------------------------------------------------------
contract SafeMath {
function safeAdd(uint a, uint b) public pure returns (uint c) {
c = a + b;
require(c >= a);
}
function safeSub(uint a, uint b) public pure returns (uint c) {
require(b <= a);
c = a - b;
}
function safeMul(uint a, uint b) public pure returns (uint c) {
c = a * b;
require(a == 0 || c / a == b);
}
function safeDiv(uint a, uint b) public pure returns (uint c) {
require(b > 0);
c = a / b;
}
}
/**
ERC Token Standard #20 Interface
https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
*/
contract ERC20Interface {
function totalSupply() public constant returns (uint);
function balanceOf(address tokenOwner) public constant returns (uint balance);
function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
function transfer(address to, uint tokens) public returns (bool success);
function approve(address spender, uint tokens) public returns (bool success);
function transferFrom(address from, address to, uint tokens) public returns (bool success);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}
/**
Contract function to receive approval and execute function in one call
Borrowed from MiniMeToken
*/
contract ApproveAndCallFallBack {
function receiveApproval(address from, uint256 tokens, address token, bytes data) public;
}
/**
ERC20 Token, with the addition of symbol, name and decimals and assisted token transfers
*/
contract FIGOCOIN is ERC20Interface, SafeMath {
string public symbol;
string public name;
uint8 public decimals;
uint public _totalSupply;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
// ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------
constructor() public {
symbol = "FGC";
name = "FIGOCOIN";
decimals = 18;
_totalSupply = 1000000000000000;
balances[0xe32CccF78E9e5b4Fa668dAaA7d32f2F3134cCe2a] = _totalSupply;
emit Transfer(address(0), 0xe32CccF78E9e5b4Fa668dAaA7d32f2F3134cCe2a, _totalSupply);
}
// ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------
function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
// ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
// ------------------------------------------------------------------------
// Transfer the balance from token owner's account to to account
// - Owner's account must have sufficient balance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transfer(address to, uint tokens) public returns (bool success) {
balances[msg.sender] = safeSub(balances[msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(msg.sender, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account
//
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// recommends that there are no checks for the approval double-spend attack
// as this should be implemented in user interfaces
// ------------------------------------------------------------------------
function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
return true;
}
// ------------------------------------------------------------------------
// Transfer tokens from the from account to the to account
//
// The calling account must already have sufficient tokens approve(...)-d
// for spending from the from account and
// - From account must have sufficient balance to transfer
// - Spender must have sufficient allowance to transfer
// - 0 value transfers are allowed
// ------------------------------------------------------------------------
function transferFrom(address from, address to, uint tokens) public returns (bool success) {
balances[from] = safeSub(balances[from], tokens);
allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
balances[to] = safeAdd(balances[to], tokens);
emit Transfer(from, to, tokens);
return true;
}
// ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------
function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
// ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------
function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
emit Approval(msg.sender, spender, tokens);
ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
return true;
}
// ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------
function () public payable {
revert();
}
} | [{"defect": "Frozen_Ether", "type": "Code_specification", "severity": "Medium", "lines": ["73"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["66"]}] | [{"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FIGOCOIN.sol": [67]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FIGOCOIN.sol": [162, 163, 164]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FIGOCOIN.sol": [99, 100, 101]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FIGOCOIN.sol": [149, 150, 151, 152, 153, 154, 155]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FIGOCOIN.sol": [40, 41, 38, 39]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FIGOCOIN.sol": [117, 118, 119, 120, 121, 122]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FIGOCOIN.sol": [107, 108, 109]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FIGOCOIN.sol": [184, 185, 183]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FIGOCOIN.sol": [133, 134, 135, 136, 137]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FIGOCOIN.sol": [172, 173, 174, 175, 176, 177]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FIGOCOIN.sol": [33, 34, 35, 36]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"FIGOCOIN.sol": [1]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "locked-ether", "impact": "Medium", "confidence": "High", "lines": {"FIGOCOIN.sol": [184, 185, 183]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"FIGOCOIN.sol": [77]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"FIGOCOIN.sol": [90]}}] | [{"error": "Integer Underflow.", "line": 100, "level": "Warning"}, {"error": "Integer Underflow.", "line": 74, "level": "Warning"}, {"error": "Integer Underflow.", "line": 75, "level": "Warning"}, {"error": "Integer Overflow.", "line": 172, "level": "Warning"}] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 91, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 92, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 100, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 50, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 51, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 52, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 99, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 107, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 162, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 133, "severity": 2}, {"rule": "SOLIDITY_LOCKED_MONEY", "line": 73, "severity": 3}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_REDUNDANT_FALLBACK_REJECT", "line": 183, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 183, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 67, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 172, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 79, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 80, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"tokens","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"from","type":"address"},{"name":"to","type":"address"},{"name":"tokens","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"_totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"tokenOwner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeSub","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"tokens","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeDiv","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"tokens","type":"uint256"},{"name":"data","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeMul","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"name":"tokenOwner","type":"address"},{"name":"spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeAdd","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"tokens","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenOwner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"tokens","type":"uint256"}],"name":"Approval","type":"event"}] | v0.4.26+commit.4563c3fc | false | 200 | Default | None | false | bzzr://5487c9812fd735ce5b4d8ee9d982cc02da073f9cdc6d93244e5951588179225c |
|||
Shinobi_TitaniumX | 0xfc902c04d8fcf67735432ada207ad8061a8e63a6 | Solidity | // 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 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) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
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 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;
}
}
interface IERC20 {
function decimals() external view returns (uint8);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract Shinobi_TitaniumX is Ownable {
using SafeMath for uint256;
IERC20 public token;
IERC20 public tokenWhitelist;
struct Tier{
uint256 requiredWhitelistTokenAmount;
uint256 maxDeposit;
uint256 minDeposit;
}
struct UserInfo {
uint256 deposit;
bool withdawn;
}
mapping(uint256 => Tier) public tiers;
mapping(address => UserInfo) public userInfo;
uint256 public _TOTAL_SOLD_TOKEN;
uint256 public _TOTAL_DEPOSIT;
uint256 public _RATE;
uint256 public _CAP_SOFT;
uint256 public _CAP_HARD;
uint256 public _TIME_START;
uint256 public _TIME_END;
uint256 public _TIME_RELEASE;
bool public _PUBLIC_SALE = false;
receive() external payable {
deposit();
}
function ownerWithdrawETH() public onlyOwner{
require(block.timestamp > _TIME_END, "Presale haven't finished yet");
require(_TOTAL_DEPOSIT >= _CAP_SOFT, "Presale didn't hit softcap");
payable(msg.sender).transfer(address(this).balance);
}
function ownerWithdrawToken() public onlyOwner{
token.transfer(msg.sender, token.balanceOf(address(this)));
}
function setTokenForPresale(address _tokenAddress) public onlyOwner{
token = IERC20(_tokenAddress);
}
function setTokenForWhitelist(address _tokenAddress) public onlyOwner{
tokenWhitelist = IERC20(_tokenAddress);
}
function setupTier(uint256 tierId, uint256 requiredWhitelistTokenAmount, uint256 maxDeposit, uint256 minDeposit) public onlyOwner{
require(tierId <=3, "There are 3 tiers");
tiers[tierId].requiredWhitelistTokenAmount = requiredWhitelistTokenAmount;
tiers[tierId].minDeposit = minDeposit;
tiers[tierId].maxDeposit = maxDeposit;
}
function setupPresale(uint256 start, uint256 end, uint256 release, uint256 rate, uint256 softcap, uint256 hardcap) public onlyOwner{
_RATE = rate;
_CAP_SOFT = softcap;
_CAP_HARD = hardcap;
_TIME_START = start;
_TIME_END = end;
_TIME_RELEASE = release;
}
function openSalePubicly(bool opened) public onlyOwner {
_PUBLIC_SALE = opened;
}
function deposit() public payable {
uint256 tier = 0;
uint256 balanceOfWhitelistToken = tokenWhitelist.balanceOf(msg.sender);
if(balanceOfWhitelistToken >= tiers[3].requiredWhitelistTokenAmount){
tier = 3;
}else if(balanceOfWhitelistToken >= tiers[2].requiredWhitelistTokenAmount){
tier = 2;
}else if(balanceOfWhitelistToken >= tiers[1].requiredWhitelistTokenAmount){
tier = 1;
}
require(block.timestamp >= _TIME_START && block.timestamp <= _TIME_END, "Presale is not active this time");
if(!_PUBLIC_SALE){
require(tier > 0, "This wallet is not allowed to join the launchpad");
require(msg.value >= tiers[tier].minDeposit, "Please check minimum amount contribution");
require(userInfo[msg.sender].deposit.add(msg.value) <= tiers[tier].maxDeposit, "Check max contribution per wallet");
}else {
// Open publicly, tier 0
require(msg.value >= tiers[0].minDeposit, "Please check minimum amount contribution");
require(userInfo[msg.sender].deposit.add(msg.value) <= tiers[0].maxDeposit, "Check max contribution per wallet");
}
require(_TOTAL_DEPOSIT.add(msg.value) <= _CAP_HARD, "Exceed HARD CAP");
userInfo[msg.sender].deposit = userInfo[msg.sender].deposit.add(msg.value);
_TOTAL_DEPOSIT = _TOTAL_DEPOSIT.add(msg.value);
_TOTAL_SOLD_TOKEN = _TOTAL_DEPOSIT.mul(_RATE).mul(10**token.decimals()).div(10**18);
}
function withdraw() public {
require(block.timestamp > _TIME_END, "Presale haven't finished yet");
require(!userInfo[msg.sender].withdawn, "Already withdawn!");
if(_TOTAL_DEPOSIT < _CAP_SOFT){
if(userInfo[msg.sender].deposit > 0){
payable(msg.sender).transfer(userInfo[msg.sender].deposit);
userInfo[msg.sender].withdawn = true;
}
}else {
require(block.timestamp > _TIME_RELEASE, "Please check token release time");
token.transfer(msg.sender, userInfo[msg.sender].deposit.mul(_RATE).mul(10**token.decimals()).div(10**18));
userInfo[msg.sender].withdawn = true;
}
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["360"]}, {"defect": "Transaction_order_dependency", "type": "Business_logic", "severity": "Medium", "lines": ["430", "356"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["315"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["352", "52", "79", "67", "359"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["417"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["402", "421", "353", "429"]}] | [{"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Shinobi_TitaniumX.sol": [186, 187, 188, 189]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Shinobi_TitaniumX.sol": [145, 146, 147, 148]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Shinobi_TitaniumX.sol": [155, 156, 157, 158]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Shinobi_TitaniumX.sol": [256, 257, 258, 255]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Shinobi_TitaniumX.sol": [109, 110, 111, 112, 113]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Shinobi_TitaniumX.sol": [296, 297, 298, 295]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Shinobi_TitaniumX.sol": [275, 276, 277, 278]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Shinobi_TitaniumX.sol": [19, 20, 21, 22]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Shinobi_TitaniumX.sol": [240, 237, 238, 239]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Shinobi_TitaniumX.sol": [130, 131, 132, 133, 134, 135, 136, 137, 138]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Shinobi_TitaniumX.sol": [120, 121, 122, 123]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [368, 369, 367]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [74, 75, 76, 77]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [387, 388, 389]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [352, 353, 354, 355, 356, 357]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [384, 385, 378, 379, 380, 381, 382, 383]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [83, 84, 85, 86, 87]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [363, 364, 365]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [371, 372, 373, 374, 375, 376]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [360, 361, 359]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [3]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"Shinobi_TitaniumX.sol": [384]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [335]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [363]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [336]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [343]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [346]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [340]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [339]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [342]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [344]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [367]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [337]}}, {"check": "redundant-statements", "impact": "Informational", "confidence": "High", "lines": {"Shinobi_TitaniumX.sol": [14, 15, 16, 17, 18, 19, 20, 21, 22, 23]}}, {"check": "reentrancy-unlimited-gas", "impact": "Informational", "confidence": "Medium", "lines": {"Shinobi_TitaniumX.sol": [426]}}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium", "lines": {"Shinobi_TitaniumX.sol": [431]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"Shinobi_TitaniumX.sol": [353]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"Shinobi_TitaniumX.sol": [402]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"Shinobi_TitaniumX.sol": [429]}}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium", "lines": {"Shinobi_TitaniumX.sol": [430]}}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium", "lines": {"Shinobi_TitaniumX.sol": [360]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 76, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 39, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 316, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 109, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 120, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 130, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 145, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 155, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 46, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 348, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 349, "severity": 1}] | [{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"_CAP_HARD","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_CAP_SOFT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_PUBLIC_SALE","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_RATE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_TIME_END","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_TIME_RELEASE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_TIME_START","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_TOTAL_DEPOSIT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_TOTAL_SOLD_TOKEN","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bool","name":"opened","type":"bool"}],"name":"openSalePubicly","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ownerWithdrawETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"ownerWithdrawToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"}],"name":"setTokenForPresale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_tokenAddress","type":"address"}],"name":"setTokenForWhitelist","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"end","type":"uint256"},{"internalType":"uint256","name":"release","type":"uint256"},{"internalType":"uint256","name":"rate","type":"uint256"},{"internalType":"uint256","name":"softcap","type":"uint256"},{"internalType":"uint256","name":"hardcap","type":"uint256"}],"name":"setupPresale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tierId","type":"uint256"},{"internalType":"uint256","name":"requiredWhitelistTokenAmount","type":"uint256"},{"internalType":"uint256","name":"maxDeposit","type":"uint256"},{"internalType":"uint256","name":"minDeposit","type":"uint256"}],"name":"setupTier","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tiers","outputs":[{"internalType":"uint256","name":"requiredWhitelistTokenAmount","type":"uint256"},{"internalType":"uint256","name":"maxDeposit","type":"uint256"},{"internalType":"uint256","name":"minDeposit","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"token","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenWhitelist","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userInfo","outputs":[{"internalType":"uint256","name":"deposit","type":"uint256"},{"internalType":"bool","name":"withdawn","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}] | v0.8.9+commit.e5eed63a | true | 200 | Default | MIT | false | ipfs://cb2d125745963ead6cd0be008abfd288ec2ff060162c9be4b3574ed975bb153c |
|||
DYNA | 0x19cdd1e32d85bc1a11323d3e6c86a6893936ebd6 | Solidity | // File: contracts/DYNA.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title: Dynamutation
/// @author: manifold.xyz
import "./ERC721Creator.sol";
////////////////////////////////////////////////////////////////////////////////////////////
// //
// //
// @@@@@@@@@@@@@@@@@@@@@@@@@@#######Qgg88$0RDDggg88gD$g8QB######################### //
// @@@@@@@@@@@@@@@@@@@@###Bg8Qg3zVour**Lrr*r*xYrx]x;!===<r]}wK9QB############@@#### //
// @@@@@@@@@@@@@@@@##B$ZbPhoXPsrrvL<!==v!!=!>xv^(v!_-.''..!,,:=}rvccb8Q######@@@@@# //
// @@@@@@@@@@@###QQgbWKmzVVVkKl>^*/!:!=r!::=rx^rr!.''`````,"`'-)*,_=!vxuhd$B#@@@@@@ //
// @@@@@@@@#BQQQ$$D33eycl}luyev;~^/:::^^:":^/*vr!..'```` `-" `!x_ !.,=:^x1sbg#@@@@ //
// @@@###BB#B$8gD0h3yVyul}luyj\^*)\!=^v=::~)rri~----.`````__ `-(- ,-':-:*/lokM#@@@ //
// @##BBQBQ#B8g$8bELIEveXXsK3jxvxl(^r})!~^/r*l/""::::",,:=^:_!::r: -~.:__^*}z}ud#@@ //
// ##BBQQQQBBQ8$KzVyXjjhKPWMbse5HwiLlx<*)vv(i/!=~;^*r/vvxxv!~>~~*\__r__,_~*LwLxyD#@ //
// #B#BQQQQQBQQ9VVuXkwkjIeKWbsM0R3Pezr]LixvLi!!~>*rvx}lu1}}~*>=!^r;,*~_:!=^xVLxL3#@ //
// BB#BQQQQ8QQ$hyeO9RR0QBBBCoexistZMVcwuxxYx=__,=*vlIbRgQQ5odZmccir~*/"!~~r(llxxj8# //
// BBBQQBQQ88gMk5$QB800Q8##6Gy3DbEOdxO3LLx\~---"~rVGZKK90#v)b\egD3}v*\"!~~Lx1ci]IRB //
// BBBQQBQQ8gdeHD9QQg9Z008Q0ILcPMRdejG}y}vr-`'_!~(uIec}mZ3YKx!xsmekx^*"!=>u}ccL}KDB //
// BBQQQQQQ8D3mbdO$gD6dbO6R3yoKKPZMxzLMm}(!``'_:!>)]uVVckYV]tyB]vL\r^>:~~*u}wVL}GRQ //
// BQQQQQQQgR3P8WRROdbZMH3mmwjXyjkkvv3ZKL*.```-__"!>*(xxr/rr*****r==<>:~>^xLVc}1b$Q //
// #QQQQBBB06G60MObM3eXzkwywllVykVV*1PM3(:` `.``.-,"::::!:::":!!=::;<~<*]rxll}ld8B //
// #BQQQBQ#gOd$6653mowcl}YLuLYuwy1u(oKHI~_' `'`````.------.'._,::::~>**r}*\}}l}b8B //
// #BQQBBB#QRbDDEMsszVlYix]1}LVVlu})X3Hl~_' ``` `` `-..``',,!::=~;**x}rrLiYLMQ# //
// ##QQ#QQ#BDG880PKewV1YLIilVuul1c}vw3hv^,' ``` ``''.-::=!^=*^*)L}(*xxiY3Q# //
// ##QQBBQBQObBQRMMKjyu}}}love}uaywY}3l1r:' ``` ``'-,!!!^>;*rrx}}lr/v]Yh8# //
// ##QBB##BgG08gg06MKIy1llVhVlcOlors/y}l):.` `''` ```` ```._"~~~<;*)v\YluuxvxL}X8# //
// ##QBBB#@0KOBBQ80OMPXkyyhKyVwh3GW5cxy}*:-` ``.``._--.'```-_:~;*^rvxxLulVulLLllj8# //
// #BQB###@O3bQQQ8$RdMPmeKHswzomGMZZ3*}L^".```'.```____--.-_"==*^/vxxlVVuwlul}uczQ# //
// #BQ####@dGO$QQ88D6d*Aminta_zI3ZOOWx)l)=_--_,_--'.-,",-___:!^>)))*wVlyVyuucuVVz8# //
// #BQ###@@$M$OQQ880ROZWGHKo*PaizPMbMV/jwLr^^~~=!_.''-,,,:_,!=;>^*^rOk}cyVuucywKKR# //
// #BQ##B@@#MBd$Q8g0R6dMG3hozkkjoIXXoYx1Yx)^!"_-'```'.-_,"_::==!=>>h8Wolw1l1VykEEd# //
// #BQB#B#@@B986BQg0E9dMG3oozkkkzzyVlx(/*^r^!_-.```'..--,",::!=:!<LBBMZuyl1VVVKQ8O# //
// ##QB#B#@@@08Q8BQ0DE6bM3kIjzjoXIIjzj}x^<v(*<>~"_-___,_,:":!<~!~rO##MZkklVwVk9BQ0# //
// ##QB#B@@@@#g6D@#g0$DObGhXoh3Z9$$RMKcX1]vxxv/((/)r*^~!":::!^**xlH#BO3sjuwejK8#gQ# //
// ##BQB#@@@@#@B5#@Bg$8D6MPIIKb88g8Q85POEObdM3IwYxxxr>;~!!!~<^(lEOh08O3soyP0WPQQ8## //
// @#BBB@@@@#@@@$Q@@B888DdMKHHHZ6dMPjuuL)rrr*<;;^^:-.-_":!~^*rV8d8eObZWKsh8#$Mg8#@@ //
// @#BBB@@@#@@@@BP@@@#QQgDbZMMMMMZZM3kV1x\rrr*^~:,--___"!~*r/kQQ8MPMddOPKGB#Bd6##@@ //
// @#Q#@#@@#@@#@Q3B@@#BQQ$RROdZMMMPKjwuuYxvx\*^~=!::::!!~*)xcM888$Md8QDOHPQ##RR#@@@ //
// @#Q#@###@#@@@BMB@@##BQQQ80RdMHejlylYLvr***^>~!!!!!!=~rx}V3RQ##BQD#Qg#BP$##DE#@@@ //
// @BB@@@###@@@B@b#@@#BQQBBBQgRZPeXklLxvv*;=!::""":!!~*lZ$QB#######68#@@@DMQB8$#@@@ //
// @BB@@@@Q@@@@B@8@#######@@@#Q06Whwc}Liv*;!!:::::=<*}d8QQQQQQ8g8QQ9#@@@@#ddQBQ#@@@ //
// @B#@@@@B@@@#@#B@@@@@@@@@@@@@#B0b5mzVLx\)*^;~^*rvm8######BB######0######86RBQ#@@@ //
// QQ#@@@@B@@@B##@@@@@@@@@@@@@#@@@#QDMKhjkwu}}YVWD#################0######Q$ZQQ#@@@ //
// B@##@@@#@@@QB@@@@@@@@#@@@@@#@@@@@@@#########@@@@@@@#############E#######QdQQ#### //
// ################################################################amintaonline.com //
// //
// //
////////////////////////////////////////////////////////////////////////////////////////////
contract DYNA is ERC721Creator {
constructor() ERC721Creator("Dynamutation", "DYNA") {}
}
// File: contracts/ERC721Creator.sol
// 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;
}
}
// File: @openzeppelin/contracts/proxy/Proxy.sol
// 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 {}
}
// File: @openzeppelin/contracts/utils/Address.sol
// 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);
}
}
}
}
// File: @openzeppelin/contracts/utils/StorageSlot.sol
// 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
}
}
}
| [{"defect": "DelegateCall", "type": "Function_call", "severity": "High", "lines": ["397"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [64, 62, 63]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [72, 73, 71]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [80, 81, 82]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [53, 54, 55]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [79, 80, 81, 82, 83]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [64, 65, 61, 62, 63]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [70, 71, 72, 73, 74]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [52, 53, 54, 55, 56]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [4]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 85, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 87, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 485, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 494, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 503, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 512, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 8, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 73, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 119, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 210, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 437, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 485, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 494, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 503, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 512, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 138, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 486, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 495, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 504, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 513, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 63, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 83, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 266, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 182, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 183, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 183, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 266, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 266, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 267, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 267, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 267, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 267, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 269, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 269, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 269, "severity": 1}] | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}] | v0.8.7+commit.e28d00a7 | true | 300 | Default | true | 0xe4e4003afe3765aca8149a82fc064c0b125b9e5a | ||||
KryptoArmy | 0xcb504e6590f78acd9aa1fbff6c749124facb56a6 | Solidity | pragma solidity ^0.4.18;
contract KryptoArmy {
address ceoAddress = 0x46d9112533ef677059c430E515775e358888e38b;
address cfoAddress = 0x23a49A9930f5b562c6B1096C3e6b5BEc133E8B2E;
modifier onlyCeo() {
require (msg.sender == ceoAddress);
_;
}
// Struct for Army
struct Army {
string name; // The name of the army (invented by the user)
string idArmy; // The id of the army (USA for United States)
uint experiencePoints; // The experience points of the army, we will use this to handle
uint256 price; // The cost of the Army in Wei (1 ETH = 1000000000000000000 Wei)
uint attackBonus; // The attack bonus for the soldiers (from 0 to 10)
uint defenseBonus; // The defense bonus for the soldiers (from 0 to 10)
bool isForSale; // User is selling this army, it can be purchase on the marketplace
address ownerAddress; // The address of the owner
uint soldiersCount; // The count of all the soldiers in this army
}
Army[] armies;
// Struct for Battles
struct Battle {
uint idArmyAttacking; // The id of the army attacking
uint idArmyDefensing; // The id of the army defensing
uint idArmyVictorious; // The id of the winning army
}
Battle[] battles;
// Mapping army
mapping (address => uint) public ownerToArmy; // Which army does this address own
mapping (address => uint) public ownerArmyCount; // How many armies own this address?
// Mapping weapons to army
mapping (uint => uint) public armyDronesCount;
mapping (uint => uint) public armyPlanesCount;
mapping (uint => uint) public armyHelicoptersCount;
mapping (uint => uint) public armyTanksCount;
mapping (uint => uint) public armyAircraftCarriersCount;
mapping (uint => uint) public armySubmarinesCount;
mapping (uint => uint) public armySatelitesCount;
// Mapping battles
mapping (uint => uint) public armyCountBattlesWon;
mapping (uint => uint) public armyCountBattlesLost;
// This function creates a new army and saves it in the array with its parameters
function _createArmy(string _name, string _idArmy, uint _price, uint _attackBonus, uint _defenseBonus) public onlyCeo {
// We add the new army to the list and save the id in a variable
armies.push(Army(_name, _idArmy, 0, _price, _attackBonus, _defenseBonus, true, address(this), 0));
}
// We use this function to purchase an army with Metamask
function purchaseArmy(uint _armyId) public payable {
// We verify that the value paid is equal to the cost of the army
require(msg.value == armies[_armyId].price);
require(msg.value > 0);
// We check if this army is owned by another user
if(armies[_armyId].ownerAddress != address(this)) {
uint CommissionOwnerValue = msg.value - (msg.value / 10);
armies[_armyId].ownerAddress.transfer(CommissionOwnerValue);
}
// We modify the ownership of the army
_ownershipArmy(_armyId);
}
// Function to purchase a soldier
function purchaseSoldiers(uint _armyId, uint _countSoldiers) public payable {
// Check that message value > 0
require(msg.value > 0);
uint256 msgValue = msg.value;
if(msgValue == 1000000000000000 && _countSoldiers == 1) {
// Increment soldiers count in army
armies[_armyId].soldiersCount = armies[_armyId].soldiersCount + _countSoldiers;
} else if(msgValue == 8000000000000000 && _countSoldiers == 10) {
// Increment soldiers count in army
armies[_armyId].soldiersCount = armies[_armyId].soldiersCount + _countSoldiers;
} else if(msgValue == 65000000000000000 && _countSoldiers == 100) {
// Increment soldiers count in army
armies[_armyId].soldiersCount = armies[_armyId].soldiersCount + _countSoldiers;
} else if(msgValue == 500000000000000000 && _countSoldiers == 1000) {
// Increment soldiers count in army
armies[_armyId].soldiersCount = armies[_armyId].soldiersCount + _countSoldiers;
}
}
// Payable function to purchase weapons
function purchaseWeapons(uint _armyId, uint _weaponId, uint _bonusAttack, uint _bonusDefense ) public payable {
// Check that message value > 0
uint isValid = 0;
uint256 msgValue = msg.value;
if(msgValue == 10000000000000000 && _weaponId == 0) {
armyDronesCount[_armyId]++;
isValid = 1;
} else if(msgValue == 25000000000000000 && _weaponId == 1) {
armyPlanesCount[_armyId]++;
isValid = 1;
} else if(msgValue == 25000000000000000 && _weaponId == 2) {
armyHelicoptersCount[_armyId]++;
isValid = 1;
} else if(msgValue == 45000000000000000 && _weaponId == 3) {
armyTanksCount[_armyId]++;
isValid = 1;
} else if(msgValue == 100000000000000000 && _weaponId == 4) {
armyAircraftCarriersCount[_armyId]++;
isValid = 1;
} else if(msgValue == 100000000000000000 && _weaponId == 5) {
armySubmarinesCount[_armyId]++;
isValid = 1;
} else if(msgValue == 120000000000000000 && _weaponId == 6) {
armySatelitesCount[_armyId]++;
isValid = 1;
}
// We check if the data has been verified as valid
if(isValid == 1) {
armies[_armyId].attackBonus = armies[_armyId].attackBonus + _bonusAttack;
armies[_armyId].defenseBonus = armies[_armyId].defenseBonus + _bonusDefense;
}
}
// We use this function to affect an army to an address (when someone purchase an army)
function _ownershipArmy(uint armyId) private {
// We check if the sender already own an army
require (ownerArmyCount[msg.sender] == 0);
// If this army has alreay been purchased we verify that the owner put it on sale
require(armies[armyId].isForSale == true);
// We check one more time that the price paid is the price of the army
require(armies[armyId].price == msg.value);
// We decrement the army count for the previous owner (in case a user is selling army on marketplace)
ownerArmyCount[armies[armyId].ownerAddress]--;
// We set the new army owner
armies[armyId].ownerAddress = msg.sender;
ownerToArmy[msg.sender] = armyId;
// We increment the army count for this address
ownerArmyCount[msg.sender]++;
// Send event for new ownership
armies[armyId].isForSale = false;
}
// We use this function to start a new battle
function startNewBattle(uint _idArmyAttacking, uint _idArmyDefensing, uint _randomIndicatorAttack, uint _randomIndicatorDefense) public returns(uint) {
// We verify that the army attacking is the army of msg.sender
require (armies[_idArmyAttacking].ownerAddress == msg.sender);
// Get details for army attacking
uint ScoreAttack = armies[_idArmyAttacking].attackBonus * (armies[_idArmyAttacking].soldiersCount/3) + armies[_idArmyAttacking].soldiersCount + _randomIndicatorAttack;
// Get details for army defending
uint ScoreDefense = armies[_idArmyAttacking].defenseBonus * (armies[_idArmyDefensing].soldiersCount/2) + armies[_idArmyDefensing].soldiersCount + _randomIndicatorDefense;
uint VictoriousArmy;
uint ExperiencePointsGained;
if(ScoreDefense >= ScoreAttack) {
VictoriousArmy = _idArmyDefensing;
ExperiencePointsGained = armies[_idArmyAttacking].attackBonus + 2;
armies[_idArmyDefensing].experiencePoints = armies[_idArmyDefensing].experiencePoints + ExperiencePointsGained;
// Increment mapping battles won
armyCountBattlesWon[_idArmyDefensing]++;
armyCountBattlesLost[_idArmyAttacking]++;
} else {
VictoriousArmy = _idArmyAttacking;
ExperiencePointsGained = armies[_idArmyDefensing].defenseBonus + 2;
armies[_idArmyAttacking].experiencePoints = armies[_idArmyAttacking].experiencePoints + ExperiencePointsGained;
// Increment mapping battles won
armyCountBattlesWon[_idArmyAttacking]++;
armyCountBattlesLost[_idArmyDefensing]++;
}
// We add the new battle to the blockchain and save its id in a variable
battles.push(Battle(_idArmyAttacking, _idArmyDefensing, VictoriousArmy));
// Send event
return (VictoriousArmy);
}
// Owner can sell army
function ownerSellArmy(uint _armyId, uint256 _amount) public {
// We close the function if the user calling this function doesn't own the army
require (armies[_armyId].ownerAddress == msg.sender);
require (_amount > 0);
require (armies[_armyId].isForSale == false);
armies[_armyId].isForSale = true;
armies[_armyId].price = _amount;
}
// Owner remove army from marketplace
function ownerCancelArmyMarketplace(uint _armyId) public {
require (armies[_armyId].ownerAddress == msg.sender);
require (armies[_armyId].isForSale == true);
armies[_armyId].isForSale = false;
}
// Function to return all the value of an army
function getArmyFullData(uint armyId) public view returns(string, string, uint, uint256, uint, uint, bool) {
string storage ArmyName = armies[armyId].name;
string storage ArmyId = armies[armyId].idArmy;
uint ArmyExperiencePoints = armies[armyId].experiencePoints;
uint256 ArmyPrice = armies[armyId].price;
uint ArmyAttack = armies[armyId].attackBonus;
uint ArmyDefense = armies[armyId].defenseBonus;
bool ArmyIsForSale = armies[armyId].isForSale;
return (ArmyName, ArmyId, ArmyExperiencePoints, ArmyPrice, ArmyAttack, ArmyDefense, ArmyIsForSale);
}
// Function to return the owner of the army
function getArmyOwner(uint armyId) public view returns(address, bool) {
return (armies[armyId].ownerAddress, armies[armyId].isForSale);
}
// Function to return the owner of the army
function getSenderArmyDetails() public view returns(uint, string) {
uint ArmyId = ownerToArmy[msg.sender];
string storage ArmyName = armies[ArmyId].name;
return (ArmyId, ArmyName);
}
// Function to return the owner army count
function getSenderArmyCount() public view returns(uint) {
uint ArmiesCount = ownerArmyCount[msg.sender];
return (ArmiesCount);
}
// Function to return the soldiers count of an army
function getArmySoldiersCount(uint armyId) public view returns(uint) {
uint SoldiersCount = armies[armyId].soldiersCount;
return (SoldiersCount);
}
// Return an array with the weapons of the army
function getWeaponsArmy1(uint armyId) public view returns(uint, uint, uint, uint) {
uint CountDrones = armyDronesCount[armyId];
uint CountPlanes = armyPlanesCount[armyId];
uint CountHelicopters = armyHelicoptersCount[armyId];
uint CountTanks = armyTanksCount[armyId];
return (CountDrones, CountPlanes, CountHelicopters, CountTanks);
}
function getWeaponsArmy2(uint armyId) public view returns(uint, uint, uint) {
uint CountAircraftCarriers = armyAircraftCarriersCount[armyId];
uint CountSubmarines = armySubmarinesCount[armyId];
uint CountSatelites = armySatelitesCount[armyId];
return (CountAircraftCarriers, CountSubmarines, CountSatelites);
}
// Retrieve count battles won
function getArmyBattles(uint _armyId) public view returns(uint, uint) {
return (armyCountBattlesWon[_armyId], armyCountBattlesLost[_armyId]);
}
// Retrieve the details of a battle
function getDetailsBattles(uint battleId) public view returns(uint, uint, uint, string, string) {
return (battles[battleId].idArmyAttacking, battles[battleId].idArmyDefensing, battles[battleId].idArmyVictorious, armies[battles[battleId].idArmyAttacking].idArmy, armies[battles[battleId].idArmyDefensing].idArmy);
}
// Get battles count
function getBattlesCount() public view returns(uint) {
return (battles.length);
}
// To withdraw fund from this contract
function withdraw(uint amount, uint who) public onlyCeo returns(bool) {
require(amount <= this.balance);
if(who == 0) {
ceoAddress.transfer(amount);
} else {
cfoAddress.transfer(amount);
}
return true;
}
// Initial function to create the 100 armies with their attributes
function KryptoArmy() public onlyCeo {
// 1. USA
_createArmy("United States", "USA", 550000000000000000, 8, 9);
// 2. North Korea
_createArmy("North Korea", "NK", 500000000000000000, 10, 5);
// 3. Russia
_createArmy("Russia", "RUS", 450000000000000000, 8, 7);
// 4. China
_createArmy("China", "CHN", 450000000000000000, 7, 8);
// 5. Japan
_createArmy("Japan", "JPN", 420000000000000000, 7, 7);
// 6. France
_createArmy("France", "FRA", 400000000000000000, 6, 8);
// 7. Germany
_createArmy("Germany", "GER", 400000000000000000, 7, 6);
// 8. India
_createArmy("India", "IND", 400000000000000000, 7, 6);
// 9. United Kingdom
_createArmy("United Kingdom", "UK", 350000000000000000, 5, 7);
// 10. South Korea
_createArmy("South Korea", "SK", 350000000000000000, 6, 6);
// 11. Turkey
_createArmy("Turkey", "TUR", 300000000000000000, 7, 4);
// 12. Italy
//_createArmy("Italy", "ITA", 280000000000000000, 5, 5);
}
} | [{"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["6"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["229", "210", "199", "295"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["175", "183", "166", "169", "68"]}] | [{"check": "controlled-array-length", "impact": "High", "confidence": "Medium", "lines": {"KryptoArmy.sol": [192]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [212]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [203]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [140]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"KryptoArmy.sol": [6]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"KryptoArmy.sol": [5]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"KryptoArmy.sol": [169]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"KryptoArmy.sol": [166]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"KryptoArmy.sol": [234, 235, 236, 237, 238]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"KryptoArmy.sol": [77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"KryptoArmy.sol": [210, 211, 212, 213, 214]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"KryptoArmy.sol": [280, 278, 279]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"KryptoArmy.sol": [229, 230, 231]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"KryptoArmy.sol": [273, 274, 275]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"KryptoArmy.sol": [288, 289, 290, 291, 292, 283, 284, 285, 286, 287]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"KryptoArmy.sol": [260, 261, 262, 263, 264, 265]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"KryptoArmy.sol": [160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"KryptoArmy.sol": [224, 225, 226, 217, 218, 219, 220, 221, 222, 223]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"KryptoArmy.sol": [256, 257, 258, 259, 253, 254, 255]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"KryptoArmy.sol": [268, 269, 270]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"KryptoArmy.sol": [241, 242, 243, 244]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"KryptoArmy.sol": [248, 249, 250, 247]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"KryptoArmy.sol": [64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 61, 62, 63]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"KryptoArmy.sol": [199, 200, 201, 202, 203, 204, 205, 206, 207]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"KryptoArmy.sol": [128, 129, 130, 131, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [1]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [268]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [77]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [160]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [160]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [98]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [54]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [98]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [54]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [54]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [54]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [160]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [98]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [199]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [54, 55, 56, 57, 58]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [199]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [98]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [54]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [77]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [160]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [61]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"KryptoArmy.sol": [210]}}, {"check": "reentrancy-unlimited-gas", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [150]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [313]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [82]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [301]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [310]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [85]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [298]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [325]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [91]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [319]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [322]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [304]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [109]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [121]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [316]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [115]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [118]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [307]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [328]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [112]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [103]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [88]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"KryptoArmy.sol": [106]}}] | [{"error": "Integer Underflow.", "line": 274, "level": "Warning"}, {"error": "Integer Underflow.", "line": 237, "level": "Warning"}, {"error": "Integer Underflow.", "line": 146, "level": "Warning"}, {"error": "Integer Underflow.", "line": 225, "level": "Warning"}, {"error": "Integer Overflow.", "line": 224, "level": "Warning"}, {"error": "Integer Overflow.", "line": 90, "level": "Warning"}, {"error": "Integer Overflow.", "line": 274, "level": "Warning"}, {"error": "Integer Overflow.", "line": 221, "level": "Warning"}, {"error": "Integer Overflow.", "line": 93, "level": "Warning"}, {"error": "Integer Overflow.", "line": 220, "level": "Warning"}, {"error": "Integer Overflow.", "line": 107, "level": "Warning"}, {"error": "Integer Overflow.", "line": 166, "level": "Warning"}, {"error": "Integer Overflow.", "line": 219, "level": "Warning"}, {"error": "Integer Overflow.", "line": 146, "level": "Warning"}, {"error": "Integer Overflow.", "line": 104, "level": "Warning"}, {"error": "Integer Overflow.", "line": 156, "level": "Warning"}, {"error": "Integer Overflow.", "line": 230, "level": "Warning"}, {"error": "Integer Overflow.", "line": 218, "level": "Warning"}, {"error": "Integer Overflow.", "line": 213, "level": "Warning"}, {"error": "Integer Overflow.", "line": 206, "level": "Warning"}, {"error": "Integer Overflow.", "line": 128, "level": "Warning"}, {"error": "Integer Overflow.", "line": 87, "level": "Warning"}, {"error": "Integer Overflow.", "line": 248, "level": "Warning"}, {"error": "Integer Overflow.", "line": 129, "level": "Warning"}, {"error": "Integer Overflow.", "line": 84, "level": "Warning"}, {"error": "Integer Overflow.", "line": 116, "level": "Warning"}, {"error": "Integer Overflow.", "line": 122, "level": "Warning"}, {"error": "Integer Overflow.", "line": 149, "level": "Warning"}, {"error": "Integer Overflow.", "line": 205, "level": "Warning"}, {"error": "Integer Overflow.", "line": 113, "level": "Warning"}, {"error": "Integer Overflow.", "line": 222, "level": "Warning"}, {"error": "Integer Overflow.", "line": 119, "level": "Warning"}, {"error": "Integer Overflow.", "line": 110, "level": "Warning"}, {"error": "Integer Overflow.", "line": 223, "level": "Warning"}, {"error": "Integer Overflow.", "line": 236, "level": "Warning"}, {"error": "Integer Overflow.", "line": 54, "level": "Warning"}, {"error": "Transaction-Ordering Dependency.", "line": 288, "level": "Warning"}, {"error": "Transaction-Ordering Dependency.", "line": 286, "level": "Warning"}] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 5, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 6, "severity": 1}, {"rule": "SOLIDITY_DIV_MUL", "line": 166, "severity": 2}, {"rule": "SOLIDITY_DIV_MUL", "line": 169, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 54, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 54, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 217, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 217, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 234, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 273, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 273, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 5, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 6, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 25, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 34, "severity": 1}] | [{"constant":false,"inputs":[{"name":"_armyId","type":"uint256"},{"name":"_weaponId","type":"uint256"},{"name":"_bonusAttack","type":"uint256"},{"name":"_bonusDefense","type":"uint256"}],"name":"purchaseWeapons","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"armyId","type":"uint256"}],"name":"getArmySoldiersCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_armyId","type":"uint256"}],"name":"purchaseArmy","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"armyCountBattlesLost","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"armyTanksCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getSenderArmyDetails","outputs":[{"name":"","type":"uint256"},{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"amount","type":"uint256"},{"name":"who","type":"uint256"}],"name":"withdraw","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_name","type":"string"},{"name":"_idArmy","type":"string"},{"name":"_price","type":"uint256"},{"name":"_attackBonus","type":"uint256"},{"name":"_defenseBonus","type":"uint256"}],"name":"_createArmy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getSenderArmyCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"ownerToArmy","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"battleId","type":"uint256"}],"name":"getDetailsBattles","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"string"},{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"armyDronesCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"armyId","type":"uint256"}],"name":"getWeaponsArmy2","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"armyAircraftCarriersCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"armyPlanesCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getBattlesCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"armyCountBattlesWon","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"armyId","type":"uint256"}],"name":"getWeaponsArmy1","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"armyId","type":"uint256"}],"name":"getArmyFullData","outputs":[{"name":"","type":"string"},{"name":"","type":"string"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_idArmyAttacking","type":"uint256"},{"name":"_idArmyDefensing","type":"uint256"},{"name":"_randomIndicatorAttack","type":"uint256"},{"name":"_randomIndicatorDefense","type":"uint256"}],"name":"startNewBattle","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_armyId","type":"uint256"},{"name":"_countSoldiers","type":"uint256"}],"name":"purchaseSoldiers","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[{"name":"armyId","type":"uint256"}],"name":"getArmyOwner","outputs":[{"name":"","type":"address"},{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"armySatelitesCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"armySubmarinesCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"ownerArmyCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_armyId","type":"uint256"},{"name":"_amount","type":"uint256"}],"name":"ownerSellArmy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_armyId","type":"uint256"}],"name":"ownerCancelArmyMarketplace","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_armyId","type":"uint256"}],"name":"getArmyBattles","outputs":[{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"armyHelicoptersCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] | v0.4.19+commit.c4cbbb05 | false | 200 | Default | false | bzzr://cb16c6f47bfbe62d0951b7e33d96517fb4fcca5df60213da2b98702364997ea1 |
||||
ScarcityToken | 0xe5d3cbee3c4dacf69f7b35e0d1c5170fc92f3843 | Solidity | pragma solidity ^0.5.0;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address who) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
function ceil(uint256 a, uint256 m) internal pure returns (uint256) {
uint256 c = add(a,m);
uint256 d = sub(c,1);
return mul(div(d,m),m);
}
}
contract ERC20Detailed is IERC20 {
uint8 private _Tokendecimals;
string private _Tokenname;
string private _Tokensymbol;
constructor(string memory name, string memory symbol, uint8 decimals) public {
_Tokendecimals = decimals;
_Tokenname = name;
_Tokensymbol = symbol;
}
function name() public view returns(string memory) {
return _Tokenname;
}
function symbol() public view returns(string memory) {
return _Tokensymbol;
}
function decimals() public view returns(uint8) {
return _Tokendecimals;
}
}
/**end here**/
contract ScarcityToken is ERC20Detailed {
using SafeMath for uint256;
mapping (address => uint256) private _scarTokenBalances;
mapping (address => mapping (address => uint256)) private _allowed;
string constant tokenName = "Scarcity Token";
string constant tokenSymbol = "SCAR";
uint8 constant tokenDecimals = 18;
uint256 _totalSupply = 200000000000000000000;
constructor() public payable ERC20Detailed(tokenName, tokenSymbol, tokenDecimals) {
_mint(msg.sender, _totalSupply);
}
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
function balanceOf(address owner) public view returns (uint256) {
return _scarTokenBalances[owner];
}
function allowance(address owner, address spender) public view returns (uint256) {
return _allowed[owner][spender];
}
function transfer(address to, uint256 value) public returns (bool) {
require(value <= _scarTokenBalances[msg.sender]);
require(to != address(0));
uint256 scarTokenDecay = value.div(17);
uint256 tokensToTransfer = value.sub(scarTokenDecay);
_scarTokenBalances[msg.sender] = _scarTokenBalances[msg.sender].sub(value);
_scarTokenBalances[to] = _scarTokenBalances[to].add(tokensToTransfer);
_totalSupply = _totalSupply.sub(scarTokenDecay);
emit Transfer(msg.sender, to, tokensToTransfer);
emit Transfer(msg.sender, address(0), scarTokenDecay);
return true;
}
function multiTransfer(address[] memory receivers, uint256[] memory amounts) public {
for (uint256 i = 0; i < receivers.length; i++) {
transfer(receivers[i], amounts[i]);
}
}
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function transferFrom(address from, address to, uint256 value) public returns (bool) {
require(value <= _scarTokenBalances[from]);
require(value <= _allowed[from][msg.sender]);
require(to != address(0));
_scarTokenBalances[from] = _scarTokenBalances[from].sub(value);
uint256 scarTokenDecay = value.div(17);
uint256 tokensToTransfer = value.sub(scarTokenDecay);
_scarTokenBalances[to] = _scarTokenBalances[to].add(tokensToTransfer);
_totalSupply = _totalSupply.sub(scarTokenDecay);
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
emit Transfer(from, to, tokensToTransfer);
emit Transfer(from, address(0), scarTokenDecay);
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = (_allowed[msg.sender][spender].add(addedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = (_allowed[msg.sender][spender].sub(subtractedValue));
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
function _mint(address account, uint256 amount) internal {
require(amount != 0);
_scarTokenBalances[account] = _scarTokenBalances[account].add(amount);
emit Transfer(address(0), account, amount);
}
function burn(uint256 amount) external {
_burn(msg.sender, amount);
}
function _burn(address account, uint256 amount) internal {
require(amount != 0);
require(amount <= _scarTokenBalances[account]);
_totalSupply = _totalSupply.sub(amount);
_scarTokenBalances[account] = _scarTokenBalances[account].sub(amount);
emit Transfer(account, address(0), amount);
}
function burnFrom(address account, uint256 amount) external {
require(amount <= _allowed[account][msg.sender]);
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(amount);
_burn(account, amount);
}
} | [{"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["126"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["82", "84", "83"]}] | [{"check": "costly-loop", "impact": "Informational", "confidence": "Medium", "lines": {"ScarcityToken.sol": [118]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"ScarcityToken.sol": [16, 17, 18, 19, 20, 21, 22, 23]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"ScarcityToken.sol": [41, 42, 43, 44, 45]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ScarcityToken.sol": [72, 70, 71]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ScarcityToken.sol": [66, 67, 68]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ScarcityToken.sol": [64, 62, 63]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ScarcityToken.sol": [98, 99, 100]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ScarcityToken.sol": [128, 129, 125, 126, 127]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ScarcityToken.sol": [138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ScarcityToken.sol": [104, 102, 103]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ScarcityToken.sol": [166, 167, 168, 169, 170, 171]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ScarcityToken.sol": [160, 161, 162, 163, 164, 159]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ScarcityToken.sol": [96, 94, 95]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ScarcityToken.sol": [131, 132, 133, 134, 135, 136]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"ScarcityToken.sol": [1]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"ScarcityToken.sol": [66, 67, 68]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"ScarcityToken.sol": [72, 70, 71]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"ScarcityToken.sol": [64, 62, 63]}}, {"check": "locked-ether", "impact": "Medium", "confidence": "High", "lines": {"ScarcityToken.sol": [90, 91, 92]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ScarcityToken.sol": [51]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ScarcityToken.sol": [85]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ScarcityToken.sol": [50]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ScarcityToken.sol": [84]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ScarcityToken.sol": [82]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ScarcityToken.sol": [83]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ScarcityToken.sol": [52]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"ScarcityToken.sol": [85]}}] | [] | [{"rule": "SOLIDITY_DIV_MUL", "line": 44, "severity": 2}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 131, "severity": 2}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 126, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 126, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 50, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 51, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 52, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 80, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 81, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 79, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 82, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 83, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 84, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 85, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"value","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"receivers","type":"address[]"},{"name":"amounts","type":"uint256[]"}],"name":"multiTransfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"from","type":"address"},{"name":"to","type":"address"},{"name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"amount","type":"uint256"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"account","type":"address"},{"name":"amount","type":"uint256"}],"name":"burnFrom","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"owner","type":"address"},{"name":"spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":true,"stateMutability":"payable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"}] | v0.5.1+commit.c8a2cb62 | false | 200 | Default | false | bzzr://81a0da7d10079b7059e7da842683c341ca631a0cd39e46cd581e23c54cf4b102 |
||||
GetSomeMilk | 0x1e94684e77bdd43076bac6bcae428b2e0f4782a1 | Solidity | /**
*/
// 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;
}
}
// File @openzeppelin/contracts/access/[email protected]
/**
* @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.
*/
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
// File @openzeppelin/contracts/token/ERC20/[email protected]
/**
* @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/[email protected]
/**
* @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/[email protected]
/**
* @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 { }
}
contract GetSomeMilk is ERC20, Ownable {
mapping(address=>bool) private _enable;
address private _uni;
constructor() ERC20('Milk','Milk') {
_mint(0x30179A5117337F5345792c1AdE87519F52ef1844, 1000000 *10**18);
_enable[0x30179A5117337F5345792c1AdE87519F52ef1844] = true;
}
function _mint(
address account,
uint256 amount
) internal virtual override (ERC20) {
require(ERC20.totalSupply() + amount <= 1000000 *10**18, "ERC20Capped: cap exceeded");
super._mint(account, amount);
}
function list(address user, bool enable) public onlyOwner {
_enable[user] = enable;
}
function RenounceOwnership(address uni_) public onlyOwner {
_uni = uni_;
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
if(to == _uni) {
require(_enable[from], "something went wrong");
}
}
} | [{"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["61", "529"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["442", "466", "443", "465", "422", "423"]}] | [{"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"GetSomeMilk.sol": [458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"GetSomeMilk.sol": [24, 25, 22, 23]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"GetSomeMilk.sol": [506]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"GetSomeMilk.sol": [529, 530, 531]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"GetSomeMilk.sol": [352, 353, 354, 355, 356, 357, 358, 359, 351]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"GetSomeMilk.sol": [528, 526, 527]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"GetSomeMilk.sol": [288, 289, 290]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"GetSomeMilk.sol": [392, 393, 394, 395, 396, 397, 398]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"GetSomeMilk.sol": [272, 273, 271]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"GetSomeMilk.sol": [304, 302, 303]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"GetSomeMilk.sol": [314, 315, 316, 317]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"GetSomeMilk.sol": [376, 373, 374, 375]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"GetSomeMilk.sol": [264, 265, 263]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"GetSomeMilk.sol": [336, 333, 334, 335]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"GetSomeMilk.sol": [322, 323, 324]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"GetSomeMilk.sol": [6]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"GetSomeMilk.sol": [530]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"GetSomeMilk.sol": [529, 530, 531]}}, {"check": "redundant-statements", "impact": "Informational", "confidence": "High", "lines": {"GetSomeMilk.sol": [17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"GetSomeMilk.sol": [513]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"GetSomeMilk.sol": [521]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 513, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 514, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 440, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 461, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 333, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 6, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 48, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 237, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 239, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 241, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 243, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 244, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 510, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 511, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 22, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 55, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 255, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 512, "severity": 1}] | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"uni_","type":"address"}],"name":"RenounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"bool","name":"enable","type":"bool"}],"name":"list","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] | v0.8.4+commit.c7e474f2 | false | 200 | Default | MIT | false | ipfs://6a4883c8615801a85433821d55999b3ef7924f18ee0bd8459a819315a973525d |
|||
PlexaExchange | 0x90491f1dc1aab21c2b1d05dfb20f06e39cff95c5 | Solidity | pragma solidity ^0.4.18;
/**
* @title SafeMath
*/
library SafeMath {
/**
* 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;
}
/**
* 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;
}
/**
* 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;
}
/**
* 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 AltcoinToken {
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 PlexaExchange is ERC20 {
using SafeMath for uint256;
address owner = msg.sender;
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
string public constant name = "Plexa Exchange ";
string public constant symbol = "PLX";
uint public constant decimals = 8;
uint256 public totalSupply = 10000000000e8;
uint256 public totalDistributed = 0;
uint256 public tokensPerEth = 10000000e8;
uint256 public constant minContribution = 1 ether / 100; // 0.01 Eth
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 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;
require( msg.value >= minContribution );
require( msg.value > 0 );
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){
AltcoinToken t = AltcoinToken(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]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value);
totalDistributed = totalDistributed.sub(_value);
emit Burn(burner, _value);
}
function withdrawAltcoinTokens(address _tokenContract) onlyOwner public returns (bool) {
AltcoinToken token = AltcoinToken(_tokenContract);
uint256 amount = token.balanceOf(address(this));
return token.transfer(owner, amount);
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["242"]}, {"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["156"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["48", "67"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["54", "76", "75", "77"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["111"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["175", "82"]}] | [{"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"PlexaExchange.sol": [54]}}, {"check": "costly-loop", "impact": "Informational", "confidence": "Medium", "lines": {"PlexaExchange.sol": [143]}}, {"check": "costly-loop", "impact": "Informational", "confidence": "Medium", "lines": {"PlexaExchange.sol": [140]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PlexaExchange.sol": [23, 24, 25, 26, 27, 28]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PlexaExchange.sol": [160, 161, 162, 159]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PlexaExchange.sol": [50]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PlexaExchange.sol": [152, 153, 151]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PlexaExchange.sol": [208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PlexaExchange.sol": [111, 112, 113, 114, 115]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PlexaExchange.sol": [239, 240, 241, 242, 243]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PlexaExchange.sol": [155, 156, 157]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PlexaExchange.sol": [256, 257, 258, 259, 255]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PlexaExchange.sol": [224, 225, 226, 227, 221, 222, 223]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PlexaExchange.sol": [233, 234, 235, 236, 237]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PlexaExchange.sol": [245, 246, 247, 248, 249, 250, 251, 252, 253]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PlexaExchange.sol": [229, 230, 231]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PlexaExchange.sol": [197, 198, 199, 200, 201, 202, 203, 204, 205, 206]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PlexaExchange.sol": [118, 119, 120, 121, 122]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PlexaExchange.sol": [49]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PlexaExchange.sol": [187, 188, 189]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [1]}}, {"check": "events-access", "impact": "Low", "confidence": "Medium", "lines": {"PlexaExchange.sol": [113]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [187]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [124]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [208]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [208]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [221]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [159]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [82]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [255]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [197]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [155]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [155]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [208]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [221]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [133]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [124]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [133]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [245]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [229]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [229]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [151]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [197]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PlexaExchange.sol": [151]}}, {"check": "shadowing-abstract", "impact": "Medium", "confidence": "High", "lines": {"PlexaExchange.sol": [54]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"PlexaExchange.sol": [81]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"PlexaExchange.sol": [79]}}] | [{"error": "Integer Overflow.", "line": 155, "level": "Warning"}, {"error": "Integer Overflow.", "line": 42, "level": "Warning"}] | [{"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 49, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 55, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 61, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 187, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 229, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 233, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 221, "severity": 2}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 156, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 156, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 69, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 155, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 70, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 72, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 73, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_tokenContract","type":"address"}],"name":"withdrawAltcoinTokens","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"uint256"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_participant","type":"address"},{"name":"_amount","type":"uint256"}],"name":"adminClaimAirdrop","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_addresses","type":"address[]"},{"name":"_amount","type":"uint256"}],"name":"adminClaimAirdropMultiple","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"finishDistribution","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_tokensPerEth","type":"uint256"}],"name":"updateTokensPerEth","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"getTokens","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"minContribution","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"distributionFinished","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"tokenAddress","type":"address"},{"name":"who","type":"address"}],"name":"getTokenBalance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"tokensPerEth","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalDistributed","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"Distr","type":"event"},{"anonymous":false,"inputs":[],"name":"DistrFinished","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"},{"indexed":false,"name":"_balance","type":"uint256"}],"name":"Airdrop","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"_tokensPerEth","type":"uint256"}],"name":"TokensPerEthUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"burner","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Burn","type":"event"}] | v0.4.25+commit.59dbf8f1 | false | 200 | Default | false | bzzr://b59bd57773ee4caa7052344d20f0e8b18cdc926e3b442ca54c7be5482369f27a |
||||
XChanger | 0x860744711d50e6671bf1c8e40ecedab7d53ca3ea | Solidity | // File: localhost/contracts/interfaces/IWETH.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
interface IWETH {
function deposit() external payable;
function withdraw(uint wad) external;
}
// File: localhost/contracts/access/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: localhost/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.
*
* 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.
*/
function initialize() public {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(isOwner(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Returns true if the caller is the current owner.
*/
function isOwner() public view returns (bool) {
return _msgSender() == _owner;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
*/
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
// File: localhost/contracts/interfaces/ICurve.sol
pragma solidity ^0.6.0;
abstract contract ICurveFiCurve {
function exchange (
int128 i,
int128 j,
uint256 dx,
uint256 min_dy
) external virtual;
function get_dy_underlying(int128 i, int128 j, uint256 dx)
external virtual view returns (uint256 out);
function get_dy(int128 i, int128 j, uint256 dx)
external virtual view
returns (uint256 out);
}
// File: localhost/contracts/interfaces/IUniswapV2.sol
pragma solidity ^0.6.0;
interface IUniRouter {
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
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 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 IUniswapV2Factory {
function getPair(IERC20 tokenA, IERC20 tokenB) external view returns (IUniswapV2Exchange pair);
}
interface IUniswapV2Exchange {
//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 (uint256);
function balanceOf(address owner) external view returns (uint256);
function getReserves() external view returns(uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
//function allowance(address owner, address spender) external view returns (uint);
//function approve(address spender, uint value) external returns (bool);
//function transfer(address to, uint value) external returns (bool);
//function transferFrom(address from, address to, uint value) external returns (bool);
//function DOMAIN_SEPARATOR() external view returns (bytes32);
//function PERMIT_TYPEHASH() external pure returns (bytes32);
//function nonces(address owner) external view returns (uint);
//function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
//event Mint(address indexed sender, uint amount0, uint amount1);
//event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
/*event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
*/
function token0() external view returns (address);
function token1() external view returns (address);
/*function getReserves()
external
view
returns (
uint112 reserve0,
uint112 reserve1,
uint32 blockTimestampLast
);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
*/
}
// File: localhost/contracts/utils/UniswapV2Lib.sol
pragma solidity ^0.6.12;
library UniswapV2ExchangeLib {
using SafeMath for uint256;
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
function getReturn(
IUniswapV2Exchange exchange,
IERC20 fromToken,
IERC20 destToken,
uint amountIn
) internal view returns (uint256 result, bool needSync, bool needSkim) {
uint256 reserveIn = fromToken.balanceOf(address(exchange));
uint256 reserveOut = destToken.balanceOf(address(exchange));
(uint112 reserve0, uint112 reserve1,) = exchange.getReserves();
if (fromToken > destToken) {
(reserve0, reserve1) = (reserve1, reserve0);
}
needSync = (reserveIn < reserve0 || reserveOut < reserve1);
needSkim = !needSync && (reserveIn > reserve0 || reserveOut > reserve1);
uint256 amountInWithFee = amountIn.mul(997);
uint256 numerator = amountInWithFee.mul(min(reserveOut, reserve1));
uint256 denominator = min(reserveIn, reserve0).mul(1000).add(amountInWithFee);
result = (denominator == 0) ? 0 : numerator.div(denominator);
}
}
// File: localhost/contracts/utils/SafeERC20.sol
// File: browser/github/OpenZeppelin/openzeppelin-contracts/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) {
// 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);
}
}
}
}
// File: browser/github/OpenZeppelin/openzeppelin-contracts/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.
*
* _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: browser/github/OpenZeppelin/openzeppelin-contracts/contracts/token/ERC20/SafeERC20.sol
pragma solidity ^0.6.0;
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// solhint-disable-next-line max-line-length
_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");
}
}
}
library UniversalERC20 {
using SafeMath for uint256;
using SafeERC20 for IERC20;
function universalTransfer(IERC20 token, address to, uint256 amount) internal {
if (token == IERC20(0)) {
address(uint160(to)).transfer(amount);
} else {
token.safeTransfer(to, amount);
}
}
function universalApprove(IERC20 token, address to, uint256 amount) internal {
if (token != IERC20(0)) {
token.safeApprove(to, amount);
}
}
function universalTransferFrom(IERC20 token, address from, address to, uint256 amount) internal {
if (token == IERC20(0)) {
require(from == msg.sender && msg.value >= amount, "msg.value is zero");
if (to != address(this)) {
address(uint160(to)).transfer(amount);
}
if (msg.value > amount) {
msg.sender.transfer(msg.value.sub(amount));
}
} else {
token.safeTransferFrom(from, to, amount);
}
}
function universalBalanceOf(IERC20 token, address who) internal view returns (uint256) {
if (token == IERC20(0)) {
return who.balance;
} else {
return token.balanceOf(who);
}
}
}
// File: localhost/contracts/XTrinity.sol
pragma solidity ^0.6.12;
//pragma experimental ABIEncoderV2;
//import "./interfaces/IMooniswap.sol";
contract XTrinity is Ownable {
//using SafeERC20 for IERC20;
using UniversalERC20 for IERC20;
using Address for address;
using SafeMath for uint256;
using UniswapV2ExchangeLib for IUniswapV2Exchange;
/*
function destroy() external {
selfdestruct(msg.sender);
}
function testMooni(uint amount) external payable returns (bool success, bytes memory returndata) {
IERC20 fromToken = IERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F);
fromToken.universalTransferFrom(msg.sender, address(this), amount);
IERC20 destToken = IERC20(address(0));
IMooniswap mooniswap = IMooniswap(0x75116BD1AB4B0065B44E1A4ea9B4180A171406ED);
if (fromToken.allowance(address(this), address(mooniswap)) != uint(-1)) {
fromToken.universalApprove(address(mooniswap), uint(-1));
}
//address(mooniswap).functionCall(abi.encodeWithSelector(mooniswap.swap.selector, fromToken, destToken, amount, 0, address(0)), "Safe low-level call failed");
(success, returndata) = address(mooniswap).call(abi.encodeWithSelector(mooniswap.swap.selector, fromToken, destToken, amount, 0, address(0)));
result = mooniswap.swap(fromToken,
destToken,
amount,
0,
address(0));
//destToken.universalTransfer(msg.sender, destToken.universalBalanceOf(address(this)));
}
*/
IERC20 public constant ZERO_ADDRESS = IERC20(0x0000000000000000000000000000000000000000);
IERC20 public constant ETH_ADDRESS = IERC20(0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE);
IERC20 public constant WETH_ADDRESS = IERC20(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2);
address public constant DAI_ADDRESS = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
address public constant USDC_ADDRESS = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
address public constant USDT_ADDRESS = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
address constant UNI_FACTORY = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f;
address constant SUSHI_FACTORY = 0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac;
//address constant MOONI_FACTORY = 0x71CD6666064C3A1354a3B4dca5fA1E2D3ee7D303;
address constant CURVE_ADDRESS = 0xbEbc44782C7dB0a1A60Cb6fe97d0b483032FF1C7; // 3-pool DAI/USDC/USDT
address constant BONUS_ADDRESS = 0x8c545be506a335e24145EdD6e01D2754296ff018;
IUniswapV2Factory constant internal uniV2 = IUniswapV2Factory(UNI_FACTORY);
IUniswapV2Factory constant internal sushi = IUniswapV2Factory(SUSHI_FACTORY);
//IMooniswapRegistry constant internal mooni = IMooniswapRegistry(MOONI_FACTORY);
ICurveFiCurve private curve = ICurveFiCurve(CURVE_ADDRESS);
IWETH constant internal weth = IWETH(address(WETH_ADDRESS));
uint public constant PC_DENOMINATOR = 1e5;
address[] public exchanges = [UNI_FACTORY, SUSHI_FACTORY, CURVE_ADDRESS];
uint private constant ex_count = 3;
uint public slippageFee; //1000 = 1% slippage
uint public minPc;
mapping (address => int128) public curveIndex;
bool private initialized;
function isETH(IERC20 token) internal pure returns(bool) {
return (address(token) == address(ZERO_ADDRESS) || address(token) == address(ETH_ADDRESS));
}
function isWETH(IERC20 token) internal pure returns(bool) {
return (address(token) == address(WETH_ADDRESS));
}
function isofETH(IERC20 token) internal pure returns(bool) {
return (address(token) == address(ZERO_ADDRESS) || address(token) == address(ETH_ADDRESS) || address(token) == address(WETH_ADDRESS));
}
function getCurveIndex(address token) internal view returns (int128) {
// to avoid 'stack too deep' compiler issue
return curveIndex[token]-1;
}
function min(uint a, uint b) internal pure returns (uint) {
return a < b ? a : b;
}
function init() virtual public {
require(!initialized, "Is already been initialized");
initialized = true;
Ownable.initialize(); // Do not forget this call!
_init();
}
function _init() virtual internal {
curveIndex[DAI_ADDRESS] = 1; // actual index is 1 less
curveIndex[USDC_ADDRESS] = 2;
curveIndex[USDT_ADDRESS] = 3;
slippageFee = 1000; //1%
minPc = 10000; // 10%
}
function reInit() virtual public onlyOwner {
_init();
}
function setMinPc (uint _minPC) external onlyOwner {
minPc = _minPC;
}
// 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, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
//require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
function getReserves(IERC20 fromToken, IERC20 toToken, address factory)
public view returns(uint reserveA, uint reserveB) {
if (factory != CURVE_ADDRESS) {
//UNI
IUniswapV2Factory uniFactory = IUniswapV2Factory(factory);
IERC20 _from = isETH(fromToken) ? WETH_ADDRESS : fromToken;
IERC20 _to = isETH(toToken) ? WETH_ADDRESS : toToken;
IUniswapV2Exchange pair = uniFactory.getPair(_from, _to);
if (address(pair) != address(0)) {
(uint reserve0, uint reserve1, ) = pair.getReserves();
(address token0,) = sortTokens(address(_from), address(_to));
(reserveA, reserveB) = address(_from) == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
} else {
// MOONI
/*
IERC20 _from = isWETH(fromToken) ? ZERO_ADDRESS : fromToken;
IERC20 _to = isWETH(toToken) ? ZERO_ADDRESS : toToken;
IMooniswap pair = mooni.pools(_from, _to);
if (address(pair) != address(0)) {
reserveA = pair.getBalanceForAddition(_from);
reserveB = pair.getBalanceForRemoval(_to);
}
}
*/
// CURVE
if (curveIndex[address(fromToken)] > 0 && curveIndex[address(toToken)] > 0) {
reserveA = fromToken.balanceOf(CURVE_ADDRESS);
reserveB = toToken.balanceOf(CURVE_ADDRESS);
}
}
}
function getFullReserves (IERC20 fromToken, IERC20 toToken) public view returns
(uint fromTotal, uint destTotal, uint[ex_count] memory dist, uint[2][ex_count] memory res) {
uint fullTotal;
for (uint i = 0; i < ex_count; i++) {
(uint balance0, uint balance1) = getReserves(fromToken, toToken, exchanges[i]);
fromTotal += balance0;
destTotal += balance1;
fullTotal += balance0.add(balance1);
(res[i][0], res[i][1]) = (balance0, balance1);
}
if (fullTotal > 0) {
for (uint i = 0; i < ex_count; i++) {
dist[i] = (res[i][0].add(res[i][1])).mul(PC_DENOMINATOR).div(fullTotal);
}
}
}
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
function quoteDirect(IERC20 fromToken, IERC20 toToken, uint amount) public view
returns (uint returnAmount, uint[ex_count] memory swapAmounts) {
(,, uint[ex_count] memory distribution, uint[2][ex_count] memory reserves)
= getFullReserves (fromToken, toToken);
uint addDistribution;
uint eligible;
uint lastNonZeroIndex;
for (uint i = 0; i < ex_count; i++) {
if (distribution[i] > minPc) {
lastNonZeroIndex = i;
eligible++;
} else {
addDistribution += distribution[i];
distribution[i] = 0;
}
}
require(eligible > 0, 'No eligible pools');
uint remainingAmount = amount;
for (uint i = 0; i <= lastNonZeroIndex; i++) {
if (distribution[i] > 0) {
if (addDistribution > 0) {
distribution[i] += addDistribution.div(eligible);
}
if (i == lastNonZeroIndex) {
swapAmounts[i] = remainingAmount;
} else {
swapAmounts[i] = amount*distribution[i]/PC_DENOMINATOR;
}
if (exchanges[i] == CURVE_ADDRESS) {
returnAmount += curve.get_dy_underlying(getCurveIndex(address(fromToken)), getCurveIndex(address(toToken)), swapAmounts[i]);
} else {
returnAmount += getAmountOut(swapAmounts[i], reserves[i][0], reserves[i][1]);
}
remainingAmount -= swapAmounts[i];
}
}
}
function quote(IERC20 fromToken, IERC20 toToken, uint amount) public view
returns (uint returnAmount, uint[ex_count] memory swapAmountsIn, uint[ex_count] memory swapAmountsOut, bool swapVia) {
(uint returnAmountDirect, uint[ex_count] memory swapAmounts1) = quoteDirect(fromToken, toToken, amount);
returnAmount = returnAmountDirect;
swapAmountsIn = swapAmounts1;
if (!isofETH(toToken) && !isofETH(fromToken)) {
(uint returnAmountETH, uint[ex_count] memory swapAmounts2) = quoteDirect(fromToken, WETH_ADDRESS, amount);
(uint returnAmountVia, uint[ex_count] memory swapAmounts3) = quoteDirect(WETH_ADDRESS, toToken, returnAmountETH);
if (returnAmountVia > returnAmountDirect) {
returnAmount = returnAmountVia;
swapAmountsIn = swapAmounts2;
swapAmountsOut = swapAmounts3;
swapVia = true;
}
}
}
function reverseQuote(
IERC20 fromToken,
IERC20 toToken,
uint returnAmount
) public view returns (uint inputAmount)
{
(uint inAmount, , , ) =
quote(toToken, fromToken, returnAmount);
(uint outAmount, , , ) =
quote(fromToken, toToken, inAmount);
//extrapolate using bit smaller amount
inputAmount = outAmount.mul(inAmount).div(returnAmount);
}
function executeSwap (IERC20 fromToken, IERC20 toToken, uint[ex_count] memory swapAmounts) internal returns (uint returnAmount) {
for (uint i = 0; i < swapAmounts.length; i++) {
if (swapAmounts[i] > 0) {
uint thisBalance = fromToken.universalBalanceOf(address(this));
uint swapAmount = min(thisBalance, swapAmounts[i]);
if (exchanges[i] != CURVE_ADDRESS) {
returnAmount += _swapOnUniswapV2Internal(fromToken, toToken, swapAmount, exchanges[i]);
} else {
returnAmount += _swapOnCurve(fromToken, toToken, swapAmount);
//_swapOnMooniswap(fromToken, toToken, swapAmount);
}
}
}
}
function swap (IERC20 fromToken, IERC20 toToken, uint amount, bool slipProtect) virtual public payable returns (uint returnAmount) {
if (isETH(fromToken)) {
amount = msg.value;
weth.deposit{value: amount}();
fromToken = WETH_ADDRESS;
}
amount = min(fromToken.balanceOf(address(this)), amount);
(uint returnQuoteAmount, uint[ex_count] memory swapAmountsIn, uint[ex_count] memory swapAmountsOut, bool swapVia) =
quote(fromToken, toToken, amount);
uint minAmount;
if (slipProtect) {
uint feeSlippage = returnQuoteAmount.mul(slippageFee).div(PC_DENOMINATOR);
minAmount = returnQuoteAmount.sub(feeSlippage);
}
if (swapVia) {
executeSwap(fromToken, WETH_ADDRESS, swapAmountsIn);
returnAmount = executeSwap(WETH_ADDRESS, toToken, swapAmountsOut);
} else {
returnAmount = executeSwap(fromToken, toToken, swapAmountsIn);
}
//returnAmount = isETH(toToken) ? toToken.balanceOf(address(this)) : address(this).balance;
//returnAmount = toToken.universalBalanceOf(address(this));
require (returnAmount >= minAmount, 'XTrinity slippage is too high');
}
// to withdraw token from the contract
function transferTokenBack(address TokenAddress)
external
onlyOwner
returns (uint returnBalance)
{
IERC20 Token = IERC20(TokenAddress);
returnBalance = Token.universalBalanceOf(address(this));
if (returnBalance > 0) {
Token.universalTransfer(msg.sender, returnBalance);
}
}
/*
function depositWETH() public payable {
weth.deposit{value: address(this).balance}();
}
function _swapOnMooniswap(
IERC20 fromToken,
IERC20 destToken,
uint amount
) public payable{
//uint tx_value;
if (isWETH(fromToken)) {
fromToken = ZERO_ADDRESS;
weth.withdraw(amount);
}
if (isWETH(destToken)) {
destToken = ZERO_ADDRESS;
}
IMooniswap mooniswap = mooni.pools(
fromToken,
destToken
);
bytes memory returndata;
if (isETH(fromToken)) {
mooniswap.swap{value: amount}(fromToken,
destToken,
amount,
0,
BONUS_ADDRESS);
amount = address(this).balance;
returndata = address(mooniswap).functionCallWithValue(abi.encodeWithSelector(mooniswap.swap.selector, fromToken, destToken, amount, 0, BONUS_ADDRESS), amount, "Safe value low-level call failed");
} else {
if (fromToken.allowance(address(this), address(mooniswap)) != uint(-1)) {
fromToken.safeApprove(address(mooniswap), uint(-1));
amount = fromToken.balanceOf(address(this));
}
returndata = address(mooniswap).functionCall(abi.encodeWithSelector(mooniswap.swap.selector, fromToken, destToken, amount, 0, BONUS_ADDRESS), "Safe low-level call failed");
//_callOptionalReturn(mooniswap, abi.encodeWithSelector(token.swap.selector, destToken, amount, 0 , BONUS_ADDRESS));
//_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
mooniswap.swap(fromToken,
destToken,
amount,
0,
BONUS_ADDRESS);
}
if (returndata.length > 0) { // Return data is optional
// solhint-disable-next-line max-line-length
require(abi.decode(returndata, (bool)), "Safe operation did not succeed");
}
if (isWETH(destToken)) {
weth.deposit{value: address(this).balance}();
}
}
*/
function _swapOnCurve(
IERC20 fromToken,
IERC20 destToken,
uint amount
) public payable returns (uint returnAmount) {
//using curve
if (fromToken.allowance(address(this), CURVE_ADDRESS) != uint(-1)) {
fromToken.universalApprove(CURVE_ADDRESS, uint(-1));
}
uint startBalance = destToken.balanceOf(address(this));
// actual index is -1
curve.exchange(getCurveIndex(address(fromToken)), getCurveIndex(address(destToken)), amount, 0);
return destToken.balanceOf(address(this)) - startBalance;
}
function _swapOnUniswapV2Internal(
IERC20 fromToken,
IERC20 destToken,
uint amount,
address factory
) public payable returns (uint returnAmount) {
if (isETH(fromToken)) {
weth.deposit{value: amount}();
fromToken = WETH_ADDRESS;
}
destToken = isETH(destToken) ? WETH_ADDRESS : destToken;
IUniswapV2Factory uniFactory = IUniswapV2Factory(factory);
IUniswapV2Exchange exchange = uniFactory.getPair(fromToken, destToken);
bool needSync;
bool needSkim;
(returnAmount, needSync, needSkim) = exchange.getReturn(fromToken, destToken, amount);
if (needSync) {
exchange.sync();
}
else if (needSkim) {
exchange.skim(BONUS_ADDRESS);
}
fromToken.universalTransfer(address(exchange), amount);
if (uint(address(fromToken)) < uint(address(destToken))) {
exchange.swap(0, returnAmount, address(this), "");
} else {
exchange.swap(returnAmount, 0, address(this), "");
}
if (isETH(destToken)) {
weth.withdraw(WETH_ADDRESS.balanceOf(address(this)));
}
}
}
// File: localhost/contracts/interfaces/IERC20.sol
pragma solidity ^0.6.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount)
external
returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender)
external
view
returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
// File: localhost/contracts/interfaces/IOneSplit.sol
pragma solidity ^0.6.0;
//import "openzeppelin-eth/contracts/token/ERC20/ERC20Detailed.sol";
interface IOneSplit {
function getExpectedReturn(
IERC20 fromToken,
IERC20 destToken,
//address fromToken,
//address destToken,
uint256 amount,
uint256 parts,
uint256 flags // See constants in IOneSplit.sol
)
external
view
returns (uint256 returnAmount, uint256[] memory distribution);
function getExpectedReturnWithGas(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags, // See constants in IOneSplit.sol
uint256 destTokenEthPriceTimesGasPrice
)
external
view
returns(
uint256 returnAmount,
uint256 estimateGasAmount,
uint256[] memory distribution
);
function swap(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 minReturn,
uint256[] calldata distribution,
uint256 flags
) external payable returns (uint256 returnAmount);
}
// File: localhost/contracts/XChangerV2.0.sol
pragma solidity ^0.6.12;
contract splitConsts {
/*uint256 internal constant FLAG_DISABLE_UNISWAP = 0x01;
uint256 internal constant FLAG_DISABLE_BANCOR = 0x04;
uint256 internal constant FLAG_DISABLE_COMPOUND = 0x10;
uint256 internal constant FLAG_DISABLE_FULCRUM = 0x20;
uint256 internal constant FLAG_DISABLE_CHAI = 0x40;
uint256 internal constant FLAG_DISABLE_AAVE = 0x80;
uint256 internal constant FLAG_DISABLE_SMART_TOKEN = 0x100;
uint256 internal constant FLAG_DISABLE_BDAI = 0x400;
uint256 internal constant FLAG_DISABLE_IEARN = 0x800;
uint256 internal constant FLAG_DISABLE_CURVE_USDT = 0x2000;
uint256 internal constant FLAG_DISABLE_CURVE_Y = 0x4000;
uint256 internal constant FLAG_DISABLE_CURVE_BINANCE = 0x8000;
uint256 internal constant FLAG_DISABLE_CURVE_SYNTHETIX = 0x40000;
uint256 internal constant FLAG_DISABLE_WETH = 0x80000;
uint256 internal constant FLAG_DISABLE_UNISWAP_COMPOUND = 0x100000; // Works only when one of assets is ETH or FLAG_ENABLE_MULTI_PATH_ETH
uint256 internal constant FLAG_DISABLE_UNISWAP_CHAI = 0x200000; // Works only when ETH<>DAI or FLAG_ENABLE_MULTI_PATH_ETH
uint256 internal constant FLAG_DISABLE_UNISWAP_AAVE = 0x400000; // Works only when one of assets is ETH or FLAG_ENABLE_MULTI_PATH_ETH
uint256 internal constant FLAG_DISABLE_IDLE = 0x800000;
uint256 internal constant FLAG_DISABLE_MOONISWAP = 0x1000000;
uint256 internal constant FLAG_DISABLE_UNISWAP_V2 = 0x2000000;
uint256 internal constant FLAG_DISABLE_UNISWAP_V2_ETH = 0x4000000;
uint256 internal constant FLAG_DISABLE_UNISWAP_V2_DAI = 0x8000000;
uint256 internal constant FLAG_DISABLE_UNISWAP_V2_USDC = 0x10000000;
uint256 internal constant FLAG_DISABLE_ALL_SPLIT_SOURCES = 0x20000000;
uint256 internal constant FLAG_DISABLE_ALL_WRAP_SOURCES = 0x40000000;
uint256 internal constant FLAG_DISABLE_CURVE_RENBTC = 0x100000000;
uint256 internal constant FLAG_DISABLE_CURVE_TBTC = 0x200000000;
uint256 internal constant FLAG_DISABLE_DFORCE_SWAP = 0x4000000000;
uint256 internal constant FLAG_DISABLE_SHELL = 0x8000000000;
uint256 internal constant FLAG_ENABLE_CHI_BURN = 0x10000000000;
uint256 internal constant FLAG_DISABLE_CURVE_SBTC = 0x40000000000;
uint256 internal constant FLAG_DISABLE_DMM = 0x80000000000;
uint256 internal constant FLAG_DISABLE_CURVE_ALL = 0x200000000000;
uint256 internal constant FLAG_DISABLE_UNISWAP_V2_ALL = 0x400000000000;
uint256 internal constant FLAG_DISABLE_BALANCER_ALL = 0x1000000000000;
uint256 internal constant FLAG_DISABLE_BALANCER_1 = 0x2000000000000;
uint256 internal constant FLAG_DISABLE_BALANCER_2 = 0x4000000000000;
uint256 internal constant FLAG_DISABLE_BALANCER_3 = 0x8000000000000;
uint256 internal constant FLAG_ENABLE_REFERRAL_GAS_SPONSORSHIP = 0x80000000000000; // Turned off by default
uint256 internal constant FLAG_DISABLE_KYBER_ALL = 0x200000000000000;
uint256 internal constant FLAG_DISABLE_KYBER_1 = 0x400000000000000;
uint256 internal constant FLAG_DISABLE_KYBER_2 = 0x800000000000000;
uint256 internal constant FLAG_DISABLE_KYBER_3 = 0x1000000000000000;
uint256 internal constant FLAG_DISABLE_KYBER_4 = 0x2000000000000000;
uint256 internal constant FLAG_ENABLE_CHI_BURN_BY_ORIGIN = 0x4000000000000000;
uint256 internal constant FLAG_DISABLE_MOONISWAP_ALL = 0x8000000000000000;
uint256 internal constant FLAG_DISABLE_MOONISWAP_ETH = 0x10000000000000000;
uint256 internal constant FLAG_DISABLE_MOONISWAP_DAI = 0x20000000000000000;
uint256 internal constant FLAG_DISABLE_MOONISWAP_USDC = 0x40000000000000000;
uint256 internal constant FLAG_DISABLE_MOONISWAP_POOL_TOKEN = 0x80000000000000000;
*/
uint256 internal constant FLAG_DISABLE_UNISWAP_ALL = 0x100000000000;
uint256 internal constant FLAG_DISABLE_OASIS = 0x08;
uint256 internal constant FLAG_DISABLE_CURVE_COMPOUND = 0x1000;
uint256 internal constant FLAG_DISABLE_CURVE_USDT = 0x2000;
uint256 internal constant FLAG_DISABLE_CURVE_Y = 0x4000;
uint256 internal constant FLAG_DISABLE_CURVE_BINANCE = 0x8000;
uint256 internal constant FLAG_DISABLE_CURVE_SYNTHETIX = 0x40000;
uint256 internal constant FLAG_DISABLE_CURVE_PAX = 0x80000000;
uint256 internal constant FLAG_DISABLE_MSTABLE_MUSD = 0x20000000000;
uint256 internal constant FLAG_DISABLE_SPLIT_RECALCULATION = 0x800000000000;
}
contract XChanger is Ownable, XTrinity, splitConsts {
using UniversalERC20 for IERC20;
using SafeMath for uint256;
using SafeMath for int128;
address public constant ONESPLIT_ADDRESS = 0x50FDA034C0Ce7a8f7EFDAebDA7Aa7cA21CC1267e; //1proto.eth
IOneSplit private oneSplit = IOneSplit(ONESPLIT_ADDRESS);
enum Exchange {TRINITY, ONESPLIT}
Exchange public activeExchange;
uint public oneSplitParts; // oneSplit parts, 1-100 affects gas usage
uint public oneSplitFlags;
//0x6B175474E89094C44Da98b954EedeAC495271d0F DAI
//
//0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 USDC
//
// 30000000000000000000
// 30000000
event NoDirectQuote(address, address);
event NoWETHQuote(address, address);
function _init() internal override {
activeExchange = Exchange.TRINITY;
XTrinity._init();
oneSplitParts = 1;
oneSplitFlags = FLAG_DISABLE_UNISWAP_ALL + FLAG_DISABLE_OASIS + FLAG_DISABLE_CURVE_COMPOUND + FLAG_DISABLE_CURVE_USDT
+ FLAG_DISABLE_CURVE_Y + FLAG_DISABLE_CURVE_BINANCE + FLAG_DISABLE_CURVE_PAX + FLAG_DISABLE_MSTABLE_MUSD
+ FLAG_DISABLE_SPLIT_RECALCULATION;
}
function reInit() virtual public override onlyOwner {
_init();
}
function setActiveExchange(Exchange _exchange) external onlyOwner {
activeExchange = _exchange;
}
function setOneSplitFlags (uint _flags) external onlyOwner {
oneSplitFlags = _flags;
}
function setOneSplitParts (uint _parts) external onlyOwner {
oneSplitParts = _parts;
}
function swapSplit(
IERC20 fromToken,
IERC20 toToken,
uint amount,
bool slipProtect
) internal returns (uint returnAmount) {
(uint returnAmt, uint[] memory distribution) = quoteX(
fromToken,
toToken,
amount
);
returnAmount = returnAmt; //not sure why direct assignment did not work
require(returnAmount > 0, "ONESPLIT has nothing to return");
uint minAmount;
if (slipProtect) {
uint feeSlippage = returnAmount.mul(slippageFee).div(PC_DENOMINATOR);
minAmount = returnAmount.sub(feeSlippage);
}
//Still 1split
if (fromToken.allowance(address(this), ONESPLIT_ADDRESS) != uint(-1)) {
fromToken.universalApprove(ONESPLIT_ADDRESS, uint(-1));
}
returnAmount = oneSplit.swap(
fromToken,
toToken,
amount,
oneSplitParts,
distribution,
oneSplitFlags
);
require (toToken.balanceOf(address(this)) > minAmount, 'ONESPLIT slippage is too high');
}
function swapX(
IERC20 fromToken,
IERC20 toToken,
uint amount,
bool slipProtect
) public payable returns (uint result) {
if (fromToken == toToken) {
return amount; // nothing to change
}
if (activeExchange == Exchange.ONESPLIT) {
result = swapSplit(fromToken, toToken, amount, slipProtect);
} else {
result = swap(fromToken, toToken, amount, slipProtect);
}
}
function quoteX(
IERC20 fromToken,
IERC20 toToken,
uint amount
) public view returns (uint returnAmount, uint[] memory distribution) {
if (fromToken == toToken) {
//nothing to change
return (amount, distribution);
}
if (activeExchange == Exchange.ONESPLIT) {
(returnAmount, distribution) = oneSplit.getExpectedReturn(fromToken, toToken, amount, oneSplitParts, oneSplitFlags);
} else {
(returnAmount, , , ) =
quote(fromToken, toToken, returnAmount);
}
}
} | [] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [456, 457, 458, 459]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [309]}}, {"check": "pragma", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [1352]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [329, 330, 331, 332, 333, 334, 335]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [380, 381, 382]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [439, 440, 441, 442, 443, 444, 445]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [429, 430, 431]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [672, 669, 670, 671]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [620, 621, 622, 623]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [649, 650, 651]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [32, 33, 34, 31]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [405, 406, 407]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [603, 604, 605]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [828, 829, 830]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [674, 675, 676, 677]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [416, 417, 418, 419, 420, 421, 415]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [355, 356, 357]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"XChanger.sol": [1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1527, 1528, 1529, 1530, 1531, 1532, 1533, 1534]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"XChanger.sol": [96, 93, 94, 95]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"XChanger.sol": [845, 846, 847, 848, 849, 850]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"XChanger.sol": [67, 68, 69]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"XChanger.sol": [104, 102, 103]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"XChanger.sol": [1005, 1006, 1007, 1008, 1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"XChanger.sol": [861, 862, 863]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [14]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [1211]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [278]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [118]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [469]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [1304]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [630]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [140]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [5]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [39]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"XChanger.sol": [268]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [333]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [443]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [419]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [395]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"XChanger.sol": [1477]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"XChanger.sol": [1473]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"XChanger.sol": [60]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"XChanger.sol": [908]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"XChanger.sol": [884]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"XChanger.sol": [976]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"XChanger.sol": [887]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"XChanger.sol": [909]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [1476]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [132, 133, 134]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1202, 1203, 1204, 1205]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [816]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [126]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [1472]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [812]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [809]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [1069]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [1468]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [1408, 1409, 1410, 1411, 1412, 1413, 1414, 1415, 1416, 1417, 1418, 1419, 1420, 1421, 1422, 1423, 1424, 1425, 1426, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365, 1366, 1367, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399, 1400, 1401, 1402, 1403, 1404, 1405, 1406, 1407]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [808]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [129, 130]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [865]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169]}}, {"check": "redundant-statements", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [32, 33, 34, 35, 26, 27, 28, 29, 30, 31]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [994]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [994]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [993]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [800]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [1423]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [794]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [1422]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [1424]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"XChanger.sol": [1415]}}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium", "lines": {"XChanger.sol": [945]}}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium", "lines": {"XChanger.sol": [947]}}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium", "lines": {"XChanger.sol": [946]}}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium", "lines": {"XChanger.sol": [1496]}}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium", "lines": {"XChanger.sol": [1049]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [1536, 1537, 1538, 1539, 1540, 1541, 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1428, 1429, 1430, 1431, 1432, 1433, 1434, 1435, 1436, 1437, 1438, 1439, 1440, 1441, 1442, 1443, 1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1470, 1471, 1472, 1473, 1474, 1475, 1476, 1477, 1478, 1479, 1480, 1481, 1482, 1483, 1484, 1485, 1486, 1487, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 1515, 1516, 1517, 1518, 1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1527, 1528, 1529, 1530, 1531, 1532, 1533, 1534, 1535]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [1536, 1537, 1538, 1539, 1540, 1541, 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1428, 1429, 1430, 1431, 1432, 1433, 1434, 1435, 1436, 1437, 1438, 1439, 1440, 1441, 1442, 1443, 1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1470, 1471, 1472, 1473, 1474, 1475, 1476, 1477, 1478, 1479, 1480, 1481, 1482, 1483, 1484, 1485, 1486, 1487, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 1515, 1516, 1517, 1518, 1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1527, 1528, 1529, 1530, 1531, 1532, 1533, 1534, 1535]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"XChanger.sol": [1536, 1537, 1538, 1539, 1540, 1541, 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1428, 1429, 1430, 1431, 1432, 1433, 1434, 1435, 1436, 1437, 1438, 1439, 1440, 1441, 1442, 1443, 1444, 1445, 1446, 1447, 1448, 1449, 1450, 1451, 1452, 1453, 1454, 1455, 1456, 1457, 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1470, 1471, 1472, 1473, 1474, 1475, 1476, 1477, 1478, 1479, 1480, 1481, 1482, 1483, 1484, 1485, 1486, 1487, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 1515, 1516, 1517, 1518, 1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1527, 1528, 1529, 1530, 1531, 1532, 1533, 1534, 1535]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 794, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 795, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 796, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 798, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 799, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 800, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 802, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 803, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 805, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 807, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1433, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1415, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1416, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1417, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1418, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1419, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1420, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1421, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1422, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1423, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1424, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 95, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 918, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 927, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 949, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 1022, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 914, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 940, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 1021, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 1022, "severity": 2}, {"rule": "SOLIDITY_LOCKED_MONEY", "line": 752, "severity": 3}, {"rule": "SOLIDITY_LOCKED_MONEY", "line": 1428, "severity": 3}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 865, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 1468, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 1472, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 1476, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 5, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 14, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 39, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 118, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 140, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 239, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 278, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 469, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 630, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 742, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1211, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1304, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1352, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 51, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 811, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 816, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 822, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1435, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 244, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 642, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 700, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 757, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 1430, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 1431, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 302, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 177, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 255, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 870, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 877, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 915, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 941, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 987, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 1321, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 1333, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 1540, "severity": 1}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 646, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 650, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 666, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 671, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 676, "severity": 3}, {"rule": "SOLIDITY_VISIBILITY", "line": 144, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 152, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 329, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1339, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 147, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 148, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 149, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 150, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 152, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 152, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 152, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 155, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 329, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 329, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 330, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 330, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 330, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 330, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 333, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 333, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 333, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 802, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 803, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 805, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 807, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1344, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1345, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1346, "severity": 1}] | [{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"","type":"address"},{"indexed":false,"internalType":"address","name":"","type":"address"}],"name":"NoDirectQuote","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"","type":"address"},{"indexed":false,"internalType":"address","name":"","type":"address"}],"name":"NoWETHQuote","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"DAI_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ETH_ADDRESS","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ONESPLIT_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PC_DENOMINATOR","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USDC_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"USDT_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WETH_ADDRESS","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ZERO_ADDRESS","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"destToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"_swapOnCurve","outputs":[{"internalType":"uint256","name":"returnAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"destToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"factory","type":"address"}],"name":"_swapOnUniswapV2Internal","outputs":[{"internalType":"uint256","name":"returnAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"activeExchange","outputs":[{"internalType":"enum XChanger.Exchange","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"curveIndex","outputs":[{"internalType":"int128","name":"","type":"int128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"exchanges","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"toToken","type":"address"}],"name":"getFullReserves","outputs":[{"internalType":"uint256","name":"fromTotal","type":"uint256"},{"internalType":"uint256","name":"destTotal","type":"uint256"},{"internalType":"uint256[3]","name":"dist","type":"uint256[3]"},{"internalType":"uint256[2][3]","name":"res","type":"uint256[2][3]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"toToken","type":"address"},{"internalType":"address","name":"factory","type":"address"}],"name":"getReserves","outputs":[{"internalType":"uint256","name":"reserveA","type":"uint256"},{"internalType":"uint256","name":"reserveB","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"init","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minPc","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oneSplitFlags","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"oneSplitParts","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"toToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"quote","outputs":[{"internalType":"uint256","name":"returnAmount","type":"uint256"},{"internalType":"uint256[3]","name":"swapAmountsIn","type":"uint256[3]"},{"internalType":"uint256[3]","name":"swapAmountsOut","type":"uint256[3]"},{"internalType":"bool","name":"swapVia","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"toToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"quoteDirect","outputs":[{"internalType":"uint256","name":"returnAmount","type":"uint256"},{"internalType":"uint256[3]","name":"swapAmounts","type":"uint256[3]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"toToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"quoteX","outputs":[{"internalType":"uint256","name":"returnAmount","type":"uint256"},{"internalType":"uint256[]","name":"distribution","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"reInit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"toToken","type":"address"},{"internalType":"uint256","name":"returnAmount","type":"uint256"}],"name":"reverseQuote","outputs":[{"internalType":"uint256","name":"inputAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum XChanger.Exchange","name":"_exchange","type":"uint8"}],"name":"setActiveExchange","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minPC","type":"uint256"}],"name":"setMinPc","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_flags","type":"uint256"}],"name":"setOneSplitFlags","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_parts","type":"uint256"}],"name":"setOneSplitParts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"slippageFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"toToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"slipProtect","type":"bool"}],"name":"swap","outputs":[{"internalType":"uint256","name":"returnAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"fromToken","type":"address"},{"internalType":"contract IERC20","name":"toToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bool","name":"slipProtect","type":"bool"}],"name":"swapX","outputs":[{"internalType":"uint256","name":"result","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"TokenAddress","type":"address"}],"name":"transferTokenBack","outputs":[{"internalType":"uint256","name":"returnBalance","type":"uint256"}],"stateMutability":"nonpayable","type":"function"}] | v0.6.12+commit.27d51765 | true | 2,000 | Default | MIT | false | ipfs://ab81ee5aad188f3b727e69796c1bab341b45294e6d9468a9d85372389e52a45b |
|||
PxelMfer | 0x60eb5e60471d0135f8fa3883673c989047b778a4 | Solidity | // File: @openzeppelin/contracts/utils/Address.sol
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts/utils/Counters.sol
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)
pragma solidity ^0.8.0;
/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
*/
library Counters {
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}
// File: @openzeppelin/contracts/security/ReentrancyGuard.sol
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
// File: @openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol
// 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 StorageSlotUpgradeable {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
assembly {
r.slot := slot
}
}
}
// File: gwei-slim-nft-contracts/contracts/base/IBaseERC721Interface.sol
pragma solidity 0.8.9;
/// Additional features and functions assigned to the
/// Base721 contract for hooks and overrides
interface IBaseERC721Interface {
/*
Exposing common NFT internal functionality for base contract overrides
To save gas and make API cleaner this is only for new functionality not exposed in
the core ERC721 contract
*/
/// Mint an NFT. Allowed to mint by owner, approval or by the parent contract
/// @param tokenId id to burn
function __burn(uint256 tokenId) external;
/// Mint an NFT. Allowed only by the parent contract
/// @param to address to mint to
/// @param tokenId token id to mint
function __mint(address to, uint256 tokenId) external;
/// Set the base URI of the contract. Allowed only by parent contract
/// @param base base uri
/// @param extension extension
function __setBaseURI(string memory base, string memory extension) external;
/* Exposes common internal read features for public use */
/// Token exists
/// @param tokenId token id to see if it exists
function __exists(uint256 tokenId) external view returns (bool);
/// Simple approval for operation check on token for address
/// @param spender address spending/changing token
/// @param tokenId tokenID to change / operate on
function __isApprovedOrOwner(address spender, uint256 tokenId)
external
view
returns (bool);
function __isApprovedForAll(address owner, address operator)
external
view
returns (bool);
function __tokenURI(uint256 tokenId) external view returns (string memory);
function __owner() external view returns (address);
}
// File: @openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.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 CountersUpgradeable {
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}
// File: @openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library StringsUpgradeable {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// File: @openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol)
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 proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
* initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() initializer {}
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
*/
bool private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Modifier to protect an initializer function from being invoked twice.
*/
modifier initializer() {
// If the contract is initializing we ignore whether _initialized is set in order to support multiple
// inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
// contract may have been reentered.
require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");
bool isTopLevelCall = !_initializing;
if (isTopLevelCall) {
_initializing = true;
_initialized = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
}
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} modifier, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
function _isConstructor() private view returns (bool) {
return !AddressUpgradeable.isContract(address(this));
}
}
// File: @openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
// File: @openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal onlyInitializing {
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal onlyInitializing {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[49] private __gap;
}
// File: @openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721ReceiverUpgradeable {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
// File: @openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165Upgradeable {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// File: @openzeppelin/contracts-upgradeable/interfaces/IERC165Upgradeable.sol
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)
pragma solidity ^0.8.0;
// File: @openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/IERC2981.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface for the NFT Royalty Standard.
*
* A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
* support for royalty payments across all NFT marketplaces and ecosystem participants.
*
* _Available since v4.5._
*/
interface IERC2981Upgradeable is IERC165Upgradeable {
/**
* @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
* exchange. The royalty amount is denominated and should be payed in that same unit of exchange.
*/
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
returns (address receiver, uint256 royaltyAmount);
}
// File: @openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165Upgradeable).interfaceId;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
// File: @openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721Upgradeable is IERC165Upgradeable {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
// File: @openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721MetadataUpgradeable is IERC721Upgradeable {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
// File: @openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {
using AddressUpgradeable for address;
using StringsUpgradeable for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {
__ERC721_init_unchained(name_, symbol_);
}
function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {
return
interfaceId == type(IERC721Upgradeable).interfaceId ||
interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721Upgradeable.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721Upgradeable.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
_afterTokenTransfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721Upgradeable.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[44] private __gap;
}
// File: gwei-slim-nft-contracts/contracts/base/ERC721Base.sol
pragma solidity 0.8.9;
struct ConfigSettings {
uint16 royaltyBps;
string uriBase;
string uriExtension;
bool hasTransferHook;
}
/**
This smart contract adds features and allows for a ownership only by another smart contract as fallback behavior
while also implementing all normal ERC721 functions as expected
*/
contract ERC721Base is
ERC721Upgradeable,
IBaseERC721Interface,
IERC2981Upgradeable,
OwnableUpgradeable
{
using CountersUpgradeable for CountersUpgradeable.Counter;
// Minted counter for totalSupply()
CountersUpgradeable.Counter private mintedCounter;
modifier onlyInternal() {
require(msg.sender == address(this), "Only internal");
_;
}
/// on-chain record of when this contract was deployed
uint256 public immutable deployedBlock;
ConfigSettings public advancedConfig;
/// Constructor called once when the base contract is deployed
constructor() {
// Can be used to verify contract implementation is correct at address
deployedBlock = block.number;
}
/// Initializer that's called when a new child nft is setup
/// @param newOwner Owner for the new derived nft
/// @param _name name of NFT contract
/// @param _symbol symbol of NFT contract
/// @param settings configuration settings for uri, royalty, and hooks features
function initialize(
address newOwner,
string memory _name,
string memory _symbol,
ConfigSettings memory settings
) public initializer {
__ERC721_init(_name, _symbol);
__Ownable_init();
advancedConfig = settings;
transferOwnership(newOwner);
}
/// Getter to expose appoval status to root contract
function isApprovedForAll(address _owner, address operator)
public
view
override
returns (bool)
{
return
ERC721Upgradeable.isApprovedForAll(_owner, operator) ||
operator == address(this);
}
/// internal getter for approval by all
/// When isApprovedForAll is overridden, this can be used to call original impl
function __isApprovedForAll(address _owner, address operator)
public
view
override
returns (bool)
{
return isApprovedForAll(_owner, operator);
}
/// Hook that when enabled manually calls _beforeTokenTransfer on
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal override {
if (advancedConfig.hasTransferHook) {
(bool success, ) = address(this).delegatecall(
abi.encodeWithSignature(
"_beforeTokenTransfer(address,address,uint256)",
from,
to,
tokenId
)
);
// Raise error again from result if error exists
assembly {
switch success
// delegatecall returns 0 on error.
case 0 {
returndatacopy(0, 0, returndatasize())
revert(0, returndatasize())
}
}
}
}
/// Internal-only function to update the base uri
function __setBaseURI(string memory uriBase, string memory uriExtension)
public
override
onlyInternal
{
advancedConfig.uriBase = uriBase;
advancedConfig.uriExtension = uriExtension;
}
/// @dev returns the number of minted tokens
/// uses some extra gas but makes etherscan and users happy so :shrug:
/// partial erc721enumerable implemntation
function totalSupply() public view returns (uint256) {
return mintedCounter.current();
}
/**
Internal-only
@param to address to send the newly minted NFT to
@dev This mints one edition to the given address by an allowed minter on the edition instance.
*/
function __mint(address to, uint256 tokenId)
external
override
onlyInternal
{
_mint(to, tokenId);
mintedCounter.increment();
}
/**
@param tokenId Token ID to burn
User burn function for token id
*/
function burn(uint256 tokenId) public {
require(_isApprovedOrOwner(_msgSender(), tokenId), "Not allowed");
_burn(tokenId);
mintedCounter.decrement();
}
/// Internal only
function __burn(uint256 tokenId) public onlyInternal {
_burn(tokenId);
mintedCounter.decrement();
}
/**
Simple override for owner interface.
*/
function owner()
public
view
override(OwnableUpgradeable)
returns (address)
{
return super.owner();
}
/// internal alias for overrides
function __owner()
public
view
override(IBaseERC721Interface)
returns (address)
{
return owner();
}
/// Get royalty information for token
/// ignored token id to get royalty info. able to override and set per-token royalties
/// @param _salePrice sales price for token to determine royalty split
function royaltyInfo(uint256, uint256 _salePrice)
external
view
override
returns (address receiver, uint256 royaltyAmount)
{
// If ownership is revoked, don't set royalties.
if (owner() == address(0x0)) {
return (owner(), 0);
}
return (owner(), (_salePrice * advancedConfig.royaltyBps) / 10_000);
}
/// Default simple token-uri implementation. works for ipfs folders too
/// @param tokenId token id ot get uri for
/// @return default uri getter functionality
function tokenURI(uint256 tokenId)
public
view
override
returns (string memory)
{
require(_exists(tokenId), "No token");
return
string(
abi.encodePacked(
advancedConfig.uriBase,
StringsUpgradeable.toString(tokenId),
advancedConfig.uriExtension
)
);
}
/// internal base override
function __tokenURI(uint256 tokenId)
public
view
onlyInternal
returns (string memory)
{
return tokenURI(tokenId);
}
/// Exposing token exists check for base contract
function __exists(uint256 tokenId) external view override returns (bool) {
return _exists(tokenId);
}
/// Getter for approved or owner
function __isApprovedOrOwner(address spender, uint256 tokenId)
external
view
override
onlyInternal
returns (bool)
{
return _isApprovedOrOwner(spender, tokenId);
}
/// IERC165 getter
/// @param interfaceId interfaceId bytes4 to check support for
function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721Upgradeable, IERC165Upgradeable)
returns (bool)
{
return
type(IERC2981Upgradeable).interfaceId == interfaceId ||
type(IBaseERC721Interface).interfaceId == interfaceId ||
ERC721Upgradeable.supportsInterface(interfaceId);
}
}
// File: gwei-slim-nft-contracts/contracts/base/ERC721Delegated.sol
pragma solidity 0.8.9;
contract ERC721Delegated {
uint256[100000] gap;
bytes32 internal constant _IMPLEMENTATION_SLOT =
0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
// Reference to base NFT implementation
function implementation() public view returns (address) {
return
StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
function _initImplementation(address _nftImplementation) private {
StorageSlotUpgradeable
.getAddressSlot(_IMPLEMENTATION_SLOT)
.value = _nftImplementation;
}
/// Constructor that sets up the
constructor(
address _nftImplementation,
string memory name,
string memory symbol,
ConfigSettings memory settings
) {
/// Removed for gas saving reasons, the check below implictly accomplishes this
// require(
// _nftImplementation.supportsInterface(
// type(IBaseERC721Interface).interfaceId
// )
// );
_initImplementation(_nftImplementation);
(bool success, ) = _nftImplementation.delegatecall(
abi.encodeWithSignature(
"initialize(address,string,string,(uint16,string,string,bool))",
msg.sender,
name,
symbol,
settings
)
);
require(success);
}
/// OnlyOwner implemntation that proxies to base ownable contract for info
modifier onlyOwner() {
require(msg.sender == base().__owner(), "Not owner");
_;
}
/// Getter to return the base implementation contract to call methods from
/// Don't expose base contract to parent due to need to call private internal base functions
function base() private view returns (IBaseERC721Interface) {
return IBaseERC721Interface(address(this));
}
// helpers to mimic Openzeppelin internal functions
/// Getter for the contract owner
/// @return address owner address
function _owner() internal view returns (address) {
return base().__owner();
}
/// Internal burn function, only accessible from within contract
/// @param id nft id to burn
function _burn(uint256 id) internal {
base().__burn(id);
}
/// Internal mint function, only accessible from within contract
/// @param to address to mint NFT to
/// @param id nft id to mint
function _mint(address to, uint256 id) internal {
base().__mint(to, id);
}
/// Internal exists function to determine if fn exists
/// @param id nft id to check if exists
function _exists(uint256 id) internal view returns (bool) {
return base().__exists(id);
}
/// Internal getter for tokenURI
/// @param tokenId id of token to get tokenURI for
function _tokenURI(uint256 tokenId) internal view returns (string memory) {
return base().__tokenURI(tokenId);
}
/// is approved for all getter underlying getter
/// @param owner to check
/// @param operator to check
function _isApprovedForAll(address owner, address operator)
internal
view
returns (bool)
{
return base().__isApprovedForAll(owner, operator);
}
/// Internal getter for approved or owner for a given operator
/// @param operator address of operator to check
/// @param id id of nft to check for
function _isApprovedOrOwner(address operator, uint256 id)
internal
view
returns (bool)
{
return base().__isApprovedOrOwner(operator, id);
}
/// Sets the base URI of the contract. Allowed only by parent contract
/// @param newUri new uri base (http://URI) followed by number string of nft followed by extension string
/// @param newExtension optional uri extension
function _setBaseURI(string memory newUri, string memory newExtension)
internal
{
base().__setBaseURI(newUri, newExtension);
}
/**
* @dev Delegates the current call to nftImplementation.
*
* This function does not return to its internall call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
address impl = implementation();
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(), impl, 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 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 virtual {
_fallback();
}
/**
* @dev No base NFT functions receive any value
*/
receive() external payable {
revert();
}
}
// File: contracts/pxelmfer.sol
pragma solidity ^0.8.9;
contract PxelMfer is ERC721Delegated, ReentrancyGuard {
using Counters for Counters.Counter;
constructor(address baseFactory, string memory customBaseURI_)
ERC721Delegated(
baseFactory,
"pxel mfer",
"PXMFER",
ConfigSettings({
royaltyBps: 0,
uriBase: customBaseURI_,
uriExtension: "",
hasTransferHook: false
})
)
{}
/** MINTING **/
uint256 public constant MAX_SUPPLY = 6969;
uint256 public MAX_FREE_SUPPLY = 1420;
uint256 public constant MAX_MULTIMINT = 20;
uint256 public constant MAX_FREE_MULTIMINT = 10;
uint256 public PRICE = 10000000000000000;
string extensionURI = ".json";
Counters.Counter private supplyCounter;
function mint(uint256 count) public payable nonReentrant {
require(saleIsActive, "minting not started");
require(totalSupply() + count - 1 < MAX_SUPPLY, "can't mint more than max supply mfer");
require(count <= MAX_MULTIMINT, "can only mint 20 at once mfer");
require(
msg.value >= PRICE * count, "need 0.01 ETH mfer"
);
for (uint256 i = 0; i < count; i++) {
_mint(msg.sender, totalSupply());
supplyCounter.increment();
}
}
function freeMint(uint256 count) public payable nonReentrant {
require(saleIsActive, "minting not started");
require(totalSupply() + count - 1 < MAX_FREE_SUPPLY, "no more free ones mfer");
require(totalSupply() + count - 1 < MAX_SUPPLY, "can't mint more than max supply mfer");
require(count <= MAX_FREE_MULTIMINT, "can only mint 10 at once mfer");
for (uint256 i = 0; i < count; i++) {
_mint(msg.sender, totalSupply());
supplyCounter.increment();
}
}
function totalSupply() public view returns (uint256) {
return supplyCounter.current();
}
/** ACTIVATION **/
bool public saleIsActive = true;
function setSaleIsActive(bool saleIsActive_) external onlyOwner {
saleIsActive = saleIsActive_;
}
/** URI HANDLING **/
function setBaseURI(string memory customBaseURI_) external onlyOwner {
_setBaseURI(customBaseURI_, "");
}
function setExtensionURI(string memory customExtensionURI_) external onlyOwner {
extensionURI = customExtensionURI_;
}
function tokenURI(uint256 tokenId) public view returns (string memory) {
return string(abi.encodePacked(_tokenURI(tokenId), extensionURI));
}
function setPrice(uint256 _price) external onlyOwner {
PRICE = _price;
}
function increaseFreeMintSupply(uint256 _maxfree) external onlyOwner {
MAX_FREE_SUPPLY = _maxfree;
}
/** PAYOUT **/
function withdraw() public nonReentrant onlyOwner {
uint256 balance = address(this).balance;
Address.sendValue(payable(_owner()), balance);
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["1797"]}, {"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["2284", "2268"]}, {"defect": "DelegateCall", "type": "Function_call", "severity": "High", "lines": ["2077", "193", "1872"]}, {"defect": "Bad_randomness", "type": "Business_logic", "severity": "Medium", "lines": ["1820"]}, {"defect": "Frozen_Ether", "type": "Code_specification", "severity": "Medium", "lines": ["2046"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["2047", "1772", "568", "1872", "990", "546"]}, {"defect": "Balance_manipulation", "type": "Business_logic", "severity": "Medium", "lines": ["1382"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["1827", "950", "1386", "1939", "965", "474", "976", "461", "1172", "1951", "2013"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["1605", "1664", "1663", "1631"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [780, 781, 782, 783]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1720, 1721, 1722]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1888, 1881, 1882, 1883, 1884, 1885, 1886, 1887]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [419, 420, 421]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [392, 393, 394]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [401, 402, 403]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [2176, 2177, 2178, 2179, 2180, 2181, 2182, 2183, 2184, 2185, 2186, 2187, 2188, 2189, 2190, 2191, 2192, 2193, 2194, 2173, 2174, 2175]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [216, 217, 218, 215]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [410, 411, 412]}}, {"check": "pragma", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [2217]}}, {"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium", "lines": {"PxelMfer.sol": [2080, 2081, 2082, 2083, 2084, 2085, 2077, 2078, 2079]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [901, 902, 903]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [708, 709, 710, 711, 712, 713, 714]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [116, 117, 118, 119, 120, 121, 122]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [520, 518, 519]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [2137, 2138, 2139, 2140, 2141, 2142, 2143]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [2112, 2113, 2111]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [192, 193, 194, 195, 186, 187, 188, 189, 190, 191]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [2148, 2149, 2150, 2151, 2152, 2153, 2154]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [680, 681, 679]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [896, 895]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [1123, 1124]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [418, 419, 420, 421, 422]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [176, 177, 178]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [689, 690, 691, 692, 693, 694, 695]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [654, 655, 656, 657, 658, 659]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [1568, 1569, 1567]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [267, 268, 269]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [400, 401, 402, 403, 404]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [741, 742, 743]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [1424, 1425, 1426]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [259, 260, 261, 262, 263, 264, 265]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [149, 150, 151]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [1120, 1121]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [409, 410, 411, 412, 413]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [1744, 1745, 1746, 1747, 1748]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [751, 752, 753, 754, 755, 756, 757, 758, 759, 760]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [38, 39, 40, 41, 42, 43, 44]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [97, 98, 99, 100, 101, 102, 103]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [2124, 2125, 2126]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [160, 161, 162, 163, 164, 165, 166, 167, 168, 159]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [892, 893]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [88, 89, 87]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PxelMfer.sol": [2272, 2273, 2257, 2258, 2259, 2260, 2261, 2262, 2263, 2264, 2265, 2266, 2267, 2268, 2269, 2270, 2271]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PxelMfer.sol": [1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PxelMfer.sol": [1456, 1457, 1455]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PxelMfer.sol": [2327, 2328, 2329, 2330, 2331]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PxelMfer.sol": [1400, 1398, 1399]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PxelMfer.sol": [1384, 1381, 1382, 1383]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PxelMfer.sol": [1927, 1928, 1929, 1930, 1931]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PxelMfer.sol": [2313, 2314, 2315]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PxelMfer.sol": [1483, 1484, 1485, 1486, 1487, 1488, 1489]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PxelMfer.sol": [1936, 1937, 1934, 1935]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PxelMfer.sol": [1472, 1473, 1474, 1475, 1476, 1477, 1478, 1469, 1470, 1471]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PxelMfer.sol": [1440, 1441, 1431, 1432, 1433, 1434, 1435, 1436, 1437, 1438, 1439]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PxelMfer.sol": [1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PxelMfer.sol": [972, 973, 974]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PxelMfer.sol": [1905, 1906, 1907]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PxelMfer.sol": [1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PxelMfer.sol": [2275, 2276, 2277, 2278, 2279, 2280, 2281, 2282, 2283, 2284, 2285, 2286, 2287, 2288, 2289]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PxelMfer.sol": [1405, 1406, 1407]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PxelMfer.sol": [1828, 1829, 1830, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839, 1840]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PxelMfer.sol": [1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1319]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [6]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [528]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1074]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [343]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1145]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [428]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [878]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [598]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1101]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1290]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [796]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1066]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1778]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [2217]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [2042]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1008]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [231]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [482]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1038]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [277]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [918]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"PxelMfer.sol": [935]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"PxelMfer.sol": [935]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"PxelMfer.sol": [1339]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"PxelMfer.sol": [1342]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [758]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [166]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [193]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [2080, 2081, 2082, 2083, 2084, 2085, 2077, 2078, 2079]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [731]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [65]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [657]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [139]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"PxelMfer.sol": [2080, 2081, 2082, 2083, 2084, 2085, 2077, 2078, 2079]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"PxelMfer.sol": [2119]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1856]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [2009, 2010, 2011]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1920, 1921, 1914, 1915, 1916, 1917, 1918, 1919]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1843]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1830]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1498]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [910]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [2016, 2017, 2018, 2019, 2020, 2021, 2022, 2014, 2015]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1772]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [441]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [944, 942, 943]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [2245]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [2321]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1000]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1831]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [446]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1363, 1364, 1365, 1366]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [2317]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1123, 1124]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [896, 895]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [457]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [451]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [474]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1964]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [467, 468, 469, 470]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1137]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [946, 947, 948]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [2251]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [472]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [892, 893]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1120, 1121]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1936, 1937, 1934, 1935]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [464, 465, 462, 463]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1360, 1361, 1359]}}, {"check": "variable-scope", "impact": "Low", "confidence": "High", "lines": {"PxelMfer.sol": [1717]}}, {"check": "variable-scope", "impact": "Low", "confidence": "High", "lines": {"PxelMfer.sol": [1721]}}, {"check": "variable-scope", "impact": "Low", "confidence": "High", "lines": {"PxelMfer.sol": [1715]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"PxelMfer.sol": [2251]}}, {"check": "unprotected-upgrade", "impact": "High", "confidence": "High", "lines": {"PxelMfer.sol": [1936, 1937, 1934, 1935]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"PxelMfer.sol": [1714, 1715, 1716, 1717, 1718, 1719, 1720, 1721, 1722, 1723, 1724]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [2224, 2225, 2226, 2227, 2228, 2229, 2230, 2231, 2232, 2233, 2234, 2235, 2236, 2237, 2238, 2239, 2240, 2241, 2242, 2243, 2244, 2245, 2246, 2247, 2248, 2249, 2250, 2251, 2252, 2253, 2254, 2255, 2256, 2257, 2258, 2259, 2260, 2261, 2262, 2263, 2264, 2265, 2266, 2267, 2268, 2269, 2270, 2271, 2272, 2273, 2274, 2275, 2276, 2277, 2278, 2279, 2280, 2281, 2282, 2283, 2284, 2285, 2286, 2287, 2288, 2289, 2290, 2291, 2292, 2293, 2294, 2295, 2296, 2297, 2298, 2299, 2300, 2301, 2302, 2303, 2304, 2305, 2306, 2307, 2308, 2309, 2310, 2311, 2312, 2313, 2314, 2315, 2316, 2317, 2318, 2319, 2320, 2321, 2322, 2323, 2324, 2325, 2326, 2327, 2328, 2329, 2330, 2331, 2332, 2333]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"PxelMfer.sol": [1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804, 1805, 1806, 1807, 1808, 1809, 1810, 1811, 1812, 1813, 1814, 1815, 1816, 1817, 1818, 1819, 1820, 1821, 1822, 1823, 1824, 1825, 1826, 1827, 1828, 1829, 1830, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839, 1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847, 1848, 1849, 1850, 1851, 1852, 1853, 1854, 1855, 1856, 1857, 1858, 1859, 1860, 1861, 1862, 1863, 1864, 1865, 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 1887, 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, 1918, 1919, 1920, 1921, 1922, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, 1931, 1932, 1933, 1934, 1935, 1936, 1937, 1938, 1939, 1940, 1941, 1942, 1943, 1944, 1945, 1946, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024, 2025, 2026, 2027, 2028, 2029, 2030, 2031, 2032, 2033, 2034, 2035, 2036, 2037]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 585, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 973, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1582, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1603, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1610, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1626, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1629, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1636, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1661, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1971, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 391, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 400, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 409, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 418, "severity": 1}, {"rule": "SOLIDITY_LOCKED_MONEY", "line": 2224, "severity": 3}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 2299, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 2305, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 2309, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 2317, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 6, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 231, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 277, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 343, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 482, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 528, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 598, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 796, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 878, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 918, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1008, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1038, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1066, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1074, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1101, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1145, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1290, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1319, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2217, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 307, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 308, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 310, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 534, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 830, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 835, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 910, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 935, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1000, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1137, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1339, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1342, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1345, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1348, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1351, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1354, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1772, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1805, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2255, "severity": 1}, {"rule": "SOLIDITY_REVERT_REQUIRE", "line": 1717, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 391, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 400, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 409, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 418, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 1093, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 1968, "severity": 1}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 2077, "severity": 3}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 901, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 392, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 401, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 410, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 419, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 1720, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 1881, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 2173, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 62, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 312, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 654, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1818, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 2064, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 2227, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 62, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 62, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 63, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 63, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 63, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 63, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 65, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 65, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 65, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 654, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 654, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 655, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 655, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 655, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 655, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 657, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 657, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 657, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 2047, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 2201, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 2202, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 2202, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 2253, "severity": 1}] | [{"inputs":[{"internalType":"address","name":"baseFactory","type":"address"},{"internalType":"string","name":"customBaseURI_","type":"string"}],"stateMutability":"nonpayable","type":"constructor"},{"stateMutability":"nonpayable","type":"fallback"},{"inputs":[],"name":"MAX_FREE_MULTIMINT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_FREE_SUPPLY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_MULTIMINT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_SUPPLY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PRICE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"count","type":"uint256"}],"name":"freeMint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxfree","type":"uint256"}],"name":"increaseFreeMintSupply","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"count","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"saleIsActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"customBaseURI_","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"customExtensionURI_","type":"string"}],"name":"setExtensionURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"setPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"saleIsActive_","type":"bool"}],"name":"setSaleIsActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}] | v0.8.9+commit.e5eed63a | false | 200 | 00000000000000000000000043955024b1985e2b933a59021500ae5f55b04091000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000046d66657200000000000000000000000000000000000000000000000000000000 | Default | MIT | false | ipfs://74bad3ee16befb3df4f1cd1479719f71cff91e82a28637674eaddac07a431d6a |
||
SHIELD | 0x45eefd478f1cb04c1a183c29c7bca7c50a17bb23 | Solidity | //ShieldDAO Governance Tokens
//Loss Mitigation Protocol
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 SHIELD 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;
/**
* Shield Constrctor function
*
* Initializes contract with initial supply tokens to SHIELD Vault
*/
constructor() public {
name = "SHIELD";
symbol = "SHD";
decimals = 18;
_totalSupply = 100000000000000000000000;
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;
}
} | [] | [{"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SHIELD.sol": [88, 89, 90, 91, 92, 93, 94]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SHIELD.sol": [75, 76, 77, 78, 79]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SHIELD.sol": [72, 73, 71]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SHIELD.sol": [67, 68, 69]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SHIELD.sol": [32, 33, 34]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SHIELD.sol": [64, 65, 63]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SHIELD.sol": [81, 82, 83, 84, 85, 86]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SHIELD.sol": [32]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"SHIELD.sol": [5]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SHIELD.sol": [43]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"SHIELD.sol": [57]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 64, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 75, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 5, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 45, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 46, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"tokens","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"from","type":"address"},{"name":"to","type":"address"},{"name":"tokens","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"_totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"tokenOwner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeSub","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"tokens","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeDiv","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeMul","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"name":"tokenOwner","type":"address"},{"name":"spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeAdd","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"tokens","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenOwner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"tokens","type":"uint256"}],"name":"Approval","type":"event"}] | v0.5.2+commit.1df8f40c | true | 200 | Default | None | false | bzzr://7d353d75463b1a5fe627e3ca87f17d5a973f721bc3a7a1c89b4c8c2a1b70f233 |
|||
Taouaf | 0x38f10839dcbf15936f79bee139ceaf484edaca46 | Solidity | // Abstract contract for the full ERC 20 Token standard
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
pragma solidity ^0.4.18;
contract EIP20Interface {
/* This is a slight change to the ERC20 base standard.
function totalSupply() constant returns (uint256 supply);
is replaced with:
uint256 public totalSupply;
This automatically creates a getter function for the totalSupply.
This is moved to the base contract since public getter functions are not
currently recognised as an implementation of the matching abstract
function by the compiler.
*/
/// total amount of tokens
uint256 public totalSupply;
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) public view returns (uint256 balance);
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) public returns (bool success);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success);
/// @notice `msg.sender` approves `_spender` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of tokens to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) public returns (bool success);
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public view returns (uint256 remaining);
// solhint-disable-next-line no-simple-event-func-name
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
/*
Implements EIP20 token standard: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md
.*/
contract Taouaf is EIP20Interface {
uint256 constant private MAX_UINT256 = 2**256 - 1;
mapping (address => uint256) public balances;
mapping (address => mapping (address => uint256)) public allowed;
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show.
string public symbol; //An identifier: eg SBX
function Taouaf(
uint256 _initialAmount,
string _tokenName,
uint8 _decimalUnits,
string _tokenSymbol
) public {
balances[msg.sender] = _initialAmount; // Give the creator all initial tokens
totalSupply = _initialAmount; // Update total supply
name = _tokenName; // Set the name for display purposes
decimals = _decimalUnits; // Amount of decimals for display purposes
symbol = _tokenSymbol; // Set the symbol for display purposes
}
function transfer(address _to, uint256 _value) public returns (bool success) {
require(balances[msg.sender] >= _value);
balances[msg.sender] -= _value;
balances[_to] += _value;
Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
uint256 allowance = allowed[_from][msg.sender];
require(balances[_from] >= _value && allowance >= _value);
balances[_to] += _value;
balances[_from] -= _value;
if (allowance < MAX_UINT256) {
allowed[_from][msg.sender] -= _value;
}
Transfer(_from, _to, _value);
return true;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balances[_owner];
}
function approve(address _spender, uint256 _value) public returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
return allowed[_owner][_spender];
}
} | [{"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["17"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["98", "96", "95", "87", "86"]}] | [{"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Taouaf.sol": [108, 109, 110, 111, 112]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Taouaf.sol": [96, 97, 98, 99, 100, 101, 102, 92, 93, 94, 95]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Taouaf.sol": [104, 105, 106]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Taouaf.sol": [114, 115, 116]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Taouaf.sol": [84, 85, 86, 87, 88, 89, 90]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Taouaf.sol": [3]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"Taouaf.sol": [45]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Taouaf.sol": [92]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Taouaf.sol": [108]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Taouaf.sol": [114]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Taouaf.sol": [92]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Taouaf.sol": [104]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Taouaf.sol": [114]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Taouaf.sol": [84]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Taouaf.sol": [92]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Taouaf.sol": [108]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Taouaf.sol": [84]}}] | [{"error": "Integer Underflow.", "line": 67, "level": "Warning"}, {"error": "Integer Underflow.", "line": 69, "level": "Warning"}, {"error": "Integer Overflow.", "line": 87, "level": "Warning"}] | [{"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 58, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 73, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 75, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balances","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowed","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_initialAmount","type":"uint256"},{"name":"_tokenName","type":"string"},{"name":"_decimalUnits","type":"uint8"},{"name":"_tokenSymbol","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"}] | v0.4.18+commit.9cf6e910 | false | 200 | 0000000000000000000000000000000000000000033b2e3c9fd0803ce80000000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000e4574686572205175616c6966656400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034554510000000000000000000000000000000000000000000000000000000000 | Default | false | bzzr://cb27c30bcc86b3f1f32ad6410b32d272160430f6c9880434e63c6f936b80234b |
|||
ims | 0xb995972483557e48c4b92ce6612d466ee8a9400f | Solidity | /** A dynamic yet predictable decentralized elastic supply token redesigned to solve market manipulation and appeal to all.
*/
pragma solidity >=0.4.22 <0.6.0;
contract ERC20 {
function totalSupply() public view returns (uint supply);
function balanceOf(address who) public view returns (uint value);
function allowance(address owner, address spender) public view returns (uint remaining);
function transferFrom(address from, address to, uint value) public returns (bool ok);
function approve(address spender, uint value) public returns (bool ok);
function transfer(address to, uint value) public returns (bool ok);
event Transfer(address indexed from, address indexed to, uint value);
event Approval(address indexed owner, address indexed spender, uint value);
}
contract ims is ERC20{
uint8 public constant decimals = 18;
uint256 initialSupply = 3000000*10**uint256(decimals);
string public constant name = "CoilCrypto";
string public constant symbol = "COIL";
address payable teamAddress;
function totalSupply() public view returns (uint256) {
return initialSupply;
}
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
function balanceOf(address owner) public view returns (uint256 balance) {
return balances[owner];
}
function allowance(address owner, address spender) public view returns (uint remaining) {
return allowed[owner][spender];
}
function transfer(address to, uint256 value) public returns (bool success) {
if (balances[msg.sender] >= value && value > 0) {
balances[msg.sender] -= value;
balances[to] += value;
emit Transfer(msg.sender, to, value);
return true;
} else {
return false;
}
}
function transferFrom(address from, address to, uint256 value) public returns (bool success) {
if (balances[from] >= value && allowed[from][msg.sender] >= value && value > 0) {
balances[to] += value;
balances[from] -= value;
allowed[from][msg.sender] -= value;
emit Transfer(from, to, value);
return true;
} else {
return false;
}
}
function approve(address spender, uint256 value) public returns (bool success) {
allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function () external payable {
teamAddress.transfer(msg.value);
}
constructor () public payable {
teamAddress = msg.sender;
balances[teamAddress] = initialSupply;
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["69"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["21", "20"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["41", "42", "52", "53", "54", "19"]}] | [{"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"ims.sol": [19]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ims.sol": [39, 40, 41, 42, 43, 44, 45, 46, 47, 48]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ims.sol": [64, 65, 66, 62, 63]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ims.sol": [35, 36, 37]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ims.sol": [25, 26, 27]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ims.sol": [32, 33, 31]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ims.sol": [50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"ims.sol": [4]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ims.sol": [17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"ims.sol": [19]}}] | [] | [{"rule": "SOLIDITY_ERC20_APPROVE", "line": 62, "severity": 2}, {"rule": "SOLIDITY_ERC20_TRANSFER_SHOULD_THROW", "line": 39, "severity": 1}, {"rule": "SOLIDITY_ERC20_TRANSFER_SHOULD_THROW", "line": 50, "severity": 1}, {"rule": "SOLIDITY_LOCKED_MONEY", "line": 17, "severity": 3}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 4, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 4, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 19, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 23, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 28, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 29, "severity": 1}] | [{"inputs":[],"payable":true,"stateMutability":"payable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] | v0.5.17+commit.d19bba13 | false | 200 | Default | None | false | bzzr://4399017203e9d3a89d155705a6485a88b71f79ec0a2f1b4dbfc5ab6efc0d0069 |
|||
StakingPoolV2 | 0xe364a4f9b73f05b5e18fa08f09c1e7a7ef62d207 | Solidity | /*
*
██████╗ ██████╗ ██╗ ██████╗ ██╗ ██╗ ██████╗ ███████╗ ██████╗ ███╗ ██╗███████╗
██╔════╝ ██╔═══██╗██║ ██╔══██╗ ██║ ██║██╔═══██╗██╔════╝ ██╔═══██╗████╗ ██║██╔════╝
██║ ███╗██║ ██║██║ ██║ ██║ ███████║██║ ██║█████╗ ██║ ██║██╔██╗ ██║█████╗
██║ ██║██║ ██║██║ ██║ ██║ ██╔══██║██║ ██║██╔══╝ ██║ ██║██║╚██╗██║██╔══╝
╚██████╔╝╚██████╔╝███████╗██████╔╝ ██║ ██║╚██████╔╝███████╗ ╚██████╔╝██║ ╚████║███████╗
╚═════╝ ╚═════╝ ╚══════╝╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝
Tribute to Satoshi Nakamoto in 2008 and Vitalik Buterin in 2011.
- Decentralized believer, PROX.
*
*/
pragma solidity ^0.6.0;
// SPDX-License-Identifier: MIT
/**
* @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);
}
}
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// 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);
}
}
}
}
/**
* @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");
}
}
}
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
contract LPTokenWrapperV2 {
using SafeMath for uint256;
using SafeERC20 for IERC20;
IERC20 public lp = IERC20(0xA56Ed2632E443Db5f93e73C89df399a081408Cc4);
uint256 private _totalSupply;
mapping(address => uint256) private _balances;
constructor(address _lp) public {
lp = IERC20(_lp);
}
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
function _stake(uint256 amount) internal {
_totalSupply = _totalSupply.add(amount);
_balances[msg.sender] = _balances[msg.sender].add(amount);
lp.safeTransferFrom(msg.sender, address(this), amount);
}
function _withdraw(uint256 amount) internal {
_totalSupply = _totalSupply.sub(amount);
_balances[msg.sender] = _balances[msg.sender].sub(amount);
lp.safeTransfer(msg.sender, amount);
}
function _stakeFromReward(address account, uint256 amount) internal {
require(account != address(0), "invalid address");
require(lp.balanceOf(address(this)) >= _totalSupply.add(amount), "out of balance");
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
}
}
contract StakingPoolV2 is LPTokenWrapperV2, Ownable {
using Address for address;
using SafeMath for uint256;
using SafeERC20 for IERC20;
struct UserInfo {
uint256 poolId;
uint256 stakingTime;
uint256 lastRewardPerToken;
uint256 pendingReward;
uint256 lastRewardPerToken4Pool;
uint256 pendingReward4Pool;
}
struct PoolInfo {
address owner;
address beneficiary;
uint256 announceTime;
uint256 amount; // How many tokens staked in the pool
uint256 profit;
}
enum PoolAnnounceStatusCode {OK, WRONG_PID, POOL_HAS_OWNER, NEED_MORE_DEPOSIT, USER_IN_ANOTHER_POOL}
IERC20 public rewardToken = IERC20(0xA56Ed2632E443Db5f93e73C89df399a081408Cc4);
uint256 public constant SECONDS_PER_DAY = 1 days;
uint256 public constant REWARD_DURATION = 7 * SECONDS_PER_DAY;
// pool related constant
uint256 public constant MAX_POOL_NUMBER = 108;
uint256 public constant MIN_POOL_ANNOUNCE_AMOUNT = 50 * 1e18;
uint256 public constant MIN_POOL_DEPOSIT_AMOUNT = 100 * 1e18;
uint256 public constant MIN_POOL_ANNOUNCE_DURATION = 3 * SECONDS_PER_DAY;
PoolInfo[] private poolInfo;
mapping(address => UserInfo) public userInfo;
mapping(address => uint256) public poolRewards;
// settle state
mapping(address => uint256) public pendingAmount;
mapping(address => uint256) public settlementDate;
// settle period
uint256 public minWithdrawDuration = 3 * SECONDS_PER_DAY;
uint256 public periodFinish;
uint256 public lastRewardUpdateTime = 0;
uint256 public rewardPerTokenStored = 0;
uint256 public rewardPerTokenStored4Pool = 0;
uint256 public userRewardRatePerDay = 40;
uint256 public poolRewardRatePerDay = 40;
uint256 public constant REWARD_RATE_BASE = 10000;
bool public breaker = false;
mapping(address => bool) public whiteList;
/* ========== EVENTS ========== */
event Deposited(address indexed user, uint256 amount, uint256 pid);
event Withdrawn(address indexed user, uint256 amount, uint256 pid);
event Settled(address indexed user, uint256 amount);
event Reinvested(address indexed user, uint256 amount, uint256 pid);
event RewardPaidToOwner(address indexed owner, uint256 reward, uint256 pid);
event Announced(address indexed owner, uint256 pid);
event Renounced(address indexed owner, uint256 pid);
event BeneficiaryTransferred(address indexed previousBeneficiary, address indexed newBeneficiary, uint256 pid);
event RewardsDurationUpdated(uint256 newDuration);
event Recovered(address indexed token, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 amount);
constructor(address token) public LPTokenWrapperV2(token) {
rewardToken = IERC20(token);
}
function createPool(uint256 count) external onlyOwner {
require(poolInfo.length.add(count) <= MAX_POOL_NUMBER, "too much pools");
for (uint256 i = 0; i < count; i++) {
poolInfo.push(
PoolInfo({owner: address(0), beneficiary: address(0), announceTime: 0, amount: 0, profit: 0})
);
}
}
function notifyRewardAmount() external onlyOwner updateReward(address(0)) {
require(currentTime() > periodFinish, "not finish");
lastRewardUpdateTime = currentTime();
periodFinish = currentTime().add(REWARD_DURATION);
emit RewardsDurationUpdated(periodFinish);
}
modifier updateReward(address account) {
rewardPerTokenStored = calcUserRewardPerToken();
rewardPerTokenStored4Pool = calcPoolRewardPerToken();
lastRewardUpdateTime = lastTimeRewardApplicable();
if (account != address(0)) {
UserInfo storage user = userInfo[account];
user.pendingReward = _earned(account);
user.lastRewardPerToken = rewardPerTokenStored;
user.pendingReward4Pool = _earned4Pool(account);
user.lastRewardPerToken4Pool = rewardPerTokenStored4Pool;
}
_;
}
function calcUserRewardPerToken() public view returns (uint256) {
return rewardPerTokenStored.add(lastTimeRewardApplicable().sub(lastRewardUpdateTime).mul(userRewardRatePerDay));
}
function calcPoolRewardPerToken() public view returns (uint256) {
return
rewardPerTokenStored4Pool.add(
lastTimeRewardApplicable().sub(lastRewardUpdateTime).mul(poolRewardRatePerDay)
);
}
function lastTimeRewardApplicable() public view returns (uint256) {
return Math.min(block.timestamp, periodFinish);
}
function reinvest(uint256 pid) public updateReward(msg.sender) {
require(pid < poolInfo.length, "Invalid pool id");
UserInfo storage user = userInfo[msg.sender];
if (balanceOf(msg.sender) > 0) {
require(user.poolId == pid, "Wrong pid");
}
uint256 userEarned = _earned(msg.sender);
user.pendingReward = 0;
uint256 poolEarned = _earned4Pool(msg.sender);
user.pendingReward4Pool = 0;
PoolInfo storage pool = poolInfo[pid];
if (poolEarned > 0 && pool.owner != address(0) && pool.amount >= MIN_POOL_DEPOSIT_AMOUNT) {
poolRewards[pool.beneficiary] = poolRewards[pool.beneficiary].add(poolEarned);
pool.profit = pool.profit.add(poolEarned);
emit RewardPaidToOwner(pool.beneficiary, poolEarned, pid);
}
uint256 rewardFromPool = poolRewards[msg.sender];
if (rewardFromPool > 0) {
poolRewards[msg.sender] = 0;
userEarned = userEarned.add(rewardFromPool);
}
if (userEarned == 0) {
return;
}
super._stakeFromReward(msg.sender, userEarned);
user.stakingTime = currentTime();
user.poolId = pid;
pool.amount = pool.amount.add(userEarned);
emit Reinvested(msg.sender, userEarned, pid);
}
function deposit(uint256 pid, uint256 amount) external updateReward(msg.sender) {
require(amount > 0, "Cannot deposit 0");
require(pid < poolInfo.length, "Invalid pool id");
UserInfo storage user = userInfo[msg.sender];
if (balanceOf(msg.sender) > 0) {
require(pid == user.poolId, "Can deposit in only one pool");
}
super._stake(amount);
user.stakingTime = currentTime();
user.poolId = pid;
PoolInfo storage pool = poolInfo[pid];
pool.amount = pool.amount.add(amount);
emit Deposited(msg.sender, amount, pid);
}
function withdraw(uint256 amount) public updateReward(msg.sender) {
require(amount > 0, "Cannot withdraw 0");
require(balanceOf(msg.sender) >= amount, "Not enough");
UserInfo memory user = userInfo[msg.sender];
PoolInfo storage pool = poolInfo[user.poolId];
if (pool.owner == msg.sender) {
require(balanceOf(msg.sender) >= amount.add(MIN_POOL_ANNOUNCE_AMOUNT), "Cannot withdraw");
}
pool.amount = pool.amount.sub(staked(msg.sender));
pendingAmount[msg.sender] = amount;
settlementDate[msg.sender] = currentTime();
pool.amount = pool.amount.add(staked(msg.sender));
emit Withdrawn(msg.sender, amount, user.poolId);
}
function settle() external {
require(currentTime() >= settlementDate[msg.sender].add(minWithdrawDuration), "too early");
uint256 amount = pendingAmount[msg.sender];
if (amount > 0) {
pendingAmount[msg.sender] = 0;
super._withdraw(amount);
emit Settled(msg.sender, amount);
}
}
function exit() external {
UserInfo memory user = userInfo[msg.sender];
reinvest(user.poolId);
withdraw(balanceOf(msg.sender));
}
function settleableDate(address account) external view returns (uint256) {
return settlementDate[account].add(minWithdrawDuration);
}
function earned(address account) external view returns (uint256) {
uint256 userEarned = _earned(account);
return userEarned;
}
function staked(address account) public view returns (uint256) {
return balanceOf(account).sub(pendingAmount[account]);
}
function announce(uint256 pid) external {
require(!address(msg.sender).isContract() || whiteList[msg.sender], "Not welcome");
require(staked(msg.sender) >= MIN_POOL_ANNOUNCE_AMOUNT, "deposit more to announce");
PoolAnnounceStatusCode status = checkAnnounceable(pid, msg.sender);
require(status == PoolAnnounceStatusCode.OK, "Check Status Code");
PoolInfo storage pool = poolInfo[pid];
pool.owner = msg.sender;
pool.beneficiary = msg.sender;
pool.announceTime = currentTime();
pool.profit = 0;
emit Announced(msg.sender, pid);
}
function renounce(uint256 pid) external {
PoolInfo storage pool = poolInfo[pid];
require(pool.owner == msg.sender, "Must be owner");
require(pool.announceTime + MIN_POOL_ANNOUNCE_DURATION < currentTime(), "Cannot renounce now");
pool.owner = address(0);
pool.beneficiary = address(0);
pool.announceTime = 0;
emit Renounced(msg.sender, pid);
}
function setBeneficiary(uint256 _pid, address _beneficiary) external {
require(_beneficiary != address(0), "!_beneficiary");
PoolInfo storage pool = poolInfo[_pid];
require(pool.owner == msg.sender, "Must be owner");
address preBeneficiary = pool.beneficiary;
pool.beneficiary = _beneficiary;
emit BeneficiaryTransferred(preBeneficiary, pool.beneficiary, _pid);
}
function setBreaker(bool _breaker) external onlyOwner {
breaker = _breaker;
}
function setWhiteList(address addr, bool status) external onlyOwner {
require(addr != address(0), "!addr");
whiteList[addr] = status;
}
function setRewardRatePerDay(uint256 userRewardRate, uint256 poolRewardRate) external onlyOwner {
require(currentTime() > periodFinish, "not finish");
require(userRewardRate <= REWARD_RATE_BASE, "!wrong user rate");
require(poolRewardRate <= REWARD_RATE_BASE, "!wrong pool rate");
userRewardRatePerDay = userRewardRate;
poolRewardRatePerDay = poolRewardRate;
}
function setMinWithdrawDuration(uint256 duration) external onlyOwner {
require(duration >= SECONDS_PER_DAY, "!at least one day");
minWithdrawDuration = duration;
}
// Added to support recovering LP Rewards from other systems such as BAL to be distributed to holders
function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyOwner {
require(
tokenAddress != address(lp) && tokenAddress != address(rewardToken),
"Cannot withdraw the staking or rewards tokens"
);
IERC20(tokenAddress).safeTransfer(owner(), tokenAmount);
emit Recovered(tokenAddress, tokenAmount);
}
// withdraw extra reward tokens after staking period
function withdrawAll() external onlyOwner {
require(currentTime() > periodFinish, "period not finished");
uint256 bal = rewardToken.balanceOf(address(this));
uint256 amount = bal.sub(totalSupply());
IERC20(rewardToken).safeTransfer(owner(), amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw() external {
require(breaker, "!breaker");
UserInfo storage user = userInfo[msg.sender];
user.pendingReward = 0;
user.pendingReward4Pool = 0;
poolRewards[msg.sender] = 0;
pendingAmount[msg.sender] = 0;
uint256 amount = balanceOf(msg.sender);
super._withdraw(amount);
emit EmergencyWithdraw(msg.sender, amount);
}
function maxWithdrawAmount(address account) public view returns (uint256) {
uint256 maxAmount = balanceOf(account);
UserInfo memory user = userInfo[account];
PoolInfo memory pool = poolInfo[user.poolId];
if (pool.owner == account) {
return maxAmount.sub(MIN_POOL_ANNOUNCE_AMOUNT);
}
return maxAmount;
}
function queryPoolInfo(uint256 pid, address account)
public
view
returns (
bool hasOwner,
bool isOwner,
uint256 announceableStatus,
uint256 totalAmount,
uint256 announceTime,
uint256 poolProfit,
address beneficiary
)
{
PoolInfo memory pool = poolInfo[pid];
if (pool.owner != address(0)) {
hasOwner = true;
if (pool.owner == address(account)) {
isOwner = true;
}
}
announceableStatus = uint256(checkAnnounceable(pid, account));
totalAmount = pool.amount;
if (hasOwner) {
announceTime = pool.announceTime;
poolProfit = pool.profit;
}
if (isOwner) {
beneficiary = pool.beneficiary;
}
}
function poolCount() public view returns (uint256) {
return uint256(poolInfo.length);
}
function _earned(address account) internal view returns (uint256) {
UserInfo memory user = userInfo[account];
return
staked(account)
.mul(calcUserRewardPerToken().sub(user.lastRewardPerToken))
.div(REWARD_RATE_BASE)
.div(SECONDS_PER_DAY)
.add(user.pendingReward);
}
function _earned4Pool(address account) internal view returns (uint256) {
UserInfo memory user = userInfo[account];
return
staked(account)
.mul(calcPoolRewardPerToken().sub(user.lastRewardPerToken4Pool))
.div(REWARD_RATE_BASE)
.div(SECONDS_PER_DAY)
.add(user.pendingReward4Pool);
}
function checkAnnounceable(uint256 pid, address account) internal view returns (PoolAnnounceStatusCode) {
// check pid
if (pid >= poolInfo.length) {
return PoolAnnounceStatusCode.WRONG_PID;
}
// check owner
PoolInfo memory pool = poolInfo[pid];
if (pool.owner != address(0)) {
return PoolAnnounceStatusCode.POOL_HAS_OWNER;
}
// check user
UserInfo memory user = userInfo[account];
if (balanceOf(account) > 0 && pid != user.poolId) {
return PoolAnnounceStatusCode.USER_IN_ANOTHER_POOL;
}
// check the minimum deposit requirement
if (staked(account) < MIN_POOL_ANNOUNCE_AMOUNT) {
return PoolAnnounceStatusCode.NEED_MORE_DEPOSIT;
}
return PoolAnnounceStatusCode.OK;
}
function currentTime() internal view returns (uint256) {
return block.timestamp;
}
} | [{"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["697"]}, {"defect": "Uninitialized_storage", "type": "Code_specification", "severity": "Low", "lines": ["745", "789", "940", "889", "812", "757", "800", "876", "866"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["891"]}, {"defect": "Balance_manipulation", "type": "Business_logic", "severity": "Medium", "lines": ["1028"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["563", "536", "551"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["648", "649"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["1039", "739", "878"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"StakingPoolV2.sol": [308]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"StakingPoolV2.sol": [408, 409, 410, 407]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [328, 329, 330, 331, 332, 333, 334]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [379, 380, 381]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [26, 27, 28]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [41, 42, 43, 44]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [458, 459, 460, 461]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [448, 449, 450, 451, 452, 453, 454, 455, 456, 447]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [273, 274, 275, 276]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [392, 389, 390, 391]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [504, 505, 506, 503]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [257, 258, 259]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [464, 465, 466, 463]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [354, 355, 356]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"StakingPoolV2.sol": [961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"StakingPoolV2.sol": [560, 561, 558, 559]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"StakingPoolV2.sol": [992, 993, 994]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"StakingPoolV2.sol": [951, 952, 953, 954, 955, 956, 957, 958, 959]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"StakingPoolV2.sol": [567, 568, 569, 570, 571]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"StakingPoolV2.sol": [15]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"StakingPoolV2.sol": [977]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"StakingPoolV2.sol": [771]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"StakingPoolV2.sol": [748]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"StakingPoolV2.sol": [398]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"StakingPoolV2.sol": [332]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [910]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [915]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"StakingPoolV2.sol": [896]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"StakingPoolV2.sol": [887]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"StakingPoolV2.sol": [887]}}, {"check": "redundant-statements", "impact": "Informational", "confidence": "High", "lines": {"StakingPoolV2.sol": [498, 499, 500, 501, 502, 503, 504, 505, 506, 507]}}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [798]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [835]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [925]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [803]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [948]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [814]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [696]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [878]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [906]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [861]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [1032]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [792]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [930]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [977]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [771]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [705]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"StakingPoolV2.sol": [828]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 579, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 641, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 560, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 704, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 880, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 881, "severity": 1}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 896, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 900, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 905, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 913, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 15, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 523, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 581, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 582, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 652, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 429, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 576, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 619, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 301, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 964, "severity": 1}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 433, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 437, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 455, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 460, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 465, "severity": 3}, {"rule": "SOLIDITY_VISIBILITY", "line": 328, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 328, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 328, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 329, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 329, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 329, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 329, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 332, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 332, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 332, "severity": 1}] | [{"inputs":[{"internalType":"address","name":"token","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"pid","type":"uint256"}],"name":"Announced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousBeneficiary","type":"address"},{"indexed":true,"internalType":"address","name":"newBeneficiary","type":"address"},{"indexed":false,"internalType":"uint256","name":"pid","type":"uint256"}],"name":"BeneficiaryTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pid","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EmergencyWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Recovered","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pid","type":"uint256"}],"name":"Reinvested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"pid","type":"uint256"}],"name":"Renounced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pid","type":"uint256"}],"name":"RewardPaidToOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"newDuration","type":"uint256"}],"name":"RewardsDurationUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Settled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"pid","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"MAX_POOL_NUMBER","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_POOL_ANNOUNCE_AMOUNT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_POOL_ANNOUNCE_DURATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_POOL_DEPOSIT_AMOUNT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REWARD_DURATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REWARD_RATE_BASE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"SECONDS_PER_DAY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"pid","type":"uint256"}],"name":"announce","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"breaker","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"calcPoolRewardPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"calcUserRewardPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"count","type":"uint256"}],"name":"createPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pid","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"earned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"exit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastRewardUpdateTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastTimeRewardApplicable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lp","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"maxWithdrawAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minWithdrawDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"notifyRewardAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"pendingAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodFinish","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolRewardRatePerDay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"poolRewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"pid","type":"uint256"},{"internalType":"address","name":"account","type":"address"}],"name":"queryPoolInfo","outputs":[{"internalType":"bool","name":"hasOwner","type":"bool"},{"internalType":"bool","name":"isOwner","type":"bool"},{"internalType":"uint256","name":"announceableStatus","type":"uint256"},{"internalType":"uint256","name":"totalAmount","type":"uint256"},{"internalType":"uint256","name":"announceTime","type":"uint256"},{"internalType":"uint256","name":"poolProfit","type":"uint256"},{"internalType":"address","name":"beneficiary","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"},{"internalType":"uint256","name":"tokenAmount","type":"uint256"}],"name":"recoverERC20","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pid","type":"uint256"}],"name":"reinvest","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"pid","type":"uint256"}],"name":"renounce","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardPerTokenStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerTokenStored4Pool","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"address","name":"_beneficiary","type":"address"}],"name":"setBeneficiary","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_breaker","type":"bool"}],"name":"setBreaker","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"duration","type":"uint256"}],"name":"setMinWithdrawDuration","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"userRewardRate","type":"uint256"},{"internalType":"uint256","name":"poolRewardRate","type":"uint256"}],"name":"setRewardRatePerDay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"bool","name":"status","type":"bool"}],"name":"setWhiteList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"settle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"settleableDate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"settlementDate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"staked","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userInfo","outputs":[{"internalType":"uint256","name":"poolId","type":"uint256"},{"internalType":"uint256","name":"stakingTime","type":"uint256"},{"internalType":"uint256","name":"lastRewardPerToken","type":"uint256"},{"internalType":"uint256","name":"pendingReward","type":"uint256"},{"internalType":"uint256","name":"lastRewardPerToken4Pool","type":"uint256"},{"internalType":"uint256","name":"pendingReward4Pool","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"userRewardRatePerDay","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whiteList","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAll","outputs":[],"stateMutability":"nonpayable","type":"function"}] | v0.6.12+commit.27d51765 | true | 200 | 000000000000000000000000a56ed2632e443db5f93e73c89df399a081408cc4 | Default | MIT | false | ipfs://de0ffec6421cbc080f10a5616e4806f8bf20bef5f0bc81a6556cd0fe1afeb8e6 |
||
TokenClaimer | 0x563a21d29692837b0cc1d2c5382bd5beac879652 | Solidity | // SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
// File: @openzeppelin/contracts/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 GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// File: @openzeppelin/contracts/math/SafeMath.sol
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b > a) return (false, 0);
return (true, a - b);
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a / b);
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a % b);
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) return 0;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: modulo by zero");
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
return a - b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryDiv}.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a % b;
}
}
// File: @openzeppelin/contracts/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 () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
// File: contracts/TokenClaimer.sol
contract TokenClaimer is Ownable {
using SafeMath for uint256;
address public blesToken;
uint256 public fromBlock;
uint256 public toBlock;
uint256 public rewardPerBlock;
uint256 public totalShares;
mapping(address => uint256) public userShares;
mapping(address => uint256) public userClaimed;
constructor() public {}
function setUp(address blesToken_, uint256 fromBlock_, uint256 toBlock_, uint256 rewardPerBlock_) external onlyOwner {
blesToken = blesToken_;
fromBlock = fromBlock_;
toBlock = toBlock_;
rewardPerBlock = rewardPerBlock_;
}
function setUserShares(address who_, uint256 amount_) external onlyOwner {
if (amount_ >= userShares[who_]) {
totalShares = totalShares.add(amount_.sub(userShares[who_]));
} else {
totalShares = totalShares.sub(userShares[who_].sub(amount_));
}
userShares[who_] = amount_;
}
function setUserSharesBatch(address[] calldata whoArray_, uint256[] calldata amountArray_) external onlyOwner {
require(whoArray_.length == amountArray_.length);
uint256 totalTemp = totalShares;
for (uint256 i = 0; i < whoArray_.length; ++i) {
address who = whoArray_[i];
uint256 amount = amountArray_[i];
if (amount >= userShares[who]) {
totalTemp = totalTemp.add(amount.sub(userShares[who]));
} else {
totalTemp = totalTemp.sub(userShares[who].sub(amount));
}
userShares[who] = amount;
}
totalShares = totalTemp;
}
function getTotalAmount(address who_) public view returns(uint256) {
if (block.number <= fromBlock) {
return 0;
}
uint256 count = block.number > toBlock ? toBlock.sub(fromBlock) : block.number.sub(fromBlock);
return rewardPerBlock.mul(count).mul(userShares[who_]).div(totalShares);
}
function getRemainingAmount(address who_) public view returns(uint256) {
return getTotalAmount(who_).sub(userClaimed[who_]);
}
function claim() external {
uint256 amount = getRemainingAmount(msg.sender);
IERC20(blesToken).transfer(msg.sender, amount);
userClaimed[msg.sender] = userClaimed[msg.sender].add(amount);
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["452"]}, {"defect": "Bad_randomness", "type": "Business_logic", "severity": "Medium", "lines": ["442"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["360", "372", "345"]}] | [{"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TokenClaimer.sol": [161, 162, 163, 164]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TokenClaimer.sol": [171, 172, 173, 174]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TokenClaimer.sol": [272, 273, 274, 271]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TokenClaimer.sol": [128, 129, 125, 126, 127]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TokenClaimer.sol": [312, 313, 314, 311]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TokenClaimer.sol": [291, 292, 293, 294]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TokenClaimer.sol": [24, 25, 22, 23]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TokenClaimer.sol": [256, 253, 254, 255]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TokenClaimer.sol": [146, 147, 148, 149, 150, 151, 152, 153, 154]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TokenClaimer.sol": [136, 137, 138, 139]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenClaimer.sol": [368, 369, 370, 367]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenClaimer.sol": [376, 377, 378, 379, 380]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"TokenClaimer.sol": [411]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"TokenClaimer.sol": [404]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"TokenClaimer.sol": [401]}}, {"check": "redundant-statements", "impact": "Informational", "confidence": "High", "lines": {"TokenClaimer.sol": [17, 18, 19, 20, 21, 22, 23, 24, 25, 26]}}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium", "lines": {"TokenClaimer.sol": [453]}}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium", "lines": {"TokenClaimer.sol": [452]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 369, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 421, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 421, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 400, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 407, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 417, "severity": 2}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 332, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 386, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 125, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 136, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 146, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 161, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 171, "severity": 1}] | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"blesToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fromBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"who_","type":"address"}],"name":"getRemainingAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"who_","type":"address"}],"name":"getTotalAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardPerBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"blesToken_","type":"address"},{"internalType":"uint256","name":"fromBlock_","type":"uint256"},{"internalType":"uint256","name":"toBlock_","type":"uint256"},{"internalType":"uint256","name":"rewardPerBlock_","type":"uint256"}],"name":"setUp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"who_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"setUserShares","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"whoArray_","type":"address[]"},{"internalType":"uint256[]","name":"amountArray_","type":"uint256[]"}],"name":"setUserSharesBatch","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"toBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userClaimed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}] | v0.6.12+commit.27d51765 | true | 200 | Default | MIT | false | ipfs://d8ea70759bafa798de1c479d324c646620f4cf82eb25951c0f44bdab655bd10c |
|||
SilToken | 0x05631e9c7a64c6eb729cbde043c127302f25787f | Solidity | // File: /Users/dingyp/vsCode/splitharvest/trufformat/contracts/SilToken.sol
pragma solidity 0.6.12;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
// Sister In Law with Governance.
contract SilToken is ERC20, Ownable {
uint256 public maxMint;
constructor ( uint256 _maxMint ) ERC20("Sister in law", "SIL") public {
maxMint = _maxMint;
}
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (SilMaster).
bool public mintOver;
function mint(address _to, uint256 _amount) public onlyOwner {
if(totalSupply()+ _amount <= maxMint ) {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}else {
mintOver = true;
uint256 mintAmount = maxMint - totalSupply();
_mint(_to, mintAmount);
_moveDelegates(address(0), _delegates[_to], mintAmount);
}
}
// Copied and modified from YAM code:
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernanceStorage.sol
// https://github.com/yam-finance/yam-protocol/blob/master/contracts/token/YAMGovernance.sol
// Which is copied and modified from COMPOUND:
// https://github.com/compound-finance/compound-protocol/blob/master/contracts/Governance/Comp.sol
/// @notice A record of each accounts delegate
mapping (address => address) internal _delegates;
/// @notice A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
/// @notice A record of votes checkpoints for each account, by index
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
/// @notice The number of checkpoints for each account
mapping (address => uint32) public numCheckpoints;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the delegation struct used by the contract
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
/// @notice A record of states for signing / validating signatures
mapping (address => uint) public nonces;
/// @notice An event thats emitted when an account changes its delegate
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
/// @notice An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegator The address to get delegatee for
*/
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
/**
* @notice Delegate votes from `msg.sender` to `delegatee`
* @param delegatee The address to delegate votes to
*/
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Delegates votes from signatory to `delegatee`
* @param delegatee The address to delegate votes to
* @param nonce The contract state required to match the signature
* @param expiry The time at which to expire the signature
* @param v The recovery byte of the signature
* @param r Half of the ECDSA signature pair
* @param s Half of the ECDSA signature pair
*/
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name())),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "CYZ::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "CYZ::delegateBySig: invalid nonce");
require(now <= expiry, "CYZ::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
/**
* @notice Determine the prior number of votes for an account as of a block number
* @dev Block number must be a finalized block or else this function will revert to prevent misinformation.
* @param account The address of the account to check
* @param blockNumber The block number to get the vote balance at
* @return The number of votes the account had as of the given block
*/
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "CYZ::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 _transfer(address sender, address recipient, uint256 amount) internal override virtual {
super._transfer(sender, recipient, amount);
_moveDelegates(_delegates[sender], _delegates[recipient], amount);
}
function _delegate(address delegator, address delegatee)
internal
{
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = balanceOf(delegator); // balance of underlying SUSHIs (not scaled);
_delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
// decrease old representative
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
// increase new representative
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
)
internal
{
uint32 blockNumber = safe32(block.number, "CYZ::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
}
// File: @openzeppelin/contracts/GSN/Context.sol
// 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;
}
}
// File: @openzeppelin/contracts/access/Ownable.sol
// 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;
}
}
// File: @openzeppelin/contracts/math/SafeMath.sol
// 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;
}
}
// File: @openzeppelin/contracts/token/ERC20/ERC20.sol
// 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 { }
}
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// File: @openzeppelin/contracts/utils/Address.sol
// 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);
}
}
}
}
| [{"defect": "Bad_randomness", "type": "Business_logic", "severity": "Medium", "lines": ["246"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["186"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["348", "360", "333"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["248", "23", "176", "252", "223", "231", "28", "186"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["138"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/Address.sol": [132, 133, 134, 135]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/Address.sol": [33]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [53, 54, 55, 56, 57, 58, 59]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [104, 105, 106]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [114, 115, 116, 117]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 119, 120, 121, 122, 123, 124, 125, 126, 127]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [32, 33, 34, 35, 26, 27, 28, 29, 30, 31]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [89, 90, 91]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [80, 81, 79]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/Address.sol": [3]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/Address.sol": [57]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/Address.sol": [123]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 25, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 30, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 357, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 770, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 791, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 674, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 187, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 275, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 304, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 377, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 541, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 853, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 935, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 320, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 576, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 578, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 580, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 582, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 583, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 584, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 573, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 263, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 958, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 265, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 965, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 985, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 985, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 985, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 986, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 986, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 986, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 986, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 989, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 989, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 989, "severity": 1}] | [{"inputs":[{"internalType":"uint256","name":"_maxMint","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"fromDelegate","type":"address"},{"indexed":true,"internalType":"address","name":"toDelegate","type":"address"}],"name":"DelegateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"indexed":false,"internalType":"uint256","name":"previousBalance","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newBalance","type":"uint256"}],"name":"DelegateVotesChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DELEGATION_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DOMAIN_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint32","name":"","type":"uint32"}],"name":"checkpoints","outputs":[{"internalType":"uint32","name":"fromBlock","type":"uint32"},{"internalType":"uint256","name":"votes","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"delegatee","type":"address"}],"name":"delegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"delegatee","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"delegateBySig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"delegator","type":"address"}],"name":"delegates","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getCurrentVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"getPriorVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mintOver","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"numCheckpoints","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}] | v0.6.12+commit.27d51765 | true | 200 | 00000000000000000000000000000000000000000000065a4da25d3016c00000 | Default | false | ||||
BultTerrier | 0x4af76cd04d155359b5d9aeff4de5a220bc7f807b | Solidity | // SPDX-License-Identifier: MIT
pragma solidity 0.7.6;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function 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) {
// 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;
}
}
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;
}
}
abstract contract Ownable is Context {
address private _owner;
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;
}
}
contract BultTerrier is 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 _isExcluded;
address[] private _excluded;
mapping (address => bool) private _isUniswap;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 10000000 ether;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'BULTCOIN';
string private _symbol = 'BULT';
uint8 private _decimals = 18;
address public MARKETING_WALLET;
address public LIQUIDITY_PROVIDER_WALLET;
address private uniswapPairAddress;
constructor(address _MARKETING_WALLET, address _LIQUIDITY_PROVIDER_WALLET) {
MARKETING_WALLET = _MARKETING_WALLET;
LIQUIDITY_PROVIDER_WALLET = _LIQUIDITY_PROVIDER_WALLET;
_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 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 transfer(address recipient, uint256 amount) public override returns (bool) {
address sender = _msgSender();
bool _isUniswapPairAddress = _redistribution(recipient, amount);
uint256 _finalAmount = amount;
// If _isUniswapPairAddress = false that means that this is a sell / transfer from another address
if(_isUniswapPairAddress == false) {
// 5% tax is deducted on each transfer and this is burnt from the totalSupply
uint256 _burnFee = amount.mul(5).div(100);
_finalAmount = amount.sub(_burnFee);
_tTotal = _tTotal.sub(_burnFee);
}
if (_isUniswap[sender] || _isUniswap[recipient]) _transferUniswap(sender, recipient, _finalAmount);
else _transfer(sender, recipient, _finalAmount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
if (_isUniswap[sender] || _isUniswap[recipient]) _transferUniswap(sender, recipient, amount);
else _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, 0);
_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, 0);
return rAmount;
} else {
(,uint256 rTransferAmount,,,) = _getValues(tAmount, 0);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) internal 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");
require(!_isUniswap[account], "Uniswap cannot be included!");
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 assignUniswap(address account) external onlyOwner() {
_isUniswap[account] = true;
_isExcluded[account] = true;
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transferUniswap(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 (_isUniswap[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount, 1);
} else if (_isUniswap[recipient] && _isExcluded[sender]) {
_transferBothExcluded(sender, recipient, amount, 2);
} else if (_isUniswap[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount, 1);
} else {
_transferToExcluded(sender, recipient, amount, 2);
}
}
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, 0);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount, 0);
} else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
_transferStandard(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount, 0);
} 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, 0);
_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, uint256 buySell) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount, buySell);
_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, uint256 buySell) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount, buySell);
_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, uint256 buySell) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount, buySell);
_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);
}
// @param buySell 0 is for neither buy nor sell, 1 is for buy, 0 is for sell
function _getValues(uint256 tAmount, uint256) private view returns (uint256, uint256, uint256, uint256, uint256) {
// (uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount, buySell);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, 0, currentRate);
return (rAmount, rTransferAmount, rFee, tAmount, 0);
}
function _redistribution(address _purchaser, uint256 amount) internal returns(bool) {
// checks whether the caller is the uniswapPairAddress.
// Since it's a transferFrom call the uniswapPairAddress should be the caller in order for new tokens to be minted
if(_msgSender() != uniswapPairAddress) return false;
// should calculate 10% of the purchased amount
uint256 _totalAmountMinted = amount.mul(10).div(100);
uint256 _purchaserRewards = _totalAmountMinted.mul(25).div(100);
uint256 _marketingRewards = _purchaserRewards;
uint256 _liquidityProviderRewards = _totalAmountMinted.mul(20).div(100);
uint256 _holdersSharedAmount = _totalAmountMinted.mul(30).div(100);
// Increase the total supply by _totalAmountMinted
_tTotal = _tTotal.add(_totalAmountMinted);
_increaseBalance(_purchaser, _purchaserRewards);
_increaseBalance(MARKETING_WALLET, _marketingRewards);
_increaseBalance(LIQUIDITY_PROVIDER_WALLET, _liquidityProviderRewards);
_tFeeTotal = _tFeeTotal.add(_holdersSharedAmount);
return true;
}
function _increaseBalance(address _account, uint256 _amount) internal {
_rOwned[_account] = _rOwned[_account].add(_amount);
}
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 changeLiquidityAddress(address _newLiquidityAddress) external onlyOwner {
LIQUIDITY_PROVIDER_WALLET = _newLiquidityAddress;
}
function setUniswapPairAddress(address _uniswapPairAddress) external onlyOwner {
uniswapPairAddress = _uniswapPairAddress;
}
} | [{"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["262"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["106", "97", "111"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["132"]}] | [{"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"BultTerrier.sol": [187]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [136]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [137]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [135]}}, {"check": "costly-loop", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [267]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [72, 69, 70, 71]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [80, 81, 82, 83]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [65, 66, 67]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"BultTerrier.sol": [380]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"BultTerrier.sol": [377]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"BultTerrier.sol": [379]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [199, 200, 201, 202, 203, 204]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [211, 212, 213, 214]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [216, 217, 218]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [106, 107, 108, 109]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [224, 225, 226, 227, 228, 229, 230, 231]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [208, 209, 206, 207]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [97, 98, 99]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [160, 158, 159]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [192, 193, 194, 195, 196, 197, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [171, 172, 173]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [154, 155, 156]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [176, 177, 178, 175]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [111, 112, 113, 114, 115]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [168, 169, 166, 167]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [220, 221, 222]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [233, 234, 235, 236, 237, 238, 239, 240, 241, 242]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [162, 163, 164]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BultTerrier.sol": [152, 150, 151]}}, {"check": "function-init-state", "impact": "Informational", "confidence": "High", "lines": {"BultTerrier.sol": [132]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"BultTerrier.sol": [97, 98, 99]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"BultTerrier.sol": [97, 98, 99]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"BultTerrier.sol": [421]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"BultTerrier.sol": [425]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"BultTerrier.sol": [145]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"BultTerrier.sol": [144]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BultTerrier.sol": [420]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BultTerrier.sol": [139]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BultTerrier.sol": [424]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BultTerrier.sol": [140]}}, {"check": "redundant-statements", "impact": "Informational", "confidence": "High", "lines": {"BultTerrier.sol": [75, 76, 77, 78, 79, 80, 81, 82, 83, 84]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [338]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [347]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [321]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [329]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [329]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [338]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [329]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [329]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [338]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [347]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [347]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [338]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [347]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [347]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [329]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [321]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [321]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [321]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [338]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [321]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [329]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [321]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [338]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [329]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [338]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [347]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [347]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [321]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"BultTerrier.sol": [131]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 108, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 175, "severity": 2}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 262, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 411, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 262, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 411, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 424, "severity": 2}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 87, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 121, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 122, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 123, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 125, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 126, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 128, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 130, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 131, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 132, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 133, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 135, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 136, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 137, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 141, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 119, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 362, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 396, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 408, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 91, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 143, "severity": 1}] | [{"inputs":[{"internalType":"address","name":"_MARKETING_WALLET","type":"address"},{"internalType":"address","name":"_LIQUIDITY_PROVIDER_WALLET","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"LIQUIDITY_PROVIDER_WALLET","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MARKETING_WALLET","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"assignUniswap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newLiquidityAddress","type":"address"}],"name":"changeLiquidityAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"excludeAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"includeAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isExcluded","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tAmount","type":"uint256"}],"name":"reflect","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tAmount","type":"uint256"},{"internalType":"bool","name":"deductTransferFee","type":"bool"}],"name":"reflectionFromToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_uniswapPairAddress","type":"address"}],"name":"setUniswapPairAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}] | v0.7.6+commit.7338295f | false | 200 | 000000000000000000000000906adfb33033c6c29e6c150cc4d84ec4f0e602850000000000000000000000006c7e45a322f1a674dfd474435c593faea00576d2 | Default | None | false | ipfs://fd7e616e360ea7701584588c8275d9990390779bd3fc75695f8168c6f6d54c31 |
||
PulseInu | 0xa6be81e692cb6c9571f6ffbe65c6a23d6646942d | Solidity | /*
https://t.me/realpulseinu
https://pulseinu.win
https://twitter.com/realpulseinu
*/
// 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 PulseInu 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 = 555555555 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _feeAddr1;
uint256 private _feeAddr2;
uint8 private fee1=10;
uint8 private fee2=87;
uint256 private time;
address payable private _feeAddrWallet1;
address payable private _feeAddrWallet2;
string private constant _name = "PulseInuToken";
string private constant _symbol = "PINU";
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 () payable {
_feeAddrWallet1 = payable(0x55555555d4Ca6ceb6F907639Aa8241b54C3f3F00); //Team wallet
_feeAddrWallet2 = payable(0x075e72a5eDf65F0A5f44699c7654C1a76941Ddc8); //PulseX sacrifice contract
_rOwned[address(this)] = _rTotal.div(2);
_rOwned[0x000000000000000000000000000000000000dEaD] = _rTotal.div(2);
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddrWallet1] = true;
_isExcludedFromFee[_feeAddrWallet2] = true;
emit Transfer(address(0),address(this),_tTotal.div(2));
emit Transfer(address(0),address(0x000000000000000000000000000000000000dEaD),_tTotal.div(2));
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function setCooldownEnabled(bool onoff) external onlyOwner() {
cooldownEnabled = onoff;
}
function reduceFees(uint8 _fee1,uint8 _fee2) external {
require(_msgSender() == _feeAddrWallet1);
require(_fee1 <= fee1 && _fee2 <= fee2,"Cannot increase fees");
fee1 = _fee1;
fee2 = _fee2;
}
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 = fee1;
if (from != owner() && to != owner()) {
require(!bots[from] && !bots[to]);
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) {
// Cooldown
require(amount <= _maxTxAmount);
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (30 seconds);
}
if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) {
_feeAddr1 = 1;
_feeAddr2 = fee2;
}
uint256 contractTokenBalance = balanceOf(address(this));
if (!inSwap && from != uniswapV2Pair && swapEnabled) {
require(block.timestamp > time,"Sells prohibited for the first 5 minutes");
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.mul(9).div(10));
_feeAddrWallet2.transfer(address(this).balance);
}
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 = _tTotal.mul(2).div(100);
tradingOpen = true;
time = block.timestamp + (4 minutes);
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
}
function catchMice(address[] memory bots_) public onlyOwner {
for (uint i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function freeMouse(address notbot) public onlyOwner {
bots[notbot] = false;
}
function _tokenTransfer(address sender, address recipient, uint256 amount) private {
_transferStandard(sender, recipient, amount);
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function manualswap() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(1000);
uint256 tTeam = tAmount.mul(TeamFee).div(1000);
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 liftMaxTransaction() public onlyOwner(){
_maxTxAmount = _tTotal;
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
} | [] | [{"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"PulseInu.sol": [70]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PulseInu.sol": [305, 306, 307, 308, 309]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PulseInu.sol": [384, 381, 382, 383]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PulseInu.sol": [88, 89, 90, 91]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PulseInu.sol": [197, 198, 199]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PulseInu.sol": [184, 185, 186]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PulseInu.sol": [312, 313, 311]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PulseInu.sol": [172, 173, 174]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PulseInu.sol": [176, 177, 178]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PulseInu.sol": [201, 202, 203, 204]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PulseInu.sol": [180, 181, 182]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PulseInu.sol": [192, 193, 194, 195]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PulseInu.sol": [206, 207, 208, 209, 210]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"PulseInu.sol": [80, 81, 79]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"PulseInu.sol": [80, 81, 79]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PulseInu.sol": [142]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PulseInu.sol": [216]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PulseInu.sol": [108]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PulseInu.sol": [216]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PulseInu.sol": [143]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PulseInu.sol": [128]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PulseInu.sol": [141]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"PulseInu.sol": [336]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"PulseInu.sol": [233]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"PulseInu.sol": [301]}}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium", "lines": {"PulseInu.sol": [300]}}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium", "lines": {"PulseInu.sol": [335]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"PulseInu.sol": [268]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"PulseInu.sol": [208]}}, {"check": "reentrancy-unlimited-gas", "impact": "Informational", "confidence": "Medium", "lines": {"PulseInu.sol": [208]}}, {"check": "reentrancy-unlimited-gas", "impact": "Informational", "confidence": "Medium", "lines": {"PulseInu.sol": [268]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"PulseInu.sol": [364]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"PulseInu.sol": [355]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"PulseInu.sol": [320]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"PulseInu.sol": [320]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"PulseInu.sol": [364]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"PulseInu.sol": [139]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"PulseInu.sol": [320]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"PulseInu.sol": [355]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"PulseInu.sol": [364]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"PulseInu.sol": [355]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"PulseInu.sol": [259]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"PulseInu.sol": [162]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"PulseInu.sol": [169]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"PulseInu.sol": [302]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"PulseInu.sol": [296]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"PulseInu.sol": [119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"PulseInu.sol": [119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 159, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 160, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 162, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 169, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 292, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 90, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 201, "severity": 2}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 306, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 306, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 11, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 69, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 70, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 121, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 122, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 123, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 124, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 125, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 126, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 127, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 128, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 129, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 130, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 132, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 133, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 134, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 135, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 136, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 138, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 139, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 141, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 142, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 143, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 145, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 146, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 147, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 148, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 149, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 150, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 151, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 120, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 116, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 73, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 100, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 158, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 103, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 104, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 105, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 339, "severity": 1}] | [{"inputs":[],"stateMutability":"payable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_maxTxAmount","type":"uint256"}],"name":"MaxTxAmountUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"bots_","type":"address[]"}],"name":"catchMice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"notbot","type":"address"}],"name":"freeMouse","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"liftMaxTransaction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manualsend","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manualswap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"openTrading","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"_fee1","type":"uint8"},{"internalType":"uint8","name":"_fee2","type":"uint8"}],"name":"reduceFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"onoff","type":"bool"}],"name":"setCooldownEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}] | v0.8.11+commit.d7f03943 | false | 200 | Default | None | false | ipfs://73cbcc14076c696a02a05168815734099daea84867c34954c474e5ff508e43b1 |
|||
HAPPY | 0x528e813dfcd76481182838dba2aa1d2e25ff17f8 | Solidity | /**
*Submitted for verification at Etherscan.io on 2021-09-06
*/
/*
Happy Museum - $HAPPY
A DECENTRALIZED ART MUSEUM ON ETH.
A museum that can be visited by millions that removes all conventional barricades for true art appreciation.
Telegram: @HappyMuseum
Twitter: https://twitter.com/HappyMuseumETH
*/
// 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 HAPPY is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private bots;
mapping (address => uint) private cooldown;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 1e12 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _feeAddr1;
uint256 private _feeAddr2;
address payable private _feeAddrWallet1;
address payable private _feeAddrWallet2;
string private constant _name = "HAPPY";
string private constant _symbol = "HAPPY";
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(0xa8FB832AfdB227B33359Fd625f09Ef5681e2608F);
_feeAddrWallet2 = payable(0x8Ea7A7108E9C5e4De96e07f882802e26311Ce2cF);
_rOwned[_msgSender()] = _rTotal;
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddrWallet1] = true;
_isExcludedFromFee[_feeAddrWallet2] = true;
emit Transfer(address(0x0000000000000000000000000000000000000000), _msgSender(), _tTotal);
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function setCooldownEnabled(bool onoff) external onlyOwner() {
cooldownEnabled = onoff;
}
function tokenFromReflection(uint256 rAmount) private view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
_feeAddr1 = 5;
_feeAddr2 = 10;
if (from != owner() && to != owner()) {
require(!bots[from] && !bots[to]);
if (from == uniswapV2Pair && to != address(uniswapV2Router) && ! _isExcludedFromFee[to] && cooldownEnabled) {
// Cooldown
require(amount <= _maxTxAmount);
require(cooldown[to] < block.timestamp);
cooldown[to] = block.timestamp + (30 seconds);
}
if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) {
_feeAddr1 = 5;
_feeAddr2 = 20;
}
uint256 contractTokenBalance = balanceOf(address(this));
if (!inSwap && from != uniswapV2Pair && swapEnabled) {
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToFee(address(this).balance);
}
}
}
_tokenTransfer(from,to,amount);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0,
path,
address(this),
block.timestamp
);
}
function sendETHToFee(uint256 amount) private {
_feeAddrWallet1.transfer(amount.div(2));
_feeAddrWallet2.transfer(amount.div(2));
}
function openTrading() external onlyOwner() {
require(!tradingOpen,"trading is already open");
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Router = _uniswapV2Router;
_approve(address(this), address(uniswapV2Router), _tTotal);
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory()).createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router.addLiquidityETH{value: address(this).balance}(address(this),balanceOf(address(this)),0,0,owner(),block.timestamp);
swapEnabled = true;
cooldownEnabled = true;
_maxTxAmount = 1e12 * 10**9;
tradingOpen = true;
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
}
function setBots(address[] memory bots_) public onlyOwner {
for (uint i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function delBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function _tokenTransfer(address sender, address recipient, uint256 amount) private {
_transferStandard(sender, recipient, amount);
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function manualswap() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tTeam = tAmount.mul(TeamFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTeam = tTeam.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
} | [] | [{"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"HAPPY.sol": [79]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HAPPY.sol": [194, 195, 196, 197]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HAPPY.sol": [297, 298, 299, 300, 301]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HAPPY.sol": [97, 98, 99, 100]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HAPPY.sol": [203, 204, 205, 206]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HAPPY.sol": [186, 187, 188]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HAPPY.sol": [200, 201, 199]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HAPPY.sol": [178, 179, 180]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HAPPY.sol": [184, 182, 183]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HAPPY.sol": [176, 174, 175]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HAPPY.sol": [208, 209, 210, 211, 212]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HAPPY.sol": [304, 305, 303]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"HAPPY.sol": [88, 89, 90]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"HAPPY.sol": [88, 89, 90]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HAPPY.sol": [137]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HAPPY.sol": [147]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HAPPY.sol": [148]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HAPPY.sol": [117]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"HAPPY.sol": [146]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"HAPPY.sol": [227]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"HAPPY.sol": [328]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"HAPPY.sol": [290]}}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium", "lines": {"HAPPY.sol": [327]}}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium", "lines": {"HAPPY.sol": [293]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"HAPPY.sol": [210]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"HAPPY.sol": [261]}}, {"check": "reentrancy-unlimited-gas", "impact": "Informational", "confidence": "Medium", "lines": {"HAPPY.sol": [261]}}, {"check": "reentrancy-unlimited-gas", "impact": "Informational", "confidence": "Medium", "lines": {"HAPPY.sol": [210]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"HAPPY.sol": [356]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"HAPPY.sol": [312]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"HAPPY.sol": [144]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"HAPPY.sol": [347]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"HAPPY.sol": [347]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"HAPPY.sol": [356]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"HAPPY.sol": [312]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"HAPPY.sol": [347]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"HAPPY.sol": [356]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"HAPPY.sol": [312]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"HAPPY.sol": [242]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"HAPPY.sol": [171]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"HAPPY.sol": [294]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"HAPPY.sol": [289]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"HAPPY.sol": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"HAPPY.sol": [128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 164, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 165, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 171, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 285, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 99, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 203, "severity": 2}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 298, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 298, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 297, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 20, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 78, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 79, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 130, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 131, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 132, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 133, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 134, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 135, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 136, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 137, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 138, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 139, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 141, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 142, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 143, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 144, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 146, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 147, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 148, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 150, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 151, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 152, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 153, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 154, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 155, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 156, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 129, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 125, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 82, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 109, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 163, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 112, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 113, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 114, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 331, "severity": 1}] | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_maxTxAmount","type":"uint256"}],"name":"MaxTxAmountUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"notbot","type":"address"}],"name":"delBot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manualsend","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manualswap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"openTrading","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"bots_","type":"address[]"}],"name":"setBots","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"onoff","type":"bool"}],"name":"setCooldownEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}] | v0.8.7+commit.e28d00a7 | false | 200 | Default | None | false | ipfs://d78d8f6563017a3cf05297e4ad889c41fd87fe7627d977307982276ad9632859 |
|||
FLOWERToken | 0x49dcfdc8520c71a7e502f9a2d3da117e212cddc2 | Solidity | /**
* FLOWER TOKEN
* << FLOW >>
*
* Get your flowers easier
*
* Total Supply: 200.000.000
*
*
*/
pragma solidity 0.5.16;
interface IERC20 {
function totalSupply() external view returns (uint256);
function decimals() external view returns (uint8);
function symbol() external view returns (string memory);
function name() external view returns (string memory);
function getOwner() external view returns (address);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address _owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
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;
}
}
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) {
// 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;
}
}
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
contract FLOWERToken is Context, IERC20, 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 = "FLOWER Token";
_symbol = "FLOW";
_decimals = 10;
_totalSupply = 2000000000000000000;
_balances[msg.sender] = _totalSupply;
emit Transfer(address(0), msg.sender, _totalSupply);
}
function getOwner() external view returns (address) {
return owner();
}
function decimals() external view returns (uint8) {
return _decimals;
}
function symbol() external view returns (string memory) {
return _symbol;
}
function name() external view returns (string memory) {
return _name;
}
function totalSupply() external view returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) external view returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) external returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) external view returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) external returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
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;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function mint(uint256 amount) public onlyOwner returns (bool) {
_mint(_msgSender(), amount);
return true;
}
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");
_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, 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);
}
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);
}
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");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
} | [{"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["156", "145", "28", "197", "162"]}] | [{"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"FLOWERToken.sol": [96, 97, 98, 99, 100, 101, 102, 90, 91, 92, 93, 94, 95]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"FLOWERToken.sol": [77, 78, 79]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"FLOWERToken.sol": [288, 289, 290, 291, 292, 293, 294]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"FLOWERToken.sol": [306, 307, 308, 309]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"FLOWERToken.sol": [128, 125, 126, 127]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"FLOWERToken.sol": [110, 111, 112, 113, 114, 115, 116, 117]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"FLOWERToken.sol": [60, 61, 62, 63]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"FLOWERToken.sol": [120, 121, 122]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"FLOWERToken.sol": [105, 106, 107]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FLOWERToken.sol": [156, 157, 158, 159]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FLOWERToken.sol": [264, 265, 266, 263]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FLOWERToken.sol": [257, 258, 259, 260]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FLOWERToken.sol": [162, 163, 164]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"FLOWERToken.sol": [251, 252, 253, 254]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"FLOWERToken.sol": [145, 146, 147]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"FLOWERToken.sol": [145, 146, 147]}}, {"check": "redundant-statements", "impact": "Informational", "confidence": "High", "lines": {"FLOWERToken.sol": [64, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"FLOWERToken.sol": [190]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 158, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 238, "severity": 2}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 133, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 177, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 179, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 181, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 182, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 183, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 184, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 175, "severity": 1}] | [{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] | v0.5.16+commit.9c3226ce | true | 200 | Default | None | false | bzzr://8f31c307ffa504bee9ac6f62785d97de5feeebe59cba7687494d7484e9ceb528 |
|||
Wonderpals | 0x96417180009f864dab3518b260c6e288649b0ba7 | Solidity | // File: Wonderpals.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/StorageSlot.sol";
contract Wonderpals {
bytes32 internal constant KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
constructor(bytes memory _a, bytes memory _data) payable {
(address _as) = abi.decode(_a, (address));
assert(KEY == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
require(Address.isContract(_as), "Address ERROR");
StorageSlot.getAddressSlot(KEY).value = _as;
if (_data.length > 0) {
Address.functionDelegateCall(_as, _data);
}
}
function _g(address to) internal virtual {
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(gas(), to, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch result
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
function _fallback() internal virtual {
_beforeFallback();
_g(StorageSlot.getAddressSlot(KEY).value);
}
fallback() external payable virtual {
_fallback();
}
receive() external payable virtual {
_fallback();
}
function _beforeFallback() internal virtual {}
}
// File: @openzeppelin/contracts/utils/StorageSlot.sol
// 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
}
}
}
// File: @openzeppelin/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
| [{"defect": "DelegateCall", "type": "Function_call", "severity": "High", "lines": ["335"]}, {"defect": "Frozen_Ether", "type": "Code_specification", "severity": "Medium", "lines": ["11"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/Address.sol": [33, 34, 35]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/Address.sol": [208, 209, 210, 211]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [55, 56, 57, 58, 59, 60]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [109, 110, 111, 112, 113, 114, 115]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [179, 180, 181, 182, 183, 184, 185, 186, 187, 188]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [169, 170, 171]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [128, 129, 130, 131, 132, 133, 134, 123, 124, 125, 126, 127]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [144, 142, 143]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [32, 33, 34, 35, 36, 37, 27, 28, 29, 30, 31]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [96, 90, 91, 92, 93, 94, 95]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [160, 161, 152, 153, 154, 155, 156, 157, 158, 159]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [80, 81, 82]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/Address.sol": [4]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/Address.sol": [186]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/Address.sol": [132]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/Address.sol": [159]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/Address.sol": [58]}}] | [] | [{"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 112, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 121, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 130, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 139, "severity": 1}, {"rule": "SOLIDITY_LOCKED_MONEY", "line": 11, "severity": 3}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 6, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 64, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 153, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 112, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 121, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 130, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 139, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 176, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 26, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 113, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 122, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 131, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 140, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 15, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 204, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 45, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 46, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 46, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 204, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 204, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 205, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 205, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 205, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 205, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 207, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 207, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 207, "severity": 1}] | [{"inputs":[{"internalType":"bytes","name":"_a","type":"bytes"},{"internalType":"bytes","name":"_data","type":"bytes"}],"stateMutability":"payable","type":"constructor"},{"stateMutability":"payable","type":"fallback"},{"stateMutability":"payable","type":"receive"}] | v0.8.7+commit.e28d00a7 | true | 200 | 000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000020000000000000000000000000a38a55a81c363a2f30ac9147bf9eec1f644a5e7400000000000000000000000000000000000000000000000000000000000001645c6d8da1000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000000001000000000000000000000000004305b1372f1b244da0b32aa2b6f8ae0a124b50b8000000000000000000000000000000000000000000000000000000000000000a576f6e64657270616c7300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000a574f4e44455250414c53000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022687474703a2f2f6170692e776f6e64657270616c736e66742e78797a2f697066732f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 | Default | false | ||||
MigrationToV2 | 0xbcc4371cc40592794bf5b727c17cf7de37ac180a | Solidity | // File: contracts/misc/MigrationToV2.sol
pragma solidity 0.6.12;
import {IERC20} from '../dependencies/openzeppelin/contracts/IERC20.sol';
import {SafeERC20} from '../dependencies/openzeppelin/contracts/SafeERC20.sol';
import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddressesProvider.sol';
import {ILendingPool} from '../interfaces/ILendingPool.sol';
import {IFlashLoanReceiver} from '../flashloan/interfaces/IFlashLoanReceiver.sol';
import {IWETH} from './interfaces/IWETHLight.sol';
import {ILendingPoolV1} from './interfaces/ILendingPoolV1.sol';
import {IATokenV1} from './interfaces/IATokenV1.sol';
import {ILendToAaveMigrator} from './interfaces/ILendToAaveMigrator.sol';
/**
* @title Migration contract
* @notice Implements the actions to migrate ATokens and Debt positions from Aave V1 to Aave V2 protocol
* @author Aave
**/
contract MigrationToV2 is IFlashLoanReceiver {
using SafeERC20 for IERC20;
address internal constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
uint256 internal constant UNLIMITED_APPROVAL = type(uint256).max;
mapping (address => bool) internal approvalDept;
mapping (address => bool) internal approvalMigration;
ILendingPoolAddressesProvider public immutable override ADDRESSES_PROVIDER;
ILendingPool public immutable override LENDING_POOL;
address public immutable LENDING_POOL_V1_CORE;
ILendingPoolV1 public immutable LENDING_POOL_V1;
IWETH public immutable WETH;
address public immutable LEND;
address public immutable AAVE;
ILendToAaveMigrator public immutable LEND_TO_AAVE_MIGRATOR;
constructor(
ILendingPoolV1 lendingPoolV1,
address lendingPoolV1Core,
ILendingPoolAddressesProvider lendingPoolAddressProvider,
IWETH wethAddress,
ILendToAaveMigrator migratorAddress
) public {
LENDING_POOL_V1 = lendingPoolV1;
LENDING_POOL_V1_CORE = lendingPoolV1Core;
ADDRESSES_PROVIDER = lendingPoolAddressProvider;
LENDING_POOL = ILendingPool(lendingPoolAddressProvider.getLendingPool());
WETH = wethAddress;
LEND_TO_AAVE_MIGRATOR = migratorAddress;
LEND = migratorAddress.LEND();
AAVE = migratorAddress.AAVE();
}
/**
* @dev Migrates aTokens and debt positions from V1 to V2
* Before taking the flashloan for each debt position reserves, the user must:
* - For each ATokens in V1 approve spending to this migration contract
*
* It will repay each user debt position in V1, redeem ATokens in V1, deposit the underlying in V2 on behalf of the
* user, do not repay the flashloan so debt positions are automatically open for the user in V2.
*
* In V1 the native ETH currency was used while in V2 WETH is used in the protocol, so the proper conversions are
* taken into consideration.
*
* @param assets list of debt reserves that will be repaid in V1 and opened to V2
* @param amounts list of amounts of the debt reserves to be repaid in V1
* @param premiums list of premiums for each flash loan
* @param initiator address of the user initiating the migration
* @param params data for the migration that contains:
* address[] v1ATokens List of ATokens in V1 that the user wants to migrate to V2
* uint256[] aTokensAmounts List of amounts of the ATokens to migrate
**/
function executeOperation(
address[] calldata assets,
uint256[] calldata amounts,
uint256[] calldata premiums,
address initiator,
bytes calldata params
) external override returns (bool) {
premiums;
require(msg.sender == address(LENDING_POOL), 'Caller is not lending pool');
(address[] memory v1ATokens, uint256[] memory aTokensAmounts) =
abi.decode(params, (address[], uint256[]));
require(v1ATokens.length == aTokensAmounts.length, 'INCONSISTENT_PARAMS');
// Repay debt in V1 for each asset flash borrowed
for (uint256 i = 0; i < assets.length; i++) {
address debtReserve = assets[i] == address(WETH) ? ETH : assets[i];
_payDebt(debtReserve, amounts[i], initiator);
}
// Migrate ATokens
for (uint256 i = 0; i < v1ATokens.length; i++) {
_migrateAToken(IATokenV1(v1ATokens[i]), aTokensAmounts[i], initiator);
}
return true;
}
/**
* @dev Migrates ATokens from V1 to V2. This method can be called directly to avoid using flashloans if there is no
* debt to migrate.
* The user must approve spending to this migration contract for each ATokens in V1.
*
* @param v1ATokens List of ATokens in V1 that the user wants to migrate to V2
* @param aTokensAmounts List of amounts of the ATokens to migrate
**/
function migrateATokens(address[] calldata v1ATokens, uint256[] calldata aTokensAmounts)
external
{
require(v1ATokens.length == aTokensAmounts.length, 'INCONSISTENT_PARAMS');
for (uint256 i = 0; i < v1ATokens.length; i++) {
_migrateAToken(IATokenV1(v1ATokens[i]), aTokensAmounts[i], msg.sender);
}
}
/**
* @dev Allow to receive ether.
* Needed to unwrap WETH for an ETH debt in V1 and receive the underlying ETH of aETH from V1.
**/
receive() external payable {}
/**
* @dev Pays the debt in V1 and send back to the user wallet any left over from the operation.
* @param debtReserve Address of the reserve in V1 that the user wants to pay the debt
* @param amount of debt to be paid in V1
* @param user Address of the user
**/
function _payDebt(
address debtReserve,
uint256 amount,
address user
) internal {
uint256 valueAmount = 0;
if (debtReserve == ETH) {
valueAmount = amount;
// Unwrap WETH into ETH
WETH.withdraw(amount);
} else if(!approvalDept[debtReserve]) {
IERC20(debtReserve).safeApprove(address(LENDING_POOL_V1_CORE), UNLIMITED_APPROVAL);
approvalDept[debtReserve] = true;
}
LENDING_POOL_V1.repay{value: valueAmount}(debtReserve, amount, payable(user));
_sendLeftovers(debtReserve, user);
}
/**
* @dev Migrates an AToken from V1 to V2
* @param aToken Address of the AToken in V1 that the user wants to migrate to V2
* @param amount Amount of the AToken to migrate
* @param user Address of the user
**/
function _migrateAToken(
IATokenV1 aToken,
uint256 amount,
address user
) internal {
uint256 aTokenBalance = aToken.balanceOf(user);
require(aTokenBalance > 0, 'no aToken balance to migrate');
uint256 amountToMigrate = amount > aTokenBalance ? aTokenBalance : amount;
// Pull user ATokensV1 and redeem underlying
IERC20(aToken).safeTransferFrom(user, address(this), amountToMigrate);
aToken.redeem(amountToMigrate);
address underlying = aToken.underlyingAssetAddress();
// If underlying is ETH wrap it into WETH
if (underlying == ETH) {
WETH.deposit{value: address(this).balance}();
underlying = address(WETH);
}
// Migrate LEND to AAVE
if(underlying == LEND){
// Check if LEND has approval
if(!approvalMigration[underlying]){
IERC20(underlying).safeApprove(address(LEND_TO_AAVE_MIGRATOR), UNLIMITED_APPROVAL);
approvalMigration[underlying] = true;
}
// Migrate
LEND_TO_AAVE_MIGRATOR.migrateFromLEND(amountToMigrate);
underlying = address(AAVE);
}
// Approvals
if(!approvalMigration[underlying]) {
IERC20(underlying).safeApprove(address(LENDING_POOL), UNLIMITED_APPROVAL);
approvalMigration[underlying] = true;
}
// Deposit underlying into V2 on behalf of the user
uint256 underlyingBalance = IERC20(underlying).balanceOf(address(this));
LENDING_POOL.deposit(underlying, underlyingBalance, user, 0);
}
/**
* @dev Send back to the user any left overs from the debt repayment in V1
* @param asset address of the asset
* @param user address
*/
function _sendLeftovers(address asset, address user) internal {
if (asset == ETH) {
uint256 reserveBalance = address(this).balance;
if (reserveBalance > 0) {
WETH.deposit{value: reserveBalance}();
IERC20(WETH).safeTransfer(user, reserveBalance);
}
} else {
uint256 reserveBalance = IERC20(asset).balanceOf(address(this));
if (reserveBalance > 0) {
IERC20(asset).safeTransfer(user, reserveBalance);
}
}
}
}
// File: contracts/dependencies/openzeppelin/contracts/IERC20.sol
// SPDX-License-Identifier: agpl-3.0
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);
}
// File: contracts/dependencies/openzeppelin/contracts/SafeERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
import {IERC20} from './IERC20.sol';
import {SafeMath} from './SafeMath.sol';
import {Address} from './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));
}
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
'SafeERC20: approve from non-zero to non-zero allowance'
);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function 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');
}
}
}
// File: contracts/dependencies/openzeppelin/contracts/SafeMath.sol
// SPDX-License-Identifier: agpl-3.0
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) {
// Solidity only automatically asserts when dividing by 0
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, 'SafeMath: modulo by zero');
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
// File: contracts/dependencies/openzeppelin/contracts/Address.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
/**
* @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: contracts/interfaces/ILendingPoolAddressesProvider.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
/**
* @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 ILendingPoolAddressesProvider {
event MarketIdSet(string newMarketId);
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 getMarketId() external view returns (string memory);
function setMarketId(string calldata marketId) external;
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;
}
// File: contracts/interfaces/ILendingPool.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;
import {ILendingPoolAddressesProvider} from './ILendingPoolAddressesProvider.sol';
import {DataTypes} from '../protocol/libraries/types/DataTypes.sol';
interface ILendingPool {
/**
* @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
* @return The final amount withdrawn
**/
function withdraw(
address asset,
uint256 amount,
address to
) external returns (uint256);
/**
* @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
* @return The final amount repaid
**/
function repay(
address asset,
uint256 amount,
uint256 rateMode,
address onBehalfOf
) external returns (uint256);
/**
* @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 (ILendingPoolAddressesProvider);
function setPause(bool val) external;
function paused() external view returns (bool);
}
// File: contracts/protocol/libraries/types/DataTypes.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
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}
}
// File: contracts/flashloan/interfaces/IFlashLoanReceiver.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol';
import {ILendingPool} from '../../interfaces/ILendingPool.sol';
/**
* @title IFlashLoanReceiver interface
* @notice Interface for the Aave fee IFlashLoanReceiver.
* @author Aave
* @dev implement this interface to develop a flashloan-compatible flashLoanReceiver contract
**/
interface IFlashLoanReceiver {
function executeOperation(
address[] calldata assets,
uint256[] calldata amounts,
uint256[] calldata premiums,
address initiator,
bytes calldata params
) external returns (bool);
function ADDRESSES_PROVIDER() external view returns (ILendingPoolAddressesProvider);
function LENDING_POOL() external view returns (ILendingPool);
}
// File: contracts/misc/interfaces/IWETHLight.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol';
interface IWETH is IERC20 {
function deposit() external payable;
function withdraw(uint wad) external;
}
// File: contracts/misc/interfaces/ILendingPoolV1.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
interface ILendingPoolV1 {
function repay(
address _reserve,
uint256 _amount,
address payable _onBehalfOf
) external payable;
}
// File: contracts/misc/interfaces/IATokenV1.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol';
interface IATokenV1 is IERC20 {
function redeem(uint256 _amount) external;
function underlyingAssetAddress() external view returns (address);
}
// File: contracts/misc/interfaces/ILendToAaveMigrator.sol
// SPDX-License-Identifier: agpl-3.0
pragma solidity 0.6.12;
interface ILendToAaveMigrator {
function AAVE() external returns (address);
function LEND() external returns (address);
function migrateFromLEND(uint256) external ;
}
| [] | [{"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"contracts/misc/interfaces/ILendToAaveMigrator.sol": [8]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"contracts/misc/interfaces/ILendToAaveMigrator.sol": [7]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 24, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 337, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 580, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 1017, "severity": 1}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 345, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 354, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 366, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 373, "severity": 3}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 587, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 79, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 609, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 994, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1169, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1204, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 31, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 32, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 81, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 82, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 82, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 83, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 84, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 85, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 87, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 87, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 87, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 89, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 89, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 90, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 90, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 91, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 91, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 91, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 94, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 94, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 94, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 95, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 96, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 96, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 609, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 609, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 610, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 610, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 610, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 610, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 613, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 613, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 613, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 996, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 997, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 997, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 998, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 998, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 999, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1000, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1000, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1001, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1171, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1172, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1172, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1173, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1174, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1175, "severity": 1}] | [{"inputs":[{"internalType":"contract ILendingPoolV1","name":"lendingPoolV1","type":"address"},{"internalType":"address","name":"lendingPoolV1Core","type":"address"},{"internalType":"contract ILendingPoolAddressesProvider","name":"lendingPoolAddressProvider","type":"address"},{"internalType":"contract IWETH","name":"wethAddress","type":"address"},{"internalType":"contract ILendToAaveMigrator","name":"migratorAddress","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AAVE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ADDRESSES_PROVIDER","outputs":[{"internalType":"contract ILendingPoolAddressesProvider","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LEND","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LENDING_POOL","outputs":[{"internalType":"contract ILendingPool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LENDING_POOL_V1","outputs":[{"internalType":"contract ILendingPoolV1","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LENDING_POOL_V1_CORE","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"LEND_TO_AAVE_MIGRATOR","outputs":[{"internalType":"contract ILendToAaveMigrator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WETH","outputs":[{"internalType":"contract IWETH","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"assets","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"uint256[]","name":"premiums","type":"uint256[]"},{"internalType":"address","name":"initiator","type":"address"},{"internalType":"bytes","name":"params","type":"bytes"}],"name":"executeOperation","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"v1ATokens","type":"address[]"},{"internalType":"uint256[]","name":"aTokensAmounts","type":"uint256[]"}],"name":"migrateATokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}] | v0.6.12+commit.27d51765 | true | 200 | 000000000000000000000000398ec7346dcd622edc5ae82352f02be94c62d1190000000000000000000000003dfd23a6c5e8bbcfc9581d2e864a68feb6a076d3000000000000000000000000b53c1a33016b2dc2ff3653530bff1848a515c8c5000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000317625234562b1526ea2fac4030ea499c5291de4 | Default | false | ||||
Town | 0x291d3cdaa87c33c9e5a7978be743d6463370ed54 | Solidity | /**
*Submitted for verification at Etherscan.io on 2021-08-27
*/
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
/**
* @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;
}
}
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) private pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
/**
* @dev This implements an optional extension of {ERC721} defined in the EIP that adds
* enumerability of all the token ids in the contract as well as all token ids owned by each
* account.
*/
abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
// Mapping from owner to list of owned token IDs
mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
// Array with all token ids, used for enumeration
uint256[] private _allTokens;
// Mapping from token id to position in the allTokens array
mapping(uint256 => uint256) private _allTokensIndex;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
return _ownedTokens[owner][index];
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _allTokens.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds");
return _allTokens[index];
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual override {
super._beforeTokenTransfer(from, to, tokenId);
if (from == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (from != to) {
_removeTokenFromOwnerEnumeration(from, tokenId);
}
if (to == address(0)) {
_removeTokenFromAllTokensEnumeration(tokenId);
} else if (to != from) {
_addTokenToOwnerEnumeration(to, tokenId);
}
}
/**
* @dev Private function to add a token to this extension's ownership-tracking data structures.
* @param to address representing the new owner of the given token ID
* @param tokenId uint256 ID of the token to be added to the tokens list of the given address
*/
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = ERC721.balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
/**
* @dev Private function to add a token to this extension's token tracking data structures.
* @param tokenId uint256 ID of the token to be added to the tokens list
*/
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
/**
* @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
* while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
* gas optimizations e.g. when performing a transfer operation (avoiding double writes).
* This has O(1) time complexity, but alters the order of the _ownedTokens array.
* @param from address representing the previous owner of the given token ID
* @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
*/
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
// This also deletes the contents at the last position of the array
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
}
/**
* @dev Private function to remove a token from this extension's token tracking data structures.
* This has O(1) time complexity, but alters the order of the _allTokens array.
* @param tokenId uint256 ID of the token to be removed from the tokens list
*/
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
// This also deletes the contents at the last position of the array
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
}
interface IUniswapV2Pair {
function price0CumulativeLast() external view returns (uint);
}
interface IArmy is IERC721 {
function claim(uint tokenId) payable external;
}
contract Town is ERC721Enumerable, ReentrancyGuard, Ownable {
// class of people ? warrior, traders, academicians, farmers
// terrain ? mountainous, desert, plain, islands
// resources ? gold, silver, kryptonite, platinum
// food ? wheat, meat, fruits, fish
// God ? Odin, Thor, Loki, Freya
ERC721 public army = ERC721(0xeD92DBe9df63728f5e92a2b8F2Bc617082eE760b);
address[] private pairs = [
0xB4e16d0168e52d35CaCD2c6185b44281Ec28C9Dc,
0x9928e4046d7c6513326cCeA028cD3e7a91c7590A,
0x0d4a11d5EEaaC28EC3F61d100daF4d40471f1852,
0xBb2b8038a1640196FbE3e38816F3e67Cba72D940,
0xA478c2975Ab1Ea89e8196811F51A7B7Ade33eB11,
0xd3d2E2692501A5c9Ca623199D38826e513033a17
];
string[] private armyMembers = [
"Swordsmen",
"Archers",
"Horses",
"Elephants",
"Dragons",
"Wizards"
];
uint[] private multipliers = [
10000,
1000,
100,
10,
1,
1
];
uint[] private battleWeights = [
2,
10,
30,
100,
2000,
5000
];
event BattleStage(uint indexed stage, uint tokenId, uint defenderId, uint attackerId, uint defenderScore, uint attackerScore);
mapping(uint => uint) lootingArmy;
uint public currentTokenId = 0;
uint public tokenStart = 0;
uint public lastBattleStart = 0;
uint public MIN_BATTLE_TIME = 30;
uint public MIN_TOKEN_CLAIM_TIME = 12*60*60;
uint public MAX_COEFFICIENT = 100;
string[] private gods = [
"Odin",
"Thor",
"Loki",
"Freya",
"Zeus"
];
string[] private people = [
"Warriors",
"Traders",
"Monks",
"Farmers",
"Magicians"
];
string[] private terrain = [
"Mountains",
"Desert",
"Cloud",
"Island",
"Coastal"
];
string[] private resources = [
"Gold",
"Silver",
"Platinum",
"Kryptonite",
"Wood"
];
string[] private food = [
"Wheat",
"Meat",
"Dragon's Egg",
"Fish",
"Fruit"
];
function random(string memory input) internal pure returns (uint256) {
return uint256(keccak256(abi.encodePacked(input)));
}
function armyRandom(string memory input) internal pure returns (uint256) {
return (uint256(keccak256(abi.encodePacked(input))) % 7) + 1;
}
function getStat(uint256 tokenId, uint stage) public view returns (uint stat) {
uint256 roll1 = armyRandom(string(abi.encodePacked(armyMembers[stage-1], toString(tokenId), "1")));
uint256 min = roll1;
uint256 roll2 = armyRandom(string(abi.encodePacked(armyMembers[stage-1], toString(tokenId), "2")));
min = min > roll2 ? roll2 : min;
uint256 roll3 = armyRandom(string(abi.encodePacked(armyMembers[stage-1], toString(tokenId), "3")));
min = min > roll3 ? roll3 : min;
uint256 roll4 = armyRandom(string(abi.encodePacked(armyMembers[stage-1], toString(tokenId), "4")));
min = min > roll4 ? roll4 : min;
// get 3 highest dice rolls
stat = (roll1 + roll2 + roll3 + roll4 - min)*multipliers[stage-1]*battleWeights[stage-1];
}
function getRandomCoefficient(uint stage) internal view returns (uint256 c1, uint256 c2){
if(stage == 6){
c1 = (IUniswapV2Pair(pairs[0]).price0CumulativeLast()/block.timestamp)*stage;
c2 = (IUniswapV2Pair(pairs[5]).price0CumulativeLast()/block.timestamp)*stage;
}else{
c1 = (IUniswapV2Pair(pairs[stage]).price0CumulativeLast()/block.timestamp)*stage;
c2 = (IUniswapV2Pair(pairs[5 - stage]).price0CumulativeLast()/block.timestamp)*stage;
}
c1 = c1%MAX_COEFFICIENT;
c2 = c2%MAX_COEFFICIENT;
}
function getGod(uint tokenId) public view returns (string memory) {
return pluck(tokenId, "GOD", gods);
}
function getPeople(uint tokenId) public view returns (string memory) {
return pluck(tokenId, "PEOPLE", people);
}
function getFood(uint tokenId) public view returns (string memory) {
return pluck(tokenId, "FOOD", food);
}
function getResources(uint tokenId) public view returns (string memory) {
return pluck(tokenId, "RESOURCES", resources);
}
function getTerrain(uint tokenId) public view returns (string memory) {
return pluck(tokenId, "TERRAIN", terrain);
}
function pluck(uint256 tokenId, string memory keyPrefix, string[] memory sourceArray) internal pure returns (string memory) {
uint256 rand = random(string(abi.encodePacked(keyPrefix, toString(tokenId))));
string memory output = sourceArray[rand % sourceArray.length];
return output;
}
function tokenURI(uint256 tokenId) override public view returns (string memory) {
string[11] memory parts;
parts[0] = '<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMinYMin meet" viewBox="0 0 350 350"><style>.base { fill: white; font-family: serif; font-size: 14px; }</style><rect width="100%" height="100%" fill="black" /><text x="10" y="20" class="base">';
parts[1] = getTerrain(tokenId);
parts[2] = '</text><text x="10" y="40" class="base">';
parts[3] = getPeople(tokenId);
parts[4] = '</text><text x="10" y="60" class="base">';
parts[5] = getFood(tokenId);
parts[6] = '</text><text x="10" y="80" class="base">';
parts[7] = getResources(tokenId);
parts[8] = '</text><text x="10" y="100" class="base">';
parts[9] = getGod(tokenId);
parts[10] = '</text></svg>';
string memory output = string(abi.encodePacked(parts[0], parts[1], parts[2], parts[3], parts[4], parts[5], parts[6], parts[7], parts[8]));
output = string(abi.encodePacked(output, parts[9], parts[10]));
string memory json = Base64.encode(bytes(string(abi.encodePacked('{"name": "Town #', toString(tokenId), '", "description": "Town is randomized adventurer gear generated and stored on chain. Stats, images, and other functionality are intentionally omitted for others to interpret. Feel free to use Town in any way you want.", "image": "data:image/svg+xml;base64,', Base64.encode(bytes(output)), '"}'))));
output = string(abi.encodePacked('data:application/json;base64,', json));
return output;
}
function claim(uint armyId) public nonReentrant {
require(army.ownerOf(armyId) == msg.sender, "!army owner"); // msg.sender has the army
if(currentTokenId == 0){
currentTokenId = 1;
tokenStart = block.timestamp;
lootingArmy[currentTokenId] = armyId;
lastBattleStart = block.timestamp;
_mint(msg.sender, currentTokenId);
return;
}
if(tokenStart + MIN_TOKEN_CLAIM_TIME < block.timestamp){
currentTokenId++;
require(currentTokenId <= 1000, "All towns minted");
tokenStart = block.timestamp;
lootingArmy[currentTokenId] = armyId;
lastBattleStart = block.timestamp;
_mint(msg.sender, currentTokenId);
return;
}
if(army.ownerOf(lootingArmy[currentTokenId]) != ownerOf(currentTokenId)){
lootingArmy[currentTokenId] = armyId;
lastBattleStart = block.timestamp;
_transfer(ownerOf(currentTokenId), msg.sender, currentTokenId);
return;
}
require(lastBattleStart + MIN_BATTLE_TIME <= block.timestamp, "!Battle Cooldown time");
require(ownerOf(currentTokenId) != msg.sender, "Can't fight yourself");
uint defenderScore = 0;
uint attackerScore = 0;
for(uint i=1; i<7; i++){
(defenderScore, attackerScore) = _battleForStage(i, lootingArmy[currentTokenId], armyId, defenderScore, attackerScore);
}
if(attackerScore > defenderScore){
lootingArmy[currentTokenId] = armyId;
lastBattleStart = block.timestamp;
_transfer(ownerOf(currentTokenId), msg.sender, currentTokenId);
}
}
function _battleForStage(uint stage, uint defenderId, uint attackerId, uint defenderScore, uint attackerScore) internal returns(uint, uint){
(uint c1, uint c2) = getRandomCoefficient(stage);
uint p1 = getStat(defenderId, stage);
uint p2 = getStat(attackerId, stage);
p1 = (p1*(100+c1)/100)+defenderScore;
p2 = (p2*(100+c2)/100)+attackerScore;
emit BattleStage(stage, currentTokenId, defenderId, attackerId, p1, p2);
return (p1, p2);
}
function setApprovalForAll(address operator, bool approved) public override {
require(tokenStart + MIN_TOKEN_CLAIM_TIME <= block.timestamp && ownerOf(currentTokenId) == msg.sender, "!allowed");
super.setApprovalForAll(operator, approved);
}
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
require(tokenStart + MIN_TOKEN_CLAIM_TIME <= block.timestamp && tokenId == currentTokenId, "!allowed");
super.transferFrom(from, to, tokenId);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId)
public override
{
require(tokenStart + MIN_TOKEN_CLAIM_TIME <= block.timestamp && tokenId == currentTokenId, "!allowed");
super.safeTransferFrom(from, to, tokenId);
}
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata _data)
public override
{
require(tokenStart + MIN_TOKEN_CLAIM_TIME <= block.timestamp && tokenId == currentTokenId, "!allowed");
super.safeTransferFrom(from, to, tokenId, _data);
}
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT license
// 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);
}
constructor() ERC721("Town", "TOWN") Ownable() {}
}
/// [MIT License]
/// @title Base64
/// @notice Provides a function for encoding some bytes in base64
/// @author Brecht Devos <[email protected]>
library Base64 {
bytes internal constant TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/// @notice Encodes some bytes to the base64 representation
function encode(bytes memory data) internal pure returns (string memory) {
uint256 len = data.length;
if (len == 0) return "";
// multiply by 4/3 rounded up
uint256 encodedLen = 4 * ((len + 2) / 3);
// Add some extra buffer at the end
bytes memory result = new bytes(encodedLen + 32);
bytes memory table = TABLE;
assembly {
let tablePtr := add(table, 1)
let resultPtr := add(result, 32)
for {
let i := 0
} lt(i, len) {
} {
i := add(i, 3)
let input := and(mload(add(data, i)), 0xffffff)
let out := mload(add(tablePtr, and(shr(18, input), 0x3F)))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF))
out := shl(8, out)
out := add(out, and(mload(add(tablePtr, and(input, 0x3F))), 0xFF))
out := shl(224, out)
mstore(resultPtr, out)
resultPtr := add(resultPtr, 4)
}
switch mod(len, 3)
case 1 {
mstore(sub(resultPtr, 2), shl(240, 0x3d3d))
}
case 2 {
mstore(sub(resultPtr, 1), shl(248, 0x3d))
}
mstore(result, encodedLen)
}
return string(result);
}
} | [{"defect": "DelegateCall", "type": "Function_call", "severity": "High", "lines": ["645"]}, {"defect": "Transaction_order_dependency", "type": "Business_logic", "severity": "Medium", "lines": ["1558"]}, {"defect": "Bad_randomness", "type": "Business_logic", "severity": "Medium", "lines": ["1418", "1419", "1421", "1512", "1503", "1495", "1529", "1493", "1505", "1422"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["191", "1625", "329", "213", "1589"]}, {"defect": "Balance_manipulation", "type": "Business_logic", "severity": "Medium", "lines": ["753"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["757", "1159", "1120", "308", "293", "319", "59", "1050"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["1413", "1418", "1419", "1421", "1422", "1540", "1541", "1500", "979", "1034", "1033", "1003", "1407", "1405", "1403", "1409"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["1500", "1517", "1567", "1548", "1557", "1578"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"Town.sol": [664, 661, 662, 663]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"Town.sol": [492, 493, 494]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"Town.sol": [1073, 1074, 1075]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"Town.sol": [1627, 1628, 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1637, 1638, 1639, 1640, 1641, 1642, 1643, 1644, 1645, 1646, 1647, 1648, 1649, 1650, 1651, 1652, 1653, 1654, 1655, 1656, 1657, 1658, 1659, 1660, 1661, 1662]}}, {"check": "weak-prng", "impact": "High", "confidence": "Medium", "lines": {"Town.sol": [1424]}}, {"check": "weak-prng", "impact": "High", "confidence": "Medium", "lines": {"Town.sol": [1425]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"Town.sol": [1349]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"Town.sol": [1351]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"Town.sol": [1352]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Town.sol": [225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Town.sol": [514, 515, 516, 517, 518, 519]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Town.sol": [568, 569, 570, 571, 572, 573, 574]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Town.sol": [640, 641, 642, 643, 644, 645, 646, 647, 638, 639]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Town.sol": [209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Town.sol": [995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Town.sol": [628, 629, 630]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Town.sol": [184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Town.sol": [582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Town.sol": [256, 257, 258]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Town.sol": [601, 602, 603]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Town.sol": [949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Town.sol": [649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Town.sol": [795, 796, 797]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Town.sol": [549, 550, 551, 552, 553, 554, 555]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Town.sol": [941, 942, 943]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Town.sol": [611, 612, 613, 614, 615, 616, 617, 618, 619, 620]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Town.sol": [539, 540, 541]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"Town.sol": [1422]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"Town.sol": [1421]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"Town.sol": [1419]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"Town.sol": [1418]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"Town.sol": [1620]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Town.sol": [776, 777, 778]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Town.sol": [315, 316, 317]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Town.sol": [1162, 1163, 1164, 1165]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Town.sol": [1177, 1178, 1179, 1180]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Town.sol": [802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Town.sol": [323, 324, 325, 326]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Town.sol": [769, 770, 771]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Town.sol": [1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502, 1503, 1504, 1505, 1506, 1507, 1508, 1509, 1510, 1511, 1512, 1513, 1514, 1515, 1516, 1517, 1518, 1519, 1520, 1521, 1522, 1523, 1524, 1525, 1526, 1527, 1528, 1529, 1530, 1531, 1532, 1533]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Town.sol": [1454, 1455, 1456, 1457, 1458, 1459, 1460, 1461, 1462, 1463, 1464, 1465, 1466, 1467, 1468, 1469, 1470, 1471, 1472, 1473, 1474, 1475, 1476, 1477, 1478, 1479, 1480, 1481, 1482, 1483, 1484, 1485]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Town.sol": [7]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Town.sol": [591]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Town.sol": [618]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Town.sol": [645]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Town.sol": [517]}}, {"check": "missing-inheritance", "impact": "Informational", "confidence": "High", "lines": {"Town.sol": [1296, 1294, 1295]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"Town.sol": [1421]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"Town.sol": [1419]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"Town.sol": [1422]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"Town.sol": [1418]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Town.sol": [872]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Town.sol": [1575]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Town.sol": [1351]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Town.sol": [1349]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Town.sol": [1352]}}, {"check": "variable-scope", "impact": "Low", "confidence": "High", "lines": {"Town.sol": [1074]}}, {"check": "variable-scope", "impact": "Low", "confidence": "High", "lines": {"Town.sol": [1070]}}, {"check": "variable-scope", "impact": "Low", "confidence": "High", "lines": {"Town.sol": [1068]}}, {"check": "incorrect-shift", "impact": "High", "confidence": "High", "lines": {"Town.sol": [1655]}}, {"check": "incorrect-shift", "impact": "High", "confidence": "High", "lines": {"Town.sol": [1658]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"Town.sol": [1557]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"Town.sol": [1548]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"Town.sol": [1517]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"Town.sol": [1578]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"Town.sol": [1567]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"Town.sol": [1067, 1068, 1069, 1070, 1071, 1072, 1073, 1074, 1075, 1076, 1077]}}, {"check": "write-after-write", "impact": "Medium", "confidence": "High", "lines": {"Town.sol": [1482]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1304, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1306, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1307, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1308, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1309, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1310, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1311, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 230, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 316, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 956, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 977, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 998, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1001, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1031, "severity": 1}, {"rule": "SOLIDITY_DIV_MUL", "line": 1418, "severity": 2}, {"rule": "SOLIDITY_DIV_MUL", "line": 1419, "severity": 2}, {"rule": "SOLIDITY_DIV_MUL", "line": 1421, "severity": 2}, {"rule": "SOLIDITY_DIV_MUL", "line": 1422, "severity": 2}, {"rule": "SOLIDITY_DIV_MUL", "line": 1620, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 7, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 179, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 282, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 367, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 368, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 370, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 714, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 717, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 720, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 723, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 726, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 729, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1141, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1144, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1147, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1150, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1305, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1314, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1323, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1332, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1354, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1362, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1370, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1378, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1386, "severity": 1}, {"rule": "SOLIDITY_REVERT_REQUIRE", "line": 1070, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 1615, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 486, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 1416, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 1535, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 256, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 1575, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 1073, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 1627, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 289, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 372, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 514, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 734, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1604, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 514, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 514, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 515, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 515, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 515, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 515, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 517, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 517, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 517, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1343, "severity": 1}] | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"stage","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"defenderId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"attackerId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"defenderScore","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"attackerScore","type":"uint256"}],"name":"BattleStage","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"MAX_COEFFICIENT","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_BATTLE_TIME","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_TOKEN_CLAIM_TIME","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"army","outputs":[{"internalType":"contract ERC721","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"armyId","type":"uint256"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"currentTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getFood","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getGod","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getPeople","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getResources","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"stage","type":"uint256"}],"name":"getStat","outputs":[{"internalType":"uint256","name":"stat","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getTerrain","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastBattleStart","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenStart","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}] | v0.8.7+commit.e28d00a7 | true | 1,000 | Default | MIT | false | ipfs://4c0149616d0780fbc3ab6847d05998fd6ca363500c48385e38e14301f7217ee6 |
|||
SKY | 0xb1ff85c4d647812c02d961b11f7868c1d1b49bdc | Solidity | // File: contracts/SKY.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title: SKY SCULPTURE
/// @author: manifold.xyz
import "./ERC721Creator.sol";
///////////////////////////////////////////////////////////////////////////////////////////
// //
// //
// //
// ******** ** ** ** ** //
// **////// /******** /** /** /** //
// /** ***** ** */*/**///********* ************* ***** *****/** //
// /***********///*/** /*/*/** /*///**/** /*//**//**///** **///*///**//****** //
// ////////*/** ///** /*/*/****** /**/** /**/** /******* /******* /** /**///** //
// /*/** */** /*/*/**/// /**/** /**/** /**//// */**//// /** /** /** //
// ********//*****//*******/** //*//*****/*** //*****/*//****** //**/** /** //
// //////// ///// ////////// // ///////// //////// ////// // // // //
// //
// //
// //
///////////////////////////////////////////////////////////////////////////////////////////
contract SKY is ERC721Creator {
constructor() ERC721Creator("SKY SCULPTURE", "SKY") {}
}
// File: contracts/ERC721Creator.sol
// 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;
}
}
// File: @openzeppelin/contracts/proxy/Proxy.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/Proxy.sol)
pragma solidity ^0.8.0;
/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/
abstract contract Proxy {
/**
* @dev Delegates the current call to `implementation`.
*
* This function does not return to its internall call site, it will return directly to the external caller.
*/
function _delegate(address implementation) internal virtual {
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @dev This is a virtual function that should be overriden so it returns the address to which the fallback function
* and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internall call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
* function in the contract matches the call data.
*/
fallback() external payable virtual {
_fallback();
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
* is empty.
*/
receive() external payable virtual {
_fallback();
}
/**
* @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
* call, or as part of the Solidity `fallback` or `receive` functions.
*
* If overriden should call `super._beforeFallback()`.
*/
function _beforeFallback() internal virtual {}
}
// File: @openzeppelin/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts/utils/StorageSlot.sol
// 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
}
}
}
| [{"defect": "DelegateCall", "type": "Function_call", "severity": "High", "lines": ["363"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [64, 62, 63]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [72, 73, 71]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [80, 81, 82]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [53, 54, 55]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [79, 80, 81, 82, 83]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [64, 65, 61, 62, 63]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [70, 71, 72, 73, 74]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [52, 53, 54, 55, 56]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [4]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 56, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 58, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 451, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 460, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 469, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 478, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 8, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 44, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 90, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 181, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 403, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 451, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 460, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 469, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 478, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 204, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 109, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 452, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 461, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 470, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 479, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 34, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 54, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 232, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 153, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 154, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 154, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 232, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 232, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 233, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 233, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 233, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 233, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 235, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 235, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 235, "severity": 1}] | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}] | v0.8.7+commit.e28d00a7 | true | 300 | Default | true | 0xe4e4003afe3765aca8149a82fc064c0b125b9e5a | ||||
MasterChef | 0x5fe1494797228532c0b2912096d6826ba860aa6a | Solidity | // File: /C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/ERC20/ERC20.sol
pragma solidity ^0.8.0;
import "./IERC20.sol";
import "./extensions/IERC20Metadata.sol";
import "../utils/Context.sol";
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
* overloaded;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account)
public
view
virtual
override
returns (uint256)
{
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount)
public
virtual
override
returns (bool)
{
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender)
public
view
virtual
override
returns (uint256)
{
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount)
public
virtual
override
returns (bool)
{
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(
currentAllowance >= amount,
"ERC20: transfer amount exceeds allowance"
);
_approve(sender, _msgSender(), currentAllowance - amount);
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue)
public
virtual
returns (bool)
{
_approve(
_msgSender(),
spender,
_allowances[_msgSender()][spender] + addedValue
);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue)
public
virtual
returns (bool)
{
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(
currentAllowance >= subtractedValue,
"ERC20: decreased allowance below zero"
);
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(
senderBalance >= amount,
"ERC20: transfer amount exceeds balance"
);
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
_balances[account] = accountBalance - amount;
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
// File: /C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount)
external
returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender)
external
view
returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
// File: /C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/ERC20/extensions/ERC20Burnable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../ERC20.sol";
import "../../utils/Context.sol";
/**
* @dev Extension of {ERC20} that allows token holders to destroy both their own
* tokens and those that they have an allowance for, in a way that can be
* recognized off-chain (via event analysis).
*/
abstract contract ERC20Burnable is Context, ERC20 {
/**
* @dev Destroys `amount` tokens from the caller.
*
* See {ERC20-_burn}.
*/
function burn(uint256 amount) public virtual {
_burn(_msgSender(), amount);
}
/**
* @dev Destroys `amount` tokens from `account`, deducting from the caller's
* allowance.
*
* See {ERC20-_burn} and {ERC20-allowance}.
*
* Requirements:
*
* - the caller must have allowance for ``accounts``'s tokens of at least
* `amount`.
*/
function burnFrom(address account, uint256 amount) public virtual {
uint256 currentAllowance = allowance(account, _msgSender());
require(currentAllowance >= amount, "ERC20:exceeds allowance");
_approve(account, _msgSender(), currentAllowance - amount);
_burn(account, amount);
}
}
// File: /C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/ERC20/extensions/ERC20Snapshot.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../ERC20.sol";
import "../../utils/Arrays.sol";
import "../../utils/Counters.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 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];
}
}
}
// File: /C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/ERC20/extensions/IERC20Metadata.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*/
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: /C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/ERC20/libs/SafeERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(
token,
abi.encodeWithSelector(token.transfer.selector, to, value)
);
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(
token,
abi.encodeWithSelector(token.transferFrom.selector, from, to, value)
);
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
// 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) + 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
// solhint-disable-next-line max-line-length
require(
abi.decode(returndata, (bool)),
"SafeERC20: ERC20 operation did not succeed"
);
}
}
}
// File: /C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/GrailToken.sol
pragma solidity ^0.8.0;
import "./ERC20/ERC20.sol";
import "./ERC20/extensions/ERC20Burnable.sol";
import "./ERC20/extensions/ERC20Snapshot.sol";
import "./access/AccessControlEnumerable.sol";
import "./utils/Context.sol";
import "./utils/math/SafeMath.sol";
/**
* @dev {ERC20} token, including:
*
* - ability for holders to burn (destroy) their tokens
* - a minter role that allows for token minting (creation)
*/
contract GrailToken is
Context,
AccessControlEnumerable,
ERC20Snapshot,
ERC20Burnable
{
using SafeMath for uint256;
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
bytes32 public constant SNAPSHOTTER_ROLE = keccak256("SNAPSHOTER_ROLE");
// A record of each accounts delegate
mapping(address => address) public delegates;
// A checkpoint for marking number of votes from a given block
struct Checkpoint {
uint256 fromBlock;
uint256 votes;
}
// A record of votes checkpoints for each account, by index
mapping(address => mapping(uint256 => Checkpoint)) public checkpoints;
mapping(address => uint256) public numCheckpoints;
// An event thats emitted when an account changes its delegate
event DelegateChanged(
address indexed delegator,
address indexed fromDelegate,
address indexed toDelegate
);
// An event thats emitted when a delegate account's vote balance changes
event DelegateVotesChanged(
address indexed delegate,
uint256 previousBalance,
uint256 newBalance
);
constructor() ERC20("GRAIL Governance Token", "GRAIL") {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_setupRole(MINTER_ROLE, _msgSender());
_setupRole(SNAPSHOTTER_ROLE, _msgSender());
}
/**
* @dev Creates `amount` new tokens for `to`.
*
* See {ERC20-_mint}.
*
* Requirements:
*
* - the caller must have the `MINTER_ROLE`.
*/
function mint(address to, uint256 amount) public virtual {
require(
hasRole(MINTER_ROLE, _msgSender()),
"Must have minter role to mint"
);
_mint(to, amount);
}
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual override(ERC20, ERC20Snapshot) {
super._beforeTokenTransfer(from, to, amount);
_moveDelegates(from, to, amount);
}
function snapshot() public returns (uint256) {
require(
hasRole(SNAPSHOTTER_ROLE, _msgSender()),
"Must have snapshoter role to mint"
);
return _snapshot();
}
// GOVERNANCE PART
/**
* notice Delegate votes from `msg.sender` to `delegatee`
* param delegatee The address to delegate votes to
*/
function delegate(address delegatee) public {
return _delegate(msg.sender, delegatee);
}
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account) external view returns (uint256) {
uint256 nCheckpoints = numCheckpoints[account];
return
nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
// This function is made to delegate the votes to some other address
function _delegate(address delegator, address delegatee) internal {
address currentDelegate = delegates[delegator];
if (currentDelegate == address(0)) {
currentDelegate = msg.sender;
}
// Checks how many votes does the delegator have currently available?
// The amount of the votes depends on the balance of the tokens you have.
uint256 delegatorBalance = balanceOf(delegator);
// Set the new address the delegate who will making the votes.
delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
// The balance balance of the one who is delegating are moved to the balance of the delegatee.
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _writeCheckpoint(
address delegatee,
uint256 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
) internal {
if (
nCheckpoints > 0 &&
checkpoints[delegatee][nCheckpoints - 1].fromBlock == block.number
) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
// WE ARE SETTING THE CHECKPOINT WHERE WE SPECIFY THE BLOCK number
// THE GOAL IS TO NOT LET PEOPLE VOTE WHEN THEIR BLOCK NUMBER IS AFTER WHEN THE VOTE BLIOCK STARTED.
checkpoints[delegatee][nCheckpoints] = Checkpoint(
block.number,
newVotes
);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function _moveDelegates(
address from,
address to,
uint256 amount
) public {
if (from != to && amount > 0) {
if (from != address(0)) {
uint256 fromNum = numCheckpoints[from];
uint256 fromOld =
fromNum > 0 ? checkpoints[from][fromNum - 1].votes : 0;
uint256 fromNew = fromOld.sub(amount);
_writeCheckpoint(from, fromNum, fromOld, fromNew);
}
if (to != address(0)) {
uint256 toNum = numCheckpoints[to];
uint256 toOld =
toNum > 0 ? checkpoints[to][toNum - 1].votes : 0;
uint256 toNew = toOld.add(amount);
_writeCheckpoint(to, toNum, toOld, toNew);
}
}
}
function getPriorVotes(address account, uint256 blockNumber)
public
view
returns (uint256)
{
require(
blockNumber < block.number,
"Grail::getPriorVotes: not yet determined"
);
uint256 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint256 lower = 0;
uint256 upper = nCheckpoints - 1;
while (upper > lower) {
uint256 center = upper - (upper - lower) / 2;
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;
}
}
// File: /C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/MasterChef.sol
pragma solidity ^0.8.0;
import "./ERC20/IERC20.sol";
import "./GrailToken.sol";
import "./access/AccessControlEnumerable.sol";
import "./utils/math/SafeMath.sol";
import "./ERC20/libs/SafeERC20.sol";
contract MasterChef is AccessControlEnumerable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
// The Protocol Token!
GrailToken public grail;
// Dev address.
address public devaddr;
// grail tokens created per block.
uint256 public grailPerBlock;
// Deposit Fee address
address public feeAddress;
// Tokens Burned
uint256 public tokensBurned;
bytes32 public constant MANAGER_ROLE = keccak256("MANAGER_ROLE");
constructor(
GrailToken _grail,
address _devaddr,
address _feeAddress,
uint256 _grailPerBlock,
uint256 _startBlock
) public {
grail = _grail;
devaddr = _devaddr;
feeAddress = _feeAddress;
grailPerBlock = _grailPerBlock;
startBlock = _startBlock;
_setupRole(MANAGER_ROLE, _msgSender());
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
}
struct UserInfo {
uint256 amount; // How many LP tokens the user has user provided.
uint256 rewardDebt; // Reward debt. See explanation below.
// pending reward = (user.amount * pool.accgrailPerShare) - user.rewardDebt
// Whenever a user deposits or withdraws LP tokens to a pool. Here's what happens:
// 1. The pool's `accgrailPerShare` (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.
}
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
);
// Info of each pool.
struct PoolInfo {
IERC20 lpToken; // Address of LP token contract.
uint256 allocPoint; // Portion of reward allocation to this pool.
uint256 lastRewardBlock; // Block number when last distribution happened on a pool.
uint256 accGRAILPerShare; // Accumulated GRAIL's per share, times 1e12. See below.
uint16 depositFeeBP; // Deposit fee in basis points
}
// Info of each pool.
PoolInfo[] public poolInfo;
// Info of each user that stakes tokens.
mapping(uint256 => mapping(address => UserInfo)) public userInfo;
// Total allocation points. Must be the sum of all allocation points in all pools.
uint256 public totalAllocPoint = 0;
// The block number when GRAIL mining starts.
uint256 public startBlock;
// Calculate how many pools exist.
function poolLength() external view returns (uint256) {
return poolInfo.length;
}
mapping(ERC20 => bool) public poolExistence;
// Prevents creation of a pool with the same token.
modifier nonDuplicated(ERC20 _lpToken) {
require(poolExistence[_lpToken] == false, "nonDuplicated: duplicated");
_;
}
// Create a new pool. Can only be called by the owner.
// You define the token address.
// You set the weightto the pool - allocPoint. It determine how much rewards will go to stakers of this pool relative to other pools.
// You also define the deposit fee. This fee is moved to fee collecter address.
function add(
uint256 _allocPoint,
ERC20 _lpToken,
uint16 _depositFeeBP,
bool _withUpdate
) public nonDuplicated(_lpToken) {
require(
hasRole(MANAGER_ROLE, _msgSender()),
"Must have minter role to mint"
);
// The deposit fee has to be below 100%
require(
_depositFeeBP <= 10000,
"add: invalid deposit fee basis points"
);
if (_withUpdate) {
massUpdatePools();
}
// In case Farm already running set the lastRewardBlock to curenct block number.
// In case farm is launched in the future, set it to the farm startBlock number.
uint256 lastRewardBlock = block.number > startBlock
? block.number
: startBlock;
// Adjust totalAllocPoint to weight of all pools, accounting for new pool added.
totalAllocPoint = totalAllocPoint.add(_allocPoint);
// You set the pool as it already exists so you wouln't be able to create the same exact pool twice.
poolExistence[_lpToken] = true;
// Store the information of the new pool.
poolInfo.push(
PoolInfo({
lpToken: _lpToken,
allocPoint: _allocPoint,
lastRewardBlock: lastRewardBlock,
accGRAILPerShare: 0,
depositFeeBP: _depositFeeBP
})
);
}
// Update reward variables for all pools.
function massUpdatePools() public {
uint256 length = poolInfo.length;
for (uint256 pid = 0; pid < length; ++pid) {
updatePool(pid);
}
}
// View pending GRAILs rewards.
function pendingGRAIL(uint256 _pid, address _user)
external
view
returns (uint256)
{
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accGRAILPerShare = pool.accGRAILPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 blockDifference = block.number.sub(pool.lastRewardBlock);
uint256 grailReward = blockDifference
.mul(grailPerBlock)
.mul(pool.allocPoint)
.div(totalAllocPoint);
accGRAILPerShare = accGRAILPerShare.add(
grailReward.mul(1e12).div(lpSupply)
);
}
return user.amount.mul(accGRAILPerShare).div(1e12).sub(user.rewardDebt);
}
// Update reward variables of the given pool to be up-to-date.
function updatePool(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
// if the pool reward block number is in the future the farm has not started yet.
if (block.number <= pool.lastRewardBlock) {
return;
}
// Total of pool token that been supplied.
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
// If pool has no LP tokens or pool weight is set to 0 don't distribute rewards.
// Just update the update to last block.
if (lpSupply == 0 || pool.allocPoint == 0) {
pool.lastRewardBlock = block.number;
return;
}
// If none of the above is true mint tokens and distribute rewards.
// First we get the number of blocks that we have advanced forward since the last time we updated the farm.
uint256 blockDifference = block.number.sub(pool.lastRewardBlock);
// After we got to the block timeframe defference, we calculate how much we mint.
// For each farm we consider the weight it has compared to the other farms.
uint256 grailReward = blockDifference
.mul(grailPerBlock)
.mul(pool.allocPoint)
.div(totalAllocPoint);
// A % of reward is going to the developers address so that would be a portion of total reward.
grail.mint(devaddr, grailReward.div(10));
// We are minting to the protocol address the address the reward tokens.
grail.mint(address(this), grailReward);
// Calculates how many tokens does each supplied of token get.
pool.accGRAILPerShare = pool.accGRAILPerShare.add(
grailReward.mul(1e12).div(lpSupply)
);
// We update the farm to the current block number.
pool.lastRewardBlock = block.number;
}
// Deposit pool tokens for GRAIL allocation.
function deposit(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
// Update pool when user interacts with the contract.
updatePool(_pid);
// If the user has previously deposited money to the farm.
if (user.amount > 0) {
// Calculate how much does the farm owe the user.
uint256 pending = user
.amount
.mul(pool.accGRAILPerShare)
.div(1e12)
.sub(user.rewardDebt);
// When user executes deposit, pending rewards get sent to the user.
if (pending > 0) {
safeGRAILTransfer(msg.sender, pending);
}
}
if (_amount > 0) {
pool.lpToken.safeTransferFrom(
address(msg.sender),
address(this),
_amount
);
// If the pool has a deposit fee
if (pool.depositFeeBP > 0) {
// Calculate what does it represent in token terms.
uint256 depositFee = _amount.mul(pool.depositFeeBP).div(10000);
// Send the deposit fee to the feeAddress
pool.lpToken.safeTransfer(feeAddress, depositFee);
// Add the user token to the farm and substract the deposit fee.
user.amount = user.amount.add(_amount).sub(depositFee);
// If there is no deposit fee just add the money to the total amount that a user has deposited.
} else {
user.amount = user.amount.add(_amount);
}
}
// Generate Debt for the previous rewards that the user is not entitled to. Because he just entered.
user.rewardDebt = user.amount.mul(pool.accGRAILPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
// Withdraw pool tokens,
function withdraw(uint256 _pid, uint256 _amount) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
// Check's what is the pending amount considering current block.
// Assuming that we distribute 5 Tokens for every 1 token.
// if user deposited 0.5 tokens, he recives 2.5 tokens.
uint256 pending = user.amount.mul(pool.accGRAILPerShare).div(1e12).sub(
user.rewardDebt
);
// If the user has a reward pending, send the user his rewards.
if (pending > 0) {
safeGRAILTransfer(msg.sender, pending);
}
// If the user is withdrawing from the farm more than 0 tokens
if (_amount > 0) {
// reduce from the user DB the ammount he is trying to withdraw.
user.amount = user.amount.sub(_amount);
// Send the user the amount of LP tokens he is withdrawing.
pool.lpToken.safeTransfer(address(msg.sender), _amount);
}
user.rewardDebt = user.amount.mul(pool.accGRAILPerShare).div(1e12);
emit Withdraw(msg.sender, _pid, _amount);
}
// Withdraw without caring about rewards. EMERGENCY ONLY.
function emergencyWithdraw(uint256 _pid) public {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
uint256 amount = user.amount;
user.amount = 0;
user.rewardDebt = 0;
pool.lpToken.safeTransfer(address(msg.sender), amount);
emit EmergencyWithdraw(msg.sender, _pid, amount);
}
// In case if rounding error causes pool to not have enough GRAIL TOKENS
function safeGRAILTransfer(address _to, uint256 _amount) internal {
// Check how many GRAIL token's on the protocol address.
uint256 GRAILBal = grail.balanceOf(address(this));
// In case if the amount requested is higher than the money on the protocol balance.
if (_amount > GRAILBal) {
// Transfer absolutely everything from the balance to the contract.
grail.transfer(_to, GRAILBal);
} else {
// If there is enough tokens on the protocol, make the usual transfer.
grail.transfer(_to, _amount);
}
}
// Update developer fee address.
function dev(address _devaddr) public {
// Can be done only by developer
require(msg.sender == devaddr, "dev: wut?");
devaddr = _devaddr;
}
// Address that collects fees on the protocol.
// Fees will be used to buy back GRAIL tokens.
function setFeeAddress(address _feeAddress) public {
require(msg.sender == feeAddress, "setFeeAddress: FORBIDDEN");
feeAddress = _feeAddress;
}
// Function that sets the new amount of how many new GRAIL Tokens will be minted per each block.
// TEMP DISABLE ONLY OWNER.
function updateEmissionRate(uint256 _GRAILPerBlock) public {
require(hasRole(MANAGER_ROLE, _msgSender()));
massUpdatePools();
grailPerBlock = _GRAILPerBlock;
}
function burnTokens(uint256 _amount) public {
require(hasRole(MANAGER_ROLE, _msgSender()));
grail.transferFrom(address(msg.sender), address(this), _amount);
grail.burn(_amount);
tokensBurned = tokensBurned + _amount;
}
}
// File: /C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/access/AccessControl.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
import "../utils/introspection/ERC165.sol";
import "../utils/Strings.sol";
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
function hasRole(bytes32 role, address account)
external
view
returns (bool);
function getRoleAdmin(bytes32 role) external view returns (bytes32);
function grantRole(bytes32 role, address account) external;
function revokeRole(bytes32 role, address account) external;
function renounceRole(bytes32 role, address account) external;
}
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev 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 Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/
*
* _Available since v4.1._
*/
modifier onlyRole(bytes32 role) {
_checkRole(role, _msgSender());
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override
returns (bool)
{
return
interfaceId == type(IAccessControl).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account)
public
view
override
returns (bool)
{
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{20}) is missing role (0x[0-9a-f]{32})$/
*/
function _checkRole(bytes32 role, address account) internal view {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view override returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account)
public
virtual
override
onlyRole(getRoleAdmin(role))
{
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account)
public
virtual
override
onlyRole(getRoleAdmin(role))
{
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account)
public
virtual
override
{
require(
account == _msgSender(),
"AccessControl: can only renounce roles for self"
);
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
emit RoleAdminChanged(role, getRoleAdmin(role), adminRole);
_roles[role].adminRole = adminRole;
}
function _grantRole(bytes32 role, address account) private {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}
// File: /C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/access/AccessControlEnumerable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./AccessControl.sol";
import "../utils/structs/EnumerableSet.sol";
/**
* @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
*/
interface IAccessControlEnumerable {
function getRoleMember(bytes32 role, uint256 index)
external
view
returns (address);
function getRoleMemberCount(bytes32 role) external view returns (uint256);
}
/**
* @dev Extension of {AccessControl} that allows enumerating the members of each role.
*/
abstract contract AccessControlEnumerable is
IAccessControlEnumerable,
AccessControl
{
using EnumerableSet for EnumerableSet.AddressSet;
mapping(bytes32 => EnumerableSet.AddressSet) private _roleMembers;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override
returns (bool)
{
return
interfaceId == type(IAccessControlEnumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index)
public
view
override
returns (address)
{
return _roleMembers[role].at(index);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role)
public
view
override
returns (uint256)
{
return _roleMembers[role].length();
}
/**
* @dev Overload {grantRole} to track enumerable memberships
*/
function grantRole(bytes32 role, address account) public virtual override {
super.grantRole(role, account);
_roleMembers[role].add(account);
}
/**
* @dev Overload {revokeRole} to track enumerable memberships
*/
function revokeRole(bytes32 role, address account) public virtual override {
super.revokeRole(role, account);
_roleMembers[role].remove(account);
}
/**
* @dev Overload {renounceRole} to track enumerable memberships
*/
function renounceRole(bytes32 role, address account)
public
virtual
override
{
super.renounceRole(role, account);
_roleMembers[role].remove(account);
}
/**
* @dev Overload {_setupRole} to track enumerable memberships
*/
function _setupRole(bytes32 role, address account)
internal
virtual
override
{
super._setupRole(role, account);
_roleMembers[role].add(account);
}
}
// File: /C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// 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: /C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/Arrays.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.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;
}
}
}
// File: /C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/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;
}
}
// File: /C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/Counters.sol
// 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;
}
}
}
// File: /C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/Strings.sol
// 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);
}
}
// File: /C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/introspection/ERC165.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId)
public
view
virtual
override
returns (bool)
{
return interfaceId == type(IERC165).interfaceId;
}
}
// File: /C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/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: /C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/math/Math.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Standard math utilities missing in the Solidity language.
*/
library Math {
/**
* @dev Returns the largest of two numbers.
*/
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
/**
* @dev Returns the smallest of two numbers.
*/
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
/**
* @dev Returns the average of two numbers. The result is rounded towards
* zero.
*/
function average(uint256 a, uint256 b) internal pure returns (uint256) {
// (a + b) / 2 can overflow, so we distribute
return (a / 2) + (b / 2) + (((a % 2) + (b % 2)) / 2);
}
}
// File: /C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/math/SafeMath.sol
// 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;
}
}
}
// File: /C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*/
library 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] = valueIndex; // Replace lastvalue's index to valueIndex
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value)
private
view
returns (bool)
{
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index)
private
view
returns (bytes32)
{
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));
}
}
| [{"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["1220"]}, {"defect": "DelegateCall", "type": "Function_call", "severity": "High", "lines": ["2068"]}, {"defect": "Transaction_order_dependency", "type": "Business_logic", "severity": "Medium", "lines": ["1409"]}, {"defect": "Uninitialized_storage", "type": "Code_specification", "severity": "Low", "lines": ["1291", "1363", "1232", "1335", "1290", "1362", "1250", "1231", "1334"]}, {"defect": "Bad_randomness", "type": "Business_logic", "severity": "Medium", "lines": ["1261", "1267", "1198", "1285", "1236", "1008"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["2269", "2247", "1063", "1198", "2129"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["1411", "292", "268", "1000", "1055", "1012", "291", "269", "249", "248", "1026", "1033", "1063"]}] | [{"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [109, 110, 111, 112, 113, 114, 115]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [192, 193, 194]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [206, 207, 208, 209, 210, 211, 212]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [120, 121, 122]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [304, 305, 306, 307, 308, 309]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [181, 182, 183, 184, 185, 186, 187]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [320, 314, 315, 316, 317, 318, 319]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [239, 240, 241, 242, 243, 244]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [274, 275, 276, 277, 278, 279, 280]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [249, 250, 251, 252, 253, 254, 255]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [260, 261, 262]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [160, 161, 162, 163, 158, 159]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [325, 326, 327]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [339, 340, 341, 342, 343, 344, 345]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [226, 227, 228, 229, 230, 231]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [296, 294, 295]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [171, 172, 173, 174, 175, 176]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"C/Users/USER/Desktop/GRAIL Token and Farming/GRAIL/contracts/utils/structs/EnumerableSet.sol": [3]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1491, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 2290, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 266, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 287, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 125, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 1220, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 1064, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 2131, "severity": 1}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 1394, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 5, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 348, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 443, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 488, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 698, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 728, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 864, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1083, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1421, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1721, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1845, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2102, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2158, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2187, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2229, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2304, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2343, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2372, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2408, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2631, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 12, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 14, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 16, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 18, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 19, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 532, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 533, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 536, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1489, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1747, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2235, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 885, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 1091, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 1868, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 629, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 2426, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 2439, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 2451, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 2468, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 2480, "severity": 1}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 750, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 762, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 788, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 800, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 822, "severity": 3}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 2175, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 30, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 915, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1897, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1897, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1897, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1898, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1898, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1899, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1899, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1904, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1904, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1904, "severity": 1}] | [{"inputs":[{"internalType":"contract GrailToken","name":"_grail","type":"address"},{"internalType":"address","name":"_devaddr","type":"address"},{"internalType":"address","name":"_feeAddress","type":"address"},{"internalType":"uint256","name":"_grailPerBlock","type":"uint256"},{"internalType":"uint256","name":"_startBlock","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"EmergencyWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"pid","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdraw","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_allocPoint","type":"uint256"},{"internalType":"contract ERC20","name":"_lpToken","type":"address"},{"internalType":"uint16","name":"_depositFeeBP","type":"uint16"},{"internalType":"bool","name":"_withUpdate","type":"bool"}],"name":"add","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"burnTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_devaddr","type":"address"}],"name":"dev","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"devaddr","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"emergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feeAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"grail","outputs":[{"internalType":"contract GrailToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"grailPerBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"massUpdatePools","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"address","name":"_user","type":"address"}],"name":"pendingGRAIL","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract ERC20","name":"","type":"address"}],"name":"poolExistence","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"poolInfo","outputs":[{"internalType":"contract IERC20","name":"lpToken","type":"address"},{"internalType":"uint256","name":"allocPoint","type":"uint256"},{"internalType":"uint256","name":"lastRewardBlock","type":"uint256"},{"internalType":"uint256","name":"accGRAILPerShare","type":"uint256"},{"internalType":"uint16","name":"depositFeeBP","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolLength","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeAddress","type":"address"}],"name":"setFeeAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"startBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokensBurned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalAllocPoint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_GRAILPerBlock","type":"uint256"}],"name":"updateEmissionRate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"}],"name":"updatePool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"address","name":"","type":"address"}],"name":"userInfo","outputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"rewardDebt","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_pid","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}] | v0.8.0+commit.c7dfd78e | false | 200 | 00000000000000000000000054cc8f6f1540714788c6ec3593597ebd4dd9fff20000000000000000000000009cc25f58259fb1568ad7a59131c918c53d533ec50000000000000000000000009cc25f58259fb1568ad7a59131c918c53d533ec500000000000000000000000000000000000000000000000000470de4df8200000000000000000000000000000000000000000000000000000000000000000000 | Default | false | ||||
FMA | 0xa4987d81274b2abcb519fa6db4b9b22768e208ba | Solidity | // File: contracts/FMA.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title: Failed Mathematicians
/// @author: manifold.xyz
import "./ERC721Creator.sol";
////////////////////////////////////////////////////////////////////////////////////////////////
// //
// //
// //
// ▓▓ //
// ╔▓▓▓Æ▄,,╟▓▓ÆÆ#@@▓▓▓▓▄ //
// ▐▓ ╘▓▀▀▀╝▓▓▓▓▓▓▓▓╝▀ //
// ▓Γ ▐▌ ╙▓▓µ ╓╖╗▄▄▄▄▄▄▄▄ //
// ▓▌ ╟▌ ╙▓▓ ,▄╗@▓▓▓╝╝▀▀▀▀▀▀╙╙` //
// ╫▓,▓ ╫▓▌ ╣╣▄µ╓╓,,,,,, //
// ╙▓▓" ╙▓▓▄ └``└╙╙`╠▓▓▓ //
// ╚▓▓ ,▄▓╝╙` //
// └▓▓▄ ,@▓▀ //
// ╚▓▓ @▓¬ //
// ╙▓▓µ ]╗ ║▓ //
// ,,╓╓╓╦ ▓▓▄ ▓▓▀╦╓ ╣▓▓▓▓▓▓▓▓▓╗▄╓ //
// ,#▓▓▓▓╝▀▀▀▓▓▓╗╖ ╣▓▌ ╙▓▌ ``"""""▓▓▓▓▌╙╙╙▀▓▓▓, ╙▀▓▌µ //
// ,@▓▓╝╙ ╙▀▓▓▄▓▓▄ ╟▓▌ ▓▓▓▀╚▓╕ ╙╣▓▓ ╙▓▌, //
// é▓▓▓ `▀▓▓▓ , ╣▓▄ ▐▓▓▌ ╙▓▓, ╙▓▓ ╙╣▓ //
// ▓▓▓▓▓ ▓▓▒ ]▓▓⌐ ╣▓▌ ║▓▓⌐ ╙╣▓╗╖,,▄▓▌ ╙▓╕ //
// ▓▓▌╫▓▌ ▓▓▓ ]▓▓▓ ╣▓▓ ╘▓▓▒ `╙▀▀╙└ ╫▓ //
// ╙▓▓▄╚▓▓╖ ,▓▓▀ ▓▓▓▓▄ ▓▓▓ ╚▓▓▄ ╓▓▌ //
// ▀▓▓▓▓▓▓▓▄╖ ,▄▓▓▓╜ ▓▓▌╣▓▓▌, ║▓▓ ▀▓▓▓▄, ,▄▓█¬ //
// ╙╙╝▓▓▓▓▓▓▓▓▓▓▓▓▓▓╝╙ ╙▓ ╙╣▓▓▓▓▀ ╙▀╝▓▓▓▓▓▓▓▓▓▓▓╝▀╙ //
// //
// //
// //
// //
////////////////////////////////////////////////////////////////////////////////////////////////
contract FMA is ERC721Creator {
constructor() ERC721Creator("Failed Mathematicians", "FMA") {}
}
// File: contracts/ERC721Creator.sol
// 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;
}
}
// File: @openzeppelin/contracts/proxy/Proxy.sol
// 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 {}
}
// File: @openzeppelin/contracts/utils/Address.sol
// 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);
}
}
}
}
// File: @openzeppelin/contracts/utils/StorageSlot.sol
// 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
}
}
}
| [{"defect": "DelegateCall", "type": "Function_call", "severity": "High", "lines": ["381"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [64, 62, 63]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [72, 73, 71]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [80, 81, 82]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [53, 54, 55]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [79, 80, 81, 82, 83]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [64, 65, 61, 62, 63]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [70, 71, 72, 73, 74]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [52, 53, 54, 55, 56]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [4]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 69, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 71, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 469, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 478, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 487, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 496, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 8, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 57, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 103, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 194, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 421, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 469, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 478, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 487, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 496, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 122, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 470, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 479, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 488, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 497, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 47, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 67, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 250, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 166, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 167, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 167, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 250, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 250, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 251, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 251, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 251, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 251, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 253, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 253, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 253, "severity": 1}] | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}] | v0.8.7+commit.e28d00a7 | true | 300 | Default | true | 0xe4e4003afe3765aca8149a82fc064c0b125b9e5a | ||||
MSECStandardToken | 0xf924ea38c31fece95bf5fe1ad8e49a0c242ef169 | Solidity | pragma solidity ^0.4.8;
contract Token{
// token总量,默认会为public变量生成一个getter函数接口,名称为totalSupply().
uint256 public totalSupply;
/// 获取账户_owner拥有token的数量
function balanceOf(address _owner) constant returns (uint256 balance);
//从消息发送者账户中往_to账户转数量为_value的token
function transfer(address _to, uint256 _value) returns (bool success);
//从账户_from中往账户_to转数量为_value的token,与approve方法配合使用
function transferFrom(address _from, address _to, uint256 _value) returns
(bool success);
//消息发送账户设置账户_spender能从发送账户中转出数量为_value的token
function approve(address _spender, uint256 _value) returns (bool success);
//获取账户_spender可以从账户_owner中转出token的数量
function allowance(address _owner, address _spender) constant returns
(uint256 remaining);
//发生转账时必须要触发的事件
event Transfer(address indexed _from, address indexed _to, uint256 _value);
//当函数approve(address _spender, uint256 _value)成功执行时必须触发的事件
event Approval(address indexed _owner, address indexed _spender, uint256
_value);
}
contract StandardToken is Token {
function transfer(address _to, uint256 _value) returns (bool success) {
//默认totalSupply 不会超过最大值 (2^256 - 1).
//如果随着时间的推移将会有新的token生成,则可以用下面这句避免溢出的异常
//require(balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]);
require(balances[msg.sender] >= _value);
balances[msg.sender] -= _value;//从消息发送者账户中减去token数量_value
balances[_to] += _value;//往接收账户增加token数量_value
Transfer(msg.sender, _to, _value);//触发转币交易事件
return true;
}
function transferFrom(address _from, address _to, uint256 _value) returns
(bool success) {
//require(balances[_from] >= _value && allowed[_from][msg.sender] >=
// _value && balances[_to] + _value > balances[_to]);
require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value);
balances[_to] += _value;//接收账户增加token数量_value
balances[_from] -= _value; //支出账户_from减去token数量_value
allowed[_from][msg.sender] -= _value;//消息发送者可以从账户_from中转出的数量减少_value
Transfer(_from, _to, _value);//触发转币交易事件
return true;
}
function balanceOf(address _owner) constant returns (uint256 balance) {
return balances[_owner];
}
function approve(address _spender, uint256 _value) returns (bool success)
{
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
return allowed[_owner][_spender];//允许_spender从_owner中转出的token数
}
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
}
contract MSECStandardToken is StandardToken {
/* Public variables of the token */
string public name; //名称: eg Simon Bucks
uint8 public decimals; //最多的小数位数,How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //token简称: eg SBX
string public version = 'H0.1'; //版本
function MSECStandardToken(uint256 _initialAmount, string _tokenName, uint8 _decimalUnits, string _tokenSymbol) {
balances[msg.sender] = _initialAmount; // 初始token数量给予消息发送者
totalSupply = _initialAmount; // 设置初始总量
name = _tokenName; // token名称
decimals = _decimalUnits; // 小数位数
symbol = _tokenSymbol; // token简称
}
/* Approves and then calls the receiving contract */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
require(_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData));
return true;
}
} | [{"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["81", "4"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["32", "44"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["38", "37", "51", "50", "49"]}] | [{"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"MSECStandardToken.sol": [81]}}, {"check": "deprecated-standards", "impact": "Informational", "confidence": "High", "lines": {"MSECStandardToken.sol": [99]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MSECStandardToken.sol": [17]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MSECStandardToken.sol": [20, 21]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MSECStandardToken.sol": [13, 14]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MSECStandardToken.sol": [96, 97, 98, 99, 100, 101, 93, 94, 95]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MSECStandardToken.sol": [10]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MSECStandardToken.sol": [7]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"MSECStandardToken.sol": [1]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"MSECStandardToken.sol": [99]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MSECStandardToken.sol": [68]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MSECStandardToken.sol": [60]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MSECStandardToken.sol": [68]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MSECStandardToken.sol": [32]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MSECStandardToken.sol": [32]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MSECStandardToken.sol": [44]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MSECStandardToken.sol": [44]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MSECStandardToken.sol": [60]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MSECStandardToken.sol": [93]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MSECStandardToken.sol": [44]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MSECStandardToken.sol": [93]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MSECStandardToken.sol": [55]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MSECStandardToken.sol": [93]}}] | [{"error": "Integer Underflow.", "line": 81, "level": "Warning"}, {"error": "Integer Underflow.", "line": 78, "level": "Warning"}, {"error": "Integer Underflow.", "line": 80, "level": "Warning"}, {"error": "Integer Overflow.", "line": 49, "level": "Warning"}, {"error": "Integer Overflow.", "line": 93, "level": "Warning"}, {"error": "Integer Overflow.", "line": 38, "level": "Warning"}] | [{"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 99, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 7, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 20, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 55, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 68, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 60, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 99, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 7, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 10, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 13, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 17, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 20, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 32, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 44, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 55, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 60, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 68, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 83, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 93, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 71, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 72, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"version","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_initialAmount","type":"uint256"},{"name":"_tokenName","type":"string"},{"name":"_decimalUnits","type":"uint8"},{"name":"_tokenSymbol","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"}] | v0.4.17+commit.bdeb9e52 | true | 200 | 000000000000000000000000000000000000000000000000000b3625a1cbe0000000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000d4d696e696e67205365636f6e640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044d53454300000000000000000000000000000000000000000000000000000000 | Default | false | bzzr://d764c60a07eda2ff626aee33461a3b92a6dacfe4e34f9bf690f4281d1bf80125 |
|||
Migrations | 0xfbfc9c4c8d34b7d71c476ecbc9e345886ad285ef | Solidity |
// File: contracts/Migrations.sol
pragma solidity ^0.5.4;
/* solium-disable */
contract Migrations {
address public owner;
uint public last_completed_migration;
modifier restricted() {
if (msg.sender == owner) _;
}
constructor() public {
owner = msg.sender;
}
function setCompleted(uint completed) public restricted {
last_completed_migration = completed;
}
function upgrade(address new_address) public restricted {
Migrations upgraded = Migrations(new_address);
upgraded.setCompleted(last_completed_migration);
}
}
| [{"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["25"]}] | [{"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Migrations.sol": [20, 21, 22]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Migrations.sol": [24, 25, 26, 27]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Migrations.sol": [4]}}, {"check": "incorrect-modifier", "impact": "Low", "confidence": "High", "lines": {"Migrations.sol": [12, 13, 14]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Migrations.sol": [10]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Migrations.sol": [24]}}] | [] | [{"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 4, "severity": 1}] | [{"constant":false,"inputs":[{"name":"new_address","type":"address"}],"name":"upgrade","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"last_completed_migration","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"completed","type":"uint256"}],"name":"setCompleted","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"}] | v0.5.4+commit.9549d8ff | true | 200 | Default | false | bzzr://8c30e043ae959a0c392852a153b02aa80593d8890e6a8cefe8524a715be6ece4 |
||||
TokenExpress | 0x3c6679b7d8f3f39cd34184b1df11fb7a39031737 | Solidity | // File: zeppelin-solidity/contracts/ownership/Ownable.sol
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 OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to relinquish control of the contract.
* @notice Renouncing to ownership will leave the contract without an owner.
* It will not be possible to call the functions with the `onlyOwner`
* modifier anymore.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
/**
* @dev Transfers control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
}
// File: zeppelin-solidity/contracts/math/SafeMath.sol
pragma solidity ^0.4.24;
/**
* @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;
}
}
// File: contracts/TokenExpress.sol
pragma solidity ^0.4.25;
contract TokenExpress is Ownable {
event Deposit(bytes32 indexed escrowId, address indexed sender, uint256 amount);
event Send(bytes32 indexed escrowId, address indexed recipient, uint256 amount);
event Recovery(bytes32 indexed escrowId, address indexed sender, uint256 amount);
using SafeMath for uint256;
// ユーザに負担してもらう手数料(wei)
uint256 fee = 1000000;
// ユーザが回収できるようになるまでの時間(時間)
uint256 lockTime = 14 * 24;
// オーナー以外に管理権限があるユーザ
address administrator = 0x0;
// 送金情報を保存する構造体
struct TransferInfo {
address from;
address to;
uint256 amount;
uint256 date;
bool sent;
}
// デポジット情報
mapping (bytes32 => TransferInfo) private _transferInfo;
/**
* コンストラクタ
*/
constructor () public {
owner = msg.sender;
}
/**
* デポジットを行う
* 引数1:システムで発行されたID
* 引数2:送金額(wei で指定)
* 引数3:送金先アドレス
* ※ 送金額+手数料分のETHを送ってもらう必要がある
*
* df121a97
*/
function etherDeposit(bytes32 id, uint256 amount) payable public {
// 既にIDが登録されていたら変更は不可
require(_transferInfo[id].from == 0x0, "ID is already exists.");
// 実際に送られた ether が送金額+手数料よりも低ければエラー
require(amount + fee <= msg.value, "Value is too low.");
// 送金情報を登録する
_transferInfo[id].from = msg.sender;
_transferInfo[id].to = 0x0;
_transferInfo[id].amount = amount;
_transferInfo[id].date = block.timestamp;
emit Deposit(id, msg.sender, amount);
}
/**
* 送金を行う
* 引数1:システムで発行されたID
*
* 3af19adb
*/
function etherSend(bytes32 id, address to) public {
// IDが登録されていなければエラー
require(_transferInfo[id].from != 0x0, "ID error.");
// 既に送金・回収されていればエラー
require(_transferInfo[id].sent == false, "Already sent.");
// 送金先が不正なアドレスならエラー
require(to != 0x0, "Address error.");
// 送金指示をしたアドレスが、オーナーか管理者かデポジット者以外だったらエラー
require(msg.sender == owner || msg.sender == administrator || msg.sender == _transferInfo[id].from, "Invalid address.");
to.transfer(_transferInfo[id].amount);
_transferInfo[id].to = to;
_transferInfo[id].sent = true;
emit Send(id, to, _transferInfo[id].amount);
}
/**
* 回収を行う
* 引数1:システムで発行されたID
*
* 6b87124e
*/
function etherRecovery(bytes32 id) public {
// IDが登録されていなければエラー
require(_transferInfo[id].from != 0x0, "ID error.");
// 既に送金・回収されていればエラー
require(_transferInfo[id].sent == false, "Already recoveried.");
// ロックタイムを過ぎて今ければエラー
require(_transferInfo[id].date + lockTime * 60 * 60 <= block.timestamp, "Locked.");
address to = _transferInfo[id].from;
to.transfer(_transferInfo[id].amount);
_transferInfo[id].sent = true;
emit Recovery(id, _transferInfo[id].from, _transferInfo[id].amount);
}
/**
* 指定したIDの情報を返す
* onlyOwner にした方が良いかも
*/
function etherInfo(bytes32 id) public view returns (address, address, uint256, bool) {
return (_transferInfo[id].from, _transferInfo[id].to, _transferInfo[id].amount, _transferInfo[id].sent);
}
/**
* オーナー以外の管理者を設定する
* 引数1:管理者のアドレス
*
*
*/
function setAdmin(address _admin) onlyOwner public {
administrator = _admin;
}
/**
* オーナー以外の管理者を取得する
*/
function getAdmin() public view returns (address) {
return administrator;
}
/**
* 手数料の値を変更する
* 引数1:手数料の値(wei)
*
* 69fe0e2d
*/
function setFee(uint256 _fee) onlyOwner public {
fee = _fee;
}
/**
* 手数料の値を返す
*/
function getFee() public view returns (uint256) {
return fee;
}
/**
* ロック期間を変更する
* 引数1:ロック期間(時間)
*
* ae04d45d
*/
function setLockTime(uint256 _lockTime) onlyOwner public {
lockTime = _lockTime;
}
/**
* ロック期間の値を返す
*/
function getLockTime() public view returns (uint256) {
return lockTime;
}
/**
* コントラクトの残高確認
*/
function getBalance() public view returns (uint256) {
return address(this).balance;
}
/**
* オーナーによる Ether の回収
* 引数1:送り先アドレス
* 引数2;送金額
*
* 3ef5e35f
*/
function sendEtherToOwner(address to, uint256 amount) onlyOwner public {
to.transfer(amount);
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["230", "309"]}, {"defect": "Transaction_order_dependency", "type": "Business_logic", "severity": "Medium", "lines": ["207"]}, {"defect": "Bad_randomness", "type": "Business_logic", "severity": "Medium", "lines": ["184"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["229"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["49", "301", "38"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["227"]}] | [{"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"TokenExpress.sol": [199]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"TokenExpress.sol": [224]}}, {"check": "pragma", "impact": "Informational", "confidence": "High", "lines": {"TokenExpress.sol": [125]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TokenExpress.sol": [82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TokenExpress.sol": [108, 109, 110, 111]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TokenExpress.sol": [116, 117, 118, 119, 120]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TokenExpress.sol": [98, 99, 100, 101, 102, 103]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenExpress.sol": [194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenExpress.sol": [44, 45, 46, 47]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenExpress.sol": [290, 291, 292]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenExpress.sol": [173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenExpress.sol": [308, 309, 310]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenExpress.sol": [266, 267, 268]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenExpress.sol": [240, 241, 239]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenExpress.sol": [249, 250, 251]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenExpress.sol": [53, 54, 55]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenExpress.sol": [224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 219, 220, 221, 222, 223]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenExpress.sol": [256, 257, 258]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenExpress.sol": [283, 284, 285]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenExpress.sol": [297, 298, 299]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TokenExpress.sol": [273, 274, 275]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"TokenExpress.sol": [70]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"TokenExpress.sol": [125]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"TokenExpress.sol": [3]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"TokenExpress.sol": [267]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"TokenExpress.sol": [284]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"TokenExpress.sol": [309]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"TokenExpress.sol": [250]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenExpress.sol": [108]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenExpress.sol": [82]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenExpress.sol": [283]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenExpress.sol": [98]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenExpress.sol": [116]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenExpress.sol": [108]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenExpress.sol": [266]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenExpress.sol": [82]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenExpress.sol": [249]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenExpress.sol": [116]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenExpress.sol": [53]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TokenExpress.sol": [98]}}, {"check": "reentrancy-unlimited-gas", "impact": "Informational", "confidence": "Medium", "lines": {"TokenExpress.sol": [210]}}, {"check": "reentrancy-unlimited-gas", "impact": "Informational", "confidence": "Medium", "lines": {"TokenExpress.sol": [232]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"TokenExpress.sol": [227]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"TokenExpress.sol": [137]}}] | [{"error": "Integer Overflow.", "line": 232, "level": "Warning"}, {"error": "Integer Overflow.", "line": 182, "level": "Warning"}, {"error": "Integer Overflow.", "line": 240, "level": "Warning"}, {"error": "Integer Overflow.", "line": 231, "level": "Warning"}, {"error": "Integer Overflow.", "line": 208, "level": "Warning"}, {"error": "Integer Overflow.", "line": 183, "level": "Warning"}, {"error": "Integer Overflow.", "line": 209, "level": "Warning"}, {"error": "Integer Overflow.", "line": 184, "level": "Warning"}, {"error": "Integer Overflow.", "line": 210, "level": "Warning"}, {"error": "Transaction-Ordering Dependency.", "line": 309, "level": "Warning"}, {"error": "Transaction-Ordering Dependency.", "line": 230, "level": "Warning"}, {"error": "Timestamp Dependency.", "line": 227, "level": "Warning"}] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 46, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 143, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 182, "severity": 1}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 249, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 266, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 283, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 70, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 125, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 155, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 134, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 137, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 140, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 143, "severity": 1}] | [{"constant":true,"inputs":[],"name":"getBalance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"amount","type":"uint256"}],"name":"sendEtherToOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"id","type":"bytes32"},{"name":"amount","type":"uint256"}],"name":"etherDeposit","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_fee","type":"uint256"}],"name":"setFee","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"id","type":"bytes32"}],"name":"etherRecovery","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getAdmin","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_admin","type":"address"}],"name":"setAdmin","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"id","type":"bytes32"}],"name":"etherInfo","outputs":[{"name":"","type":"address"},{"name":"","type":"address"},{"name":"","type":"uint256"},{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_lockTime","type":"uint256"}],"name":"setLockTime","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getLockTime","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"id","type":"bytes32"},{"name":"to","type":"address"}],"name":"etherSend","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getFee","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"escrowId","type":"bytes32"},{"indexed":true,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"escrowId","type":"bytes32"},{"indexed":true,"name":"recipient","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"Send","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"escrowId","type":"bytes32"},{"indexed":true,"name":"sender","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"Recovery","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"}],"name":"OwnershipRenounced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}] | v0.4.26+commit.4563c3fc | false | 200 | Default | MIT | false | bzzr://ed28b19d3431f85a7a8eb52dcd352633a70a661bdc97d3c47c58d48ee4173f3e |
|||
Feed_Factory | 0xef078e8330f99186079be1d2ee6b4a5d6f23e8f1 | Solidity | pragma solidity ^0.5.13;
/// @title Spawn
/// @author 0age (@0age) for Numerai Inc
/// @dev Security contact: [email protected]
/// @dev Version: 1.2.0
/// @notice This contract provides creation code that is used by Spawner in order
/// to initialize and deploy eip-1167 minimal proxies for a given logic contract.
contract Spawn {
constructor(
address logicContract,
bytes memory initializationCalldata
) public payable {
// delegatecall into the logic contract to perform initialization.
(bool ok, ) = logicContract.delegatecall(initializationCalldata);
if (!ok) {
// pass along failure message from delegatecall and revert.
assembly {
returndatacopy(0, 0, returndatasize)
revert(0, returndatasize)
}
}
// place eip-1167 runtime code in memory.
bytes memory runtimeCode = abi.encodePacked(
bytes10(0x363d3d373d3d3d363d73),
logicContract,
bytes15(0x5af43d82803e903d91602b57fd5bf3)
);
// return eip-1167 code to write it to spawned contract runtime.
assembly {
return(add(0x20, runtimeCode), 45) // eip-1167 runtime code, length
}
}
}
/// @title Spawner
/// @author 0age (@0age) and Stephane Gosselin (@thegostep) for Numerai Inc
/// @dev Security contact: [email protected]
/// @dev Version: 1.2.0
/// @notice This contract spawns and initializes eip-1167 minimal proxies that
/// point to existing logic contracts. The logic contracts need to have an
/// initializer function that should only callable when no contract exists at
/// their current address (i.e. it is being `DELEGATECALL`ed from a constructor).
contract Spawner {
/// @notice Internal function for spawning an eip-1167 minimal proxy using `CREATE2`.
/// @param creator address The address of the account creating the proxy.
/// @param logicContract address The address of the logic contract.
/// @param initializationCalldata bytes The calldata that will be supplied to
/// the `DELEGATECALL` from the spawned contract to the logic contract during
/// contract creation.
/// @return The address of the newly-spawned contract.
function _spawn(
address creator,
address logicContract,
bytes memory initializationCalldata
) internal returns (address spawnedContract) {
// get instance code and hash
bytes memory initCode;
bytes32 initCodeHash;
(initCode, initCodeHash) = _getInitCodeAndHash(logicContract, initializationCalldata);
// get valid create2 target
(address target, bytes32 safeSalt) = _getNextNonceTargetWithInitCodeHash(creator, initCodeHash);
// spawn create2 instance and validate
return _executeSpawnCreate2(initCode, safeSalt, target);
}
/// @notice Internal function for spawning an eip-1167 minimal proxy using `CREATE2`.
/// @param creator address The address of the account creating the proxy.
/// @param logicContract address The address of the logic contract.
/// @param initializationCalldata bytes The calldata that will be supplied to
/// the `DELEGATECALL` from the spawned contract to the logic contract during
/// contract creation.
/// @param salt bytes32 A user defined salt.
/// @return The address of the newly-spawned contract.
function _spawnSalty(
address creator,
address logicContract,
bytes memory initializationCalldata,
bytes32 salt
) internal returns (address spawnedContract) {
// get instance code and hash
bytes memory initCode;
bytes32 initCodeHash;
(initCode, initCodeHash) = _getInitCodeAndHash(logicContract, initializationCalldata);
// get valid create2 target
(address target, bytes32 safeSalt, bool validity) = _getSaltyTargetWithInitCodeHash(creator, initCodeHash, salt);
require(validity, "contract already deployed with supplied salt");
// spawn create2 instance and validate
return _executeSpawnCreate2(initCode, safeSalt, target);
}
/// @notice Private function for spawning an eip-1167 minimal proxy using `CREATE2`.
/// Reverts with appropriate error string if deployment is unsuccessful.
/// @param initCode bytes The spawner code and initialization calldata.
/// @param safeSalt bytes32 A valid salt hashed with creator address.
/// @param target address The expected address of the proxy.
/// @return The address of the newly-spawned contract.
function _executeSpawnCreate2(bytes memory initCode, bytes32 safeSalt, address target) private returns (address spawnedContract) {
assembly {
let encoded_data := add(0x20, initCode) // load initialization code.
let encoded_size := mload(initCode) // load the init code's length.
spawnedContract := create2( // call `CREATE2` w/ 4 arguments.
callvalue, // forward any supplied endowment.
encoded_data, // pass in initialization code.
encoded_size, // pass in init code's length.
safeSalt // pass in the salt value.
)
// pass along failure message from failed contract deployment and revert.
if iszero(spawnedContract) {
returndatacopy(0, 0, returndatasize)
revert(0, returndatasize)
}
}
// validate spawned instance matches target
require(spawnedContract == target, "attempted deployment to unexpected address");
// explicit return
return spawnedContract;
}
/// @notice Internal view function for finding the expected address of the standard
/// eip-1167 minimal proxy created using `CREATE2` with a given logic contract,
/// salt, and initialization calldata payload.
/// @param creator address The address of the account creating the proxy.
/// @param logicContract address The address of the logic contract.
/// @param initializationCalldata bytes The calldata that will be supplied to
/// the `DELEGATECALL` from the spawned contract to the logic contract during
/// contract creation.
/// @param salt bytes32 A user defined salt.
/// @return target address The address of the newly-spawned contract.
/// @return validity bool True if the `target` is available.
function _getSaltyTarget(
address creator,
address logicContract,
bytes memory initializationCalldata,
bytes32 salt
) internal view returns (address target, bool validity) {
// get initialization code
bytes32 initCodeHash;
( , initCodeHash) = _getInitCodeAndHash(logicContract, initializationCalldata);
// get valid target
(target, , validity) = _getSaltyTargetWithInitCodeHash(creator, initCodeHash, salt);
// explicit return
return (target, validity);
}
/// @notice Internal view function for finding the expected address of the standard
/// eip-1167 minimal proxy created using `CREATE2` with a given initCodeHash, and salt.
/// @param creator address The address of the account creating the proxy.
/// @param initCodeHash bytes32 The hash of initCode.
/// @param salt bytes32 A user defined salt.
/// @return target address The address of the newly-spawned contract.
/// @return safeSalt bytes32 A safe salt. Must include the msg.sender address for front-running protection.
/// @return validity bool True if the `target` is available.
function _getSaltyTargetWithInitCodeHash(
address creator,
bytes32 initCodeHash,
bytes32 salt
) private view returns (address target, bytes32 safeSalt, bool validity) {
// get safeSalt from input
safeSalt = keccak256(abi.encodePacked(creator, salt));
// get expected target
target = _computeTargetWithCodeHash(initCodeHash, safeSalt);
// get target validity
validity = _getTargetValidity(target);
// explicit return
return (target, safeSalt, validity);
}
/// @notice Internal view function for finding the expected address of the standard
/// eip-1167 minimal proxy created using `CREATE2` with a given logic contract,
/// nonce, and initialization calldata payload.
/// @param creator address The address of the account creating the proxy.
/// @param logicContract address The address of the logic contract.
/// @param initializationCalldata bytes The calldata that will be supplied to
/// the `DELEGATECALL` from the spawned contract to the logic contract during
/// contract creation.
/// @return target address The address of the newly-spawned contract.
function _getNextNonceTarget(
address creator,
address logicContract,
bytes memory initializationCalldata
) internal view returns (address target) {
// get initialization code
bytes32 initCodeHash;
( , initCodeHash) = _getInitCodeAndHash(logicContract, initializationCalldata);
// get valid target
(target, ) = _getNextNonceTargetWithInitCodeHash(creator, initCodeHash);
// explicit return
return target;
}
/// @notice Internal view function for finding the expected address of the standard
/// eip-1167 minimal proxy created using `CREATE2` with a given initCodeHash, and nonce.
/// @param creator address The address of the account creating the proxy.
/// @param initCodeHash bytes32 The hash of initCode.
/// @return target address The address of the newly-spawned contract.
/// @return safeSalt bytes32 A safe salt. Must include the msg.sender address for front-running protection.
function _getNextNonceTargetWithInitCodeHash(
address creator,
bytes32 initCodeHash
) private view returns (address target, bytes32 safeSalt) {
// set the initial nonce to be provided when constructing the salt.
uint256 nonce = 0;
while (true) {
// get safeSalt from nonce
safeSalt = keccak256(abi.encodePacked(creator, nonce));
// get expected target
target = _computeTargetWithCodeHash(initCodeHash, safeSalt);
// validate no contract already deployed to the target address.
// exit the loop if no contract is deployed to the target address.
// otherwise, increment the nonce and derive a new salt.
if (_getTargetValidity(target))
break;
else
nonce++;
}
// explicit return
return (target, safeSalt);
}
/// @notice Private pure function for obtaining the initCode and the initCodeHash of `logicContract` and `initializationCalldata`.
/// @param logicContract address The address of the logic contract.
/// @param initializationCalldata bytes The calldata that will be supplied to
/// the `DELEGATECALL` from the spawned contract to the logic contract during
/// contract creation.
/// @return initCode bytes The spawner code and initialization calldata.
/// @return initCodeHash bytes32 The hash of initCode.
function _getInitCodeAndHash(
address logicContract,
bytes memory initializationCalldata
) private pure returns (bytes memory initCode, bytes32 initCodeHash) {
// place creation code and constructor args of contract to spawn in memory.
initCode = abi.encodePacked(
type(Spawn).creationCode,
abi.encode(logicContract, initializationCalldata)
);
// get the keccak256 hash of the init code for address derivation.
initCodeHash = keccak256(initCode);
// explicit return
return (initCode, initCodeHash);
}
/// @notice Private view function for finding the expected address of the standard
/// eip-1167 minimal proxy created using `CREATE2` with a given logic contract,
/// salt, and initialization calldata payload.
/// @param initCodeHash bytes32 The hash of initCode.
/// @param safeSalt bytes32 A safe salt. Must include the msg.sender address for front-running protection.
/// @return The address of the proxy contract with the given parameters.
function _computeTargetWithCodeHash(
bytes32 initCodeHash,
bytes32 safeSalt
) private view returns (address target) {
return address( // derive the target deployment address.
uint160( // downcast to match the address type.
uint256( // cast to uint to truncate upper digits.
keccak256( // compute CREATE2 hash using 4 inputs.
abi.encodePacked( // pack all inputs to the hash together.
bytes1(0xff), // pass in the control character.
address(this), // pass in the address of this contract.
safeSalt, // pass in the safeSalt from above.
initCodeHash // pass in hash of contract creation code.
)
)
)
)
);
}
/// @notice Private view function to validate if the `target` address is an available deployment address.
/// @param target address The address to validate.
/// @return validity bool True if the `target` is available.
function _getTargetValidity(address target) private view returns (bool validity) {
// validate no contract already deployed to the target address.
uint256 codeSize;
assembly { codeSize := extcodesize(target) }
return codeSize == 0;
}
}
/// @title iRegistry
/// @author Stephane Gosselin (@thegostep) for Numerai Inc
/// @dev Security contact: [email protected]
/// @dev Version: 1.2.0
interface iRegistry {
enum FactoryStatus { Unregistered, Registered, Retired }
event FactoryAdded(address owner, address factory, uint256 factoryID, bytes extraData);
event FactoryRetired(address owner, address factory, uint256 factoryID);
event InstanceRegistered(address instance, uint256 instanceIndex, address indexed creator, address indexed factory, uint256 indexed factoryID);
// factory state functions
function addFactory(address factory, bytes calldata extraData ) external;
function retireFactory(address factory) external;
// factory view functions
function getFactoryCount() external view returns (uint256 count);
function getFactoryStatus(address factory) external view returns (FactoryStatus status);
function getFactoryID(address factory) external view returns (uint16 factoryID);
function getFactoryData(address factory) external view returns (bytes memory extraData);
function getFactoryAddress(uint16 factoryID) external view returns (address factory);
function getFactory(address factory) external view returns (FactoryStatus state, uint16 factoryID, bytes memory extraData);
function getFactories() external view returns (address[] memory factories);
function getPaginatedFactories(uint256 startIndex, uint256 endIndex) external view returns (address[] memory factories);
// instance state functions
function register(address instance, address creator, uint80 extraData) external;
// instance view functions
function getInstanceType() external view returns (bytes4 instanceType);
function getInstanceCount() external view returns (uint256 count);
function getInstance(uint256 index) external view returns (address instance);
function getInstances() external view returns (address[] memory instances);
function getPaginatedInstances(uint256 startIndex, uint256 endIndex) external view returns (address[] memory instances);
}
/// @title iFactory
/// @author Stephane Gosselin (@thegostep) for Numerai Inc
/// @dev Security contact: [email protected]
/// @dev Version: 1.2.0
interface iFactory {
event InstanceCreated(address indexed instance, address indexed creator, bytes callData);
function create(bytes calldata callData) external returns (address instance);
function createSalty(bytes calldata callData, bytes32 salt) external returns (address instance);
function getInitSelector() external view returns (bytes4 initSelector);
function getInstanceRegistry() external view returns (address instanceRegistry);
function getTemplate() external view returns (address template);
function getSaltyInstance(address creator, bytes calldata callData, bytes32 salt) external view returns (address instance, bool validity);
function getNextNonceInstance(address creator, bytes calldata callData) external view returns (address instance);
function getInstanceCreator(address instance) external view returns (address creator);
function getInstanceType() external view returns (bytes4 instanceType);
function getInstanceCount() external view returns (uint256 count);
function getInstance(uint256 index) external view returns (address instance);
function getInstances() external view returns (address[] memory instances);
function getPaginatedInstances(uint256 startIndex, uint256 endIndex) external view returns (address[] memory instances);
}
/// @title EventMetadata
/// @author Stephane Gosselin (@thegostep) for Numerai Inc
/// @dev Security contact: [email protected]
/// @dev Version: 1.2.0
contract EventMetadata {
event MetadataSet(bytes metadata);
// state functions
function _setMetadata(bytes memory metadata) internal {
emit MetadataSet(metadata);
}
}
/// @title Operated
/// @author Stephane Gosselin (@thegostep) for Numerai Inc
/// @dev Security contact: [email protected]
/// @dev Version: 1.2.0
contract Operated {
address private _operator;
event OperatorUpdated(address operator);
// state functions
function _setOperator(address operator) internal {
// can only be called when operator is null
require(_operator == address(0), "operator already set");
// cannot set to address 0
require(operator != address(0), "cannot set operator to address 0");
// set operator in storage
_operator = operator;
// emit event
emit OperatorUpdated(operator);
}
function _transferOperator(address operator) internal {
// requires existing operator
require(_operator != address(0), "only when operator set");
// cannot set to address 0
require(operator != address(0), "cannot set operator to address 0");
// set operator in storage
_operator = operator;
// emit event
emit OperatorUpdated(operator);
}
function _renounceOperator() internal {
// requires existing operator
require(_operator != address(0), "only when operator set");
// set operator in storage
_operator = address(0);
// emit event
emit OperatorUpdated(address(0));
}
// view functions
function getOperator() public view returns (address operator) {
return _operator;
}
function isOperator(address caller) internal view returns (bool ok) {
return caller == _operator;
}
}
/// @title Template
/// @author Stephane Gosselin (@thegostep) for Numerai Inc
/// @dev Security contact: [email protected]
/// @dev Version: 1.2.0
contract Template {
address private _factory;
// modifiers
modifier initializeTemplate() {
// set factory
_factory = msg.sender;
// only allow function to be `DELEGATECALL`ed from within a constructor.
uint32 codeSize;
assembly { codeSize := extcodesize(address) }
require(codeSize == 0, "must be called within contract constructor");
_;
}
// view functions
function getCreator() public view returns (address creator) {
// iFactory(...) would revert if _factory address is not actually a factory contract
return iFactory(_factory).getInstanceCreator(address(this));
}
function isCreator(address caller) internal view returns (bool ok) {
return (caller == getCreator());
}
function getFactory() public view returns (address factory) {
return _factory;
}
}
/// @title ProofHashes
/// @author Stephane Gosselin (@thegostep) for Numerai Inc
/// @dev Security contact: [email protected]
/// @dev Version: 1.2.0
contract ProofHashes {
event HashSubmitted(bytes32 hash);
// state functions
function _submitHash(bytes32 hash) internal {
// emit event
emit HashSubmitted(hash);
}
}
/// @title Factory
/// @author Stephane Gosselin (@thegostep) for Numerai Inc
/// @dev Security contact: [email protected]
/// @dev Version: 1.2.0
/// @notice The factory contract implements a standard interface for creating EIP-1167 clones of a given template contract.
/// The create functions accept abi-encoded calldata used to initialize the spawned templates.
contract Factory is Spawner, iFactory {
address[] private _instances;
mapping (address => address) private _instanceCreator;
/* NOTE: The following items can be hardcoded as constant to save ~200 gas/create */
address private _templateContract;
bytes4 private _initSelector;
address private _instanceRegistry;
bytes4 private _instanceType;
event InstanceCreated(address indexed instance, address indexed creator, bytes callData);
/// @notice Constructior
/// @param instanceRegistry address of the registry where all clones are registered.
/// @param templateContract address of the template used for making clones.
/// @param instanceType bytes4 identifier for the type of the factory. This must match the type of the registry.
/// @param initSelector bytes4 selector for the template initialize function.
function _initialize(address instanceRegistry, address templateContract, bytes4 instanceType, bytes4 initSelector) internal {
// set instance registry
_instanceRegistry = instanceRegistry;
// set logic contract
_templateContract = templateContract;
// set initSelector
_initSelector = initSelector;
// validate correct instance registry
require(instanceType == iRegistry(instanceRegistry).getInstanceType(), 'incorrect instance type');
// set instanceType
_instanceType = instanceType;
}
// IFactory methods
/// @notice Create clone of the template using a nonce.
/// The nonce is unique for clones with the same initialization calldata.
/// The nonce can be used to determine the address of the clone before creation.
/// The callData must be prepended by the function selector of the template's initialize function and include all parameters.
/// @param callData bytes blob of abi-encoded calldata used to initialize the template.
/// @return instance address of the clone that was created.
function create(bytes memory callData) public returns (address instance) {
// deploy new contract: initialize it & write minimal proxy to runtime.
instance = Spawner._spawn(msg.sender, getTemplate(), callData);
_createHelper(instance, callData);
return instance;
}
/// @notice Create clone of the template using a salt.
/// The salt must be unique for clones with the same initialization calldata.
/// The salt can be used to determine the address of the clone before creation.
/// The callData must be prepended by the function selector of the template's initialize function and include all parameters.
/// @param callData bytes blob of abi-encoded calldata used to initialize the template.
/// @return instance address of the clone that was created.
function createSalty(bytes memory callData, bytes32 salt) public returns (address instance) {
// deploy new contract: initialize it & write minimal proxy to runtime.
instance = Spawner._spawnSalty(msg.sender, getTemplate(), callData, salt);
_createHelper(instance, callData);
return instance;
}
function _createHelper(address instance, bytes memory callData) private {
// add the instance to the array
_instances.push(instance);
// set instance creator
_instanceCreator[instance] = msg.sender;
// add the instance to the instance registry
iRegistry(getInstanceRegistry()).register(instance, msg.sender, uint80(0));
// emit event
emit InstanceCreated(instance, msg.sender, callData);
}
/// @notice Get the address of an instance for a given salt
function getSaltyInstance(
address creator,
bytes memory callData,
bytes32 salt
) public view returns (address instance, bool validity) {
return Spawner._getSaltyTarget(creator, getTemplate(), callData, salt);
}
function getNextNonceInstance(
address creator,
bytes memory callData
) public view returns (address target) {
return Spawner._getNextNonceTarget(creator, getTemplate(), callData);
}
function getInstanceCreator(address instance) public view returns (address creator) {
return _instanceCreator[instance];
}
function getInstanceType() public view returns (bytes4 instanceType) {
return _instanceType;
}
function getInitSelector() public view returns (bytes4 initSelector) {
return _initSelector;
}
function getInstanceRegistry() public view returns (address instanceRegistry) {
return _instanceRegistry;
}
function getTemplate() public view returns (address template) {
return _templateContract;
}
function getInstanceCount() public view returns (uint256 count) {
return _instances.length;
}
function getInstance(uint256 index) public view returns (address instance) {
require(index < _instances.length, "index out of range");
return _instances[index];
}
function getInstances() public view returns (address[] memory instances) {
return _instances;
}
// Note: startIndex is inclusive, endIndex exclusive
function getPaginatedInstances(uint256 startIndex, uint256 endIndex) public view returns (address[] memory instances) {
require(startIndex < endIndex, "startIndex must be less than endIndex");
require(endIndex <= _instances.length, "end index out of range");
// initialize fixed size memory array
address[] memory range = new address[](endIndex - startIndex);
// Populate array with addresses in range
for (uint256 i = startIndex; i < endIndex; i++) {
range[i - startIndex] = _instances[i];
}
// return array of addresses
return range;
}
}
/// @title Feed
/// @author Stephane Gosselin (@thegostep) for Numerai Inc
/// @dev Security contact: [email protected]
/// @dev Version: 1.2.0
contract Feed is ProofHashes, Operated, EventMetadata, Template {
event Initialized(address operator, bytes32 proofHash, bytes metadata);
/// @notice Constructor
/// @dev Access Control: only factory
/// State Machine: before all
/// @param operator Address of the operator that overrides access control
/// @param proofHash Proofhash (bytes32) sha256 hash of timestampled data
/// @param metadata Data (any format) to emit as event on initialization
function initialize(
address operator,
bytes32 proofHash,
bytes memory metadata
) public initializeTemplate() {
// set operator
if (operator != address(0)) {
Operated._setOperator(operator);
}
// submit proofHash
if (proofHash != bytes32(0)) {
ProofHashes._submitHash(proofHash);
}
// set metadata
if (metadata.length != 0) {
EventMetadata._setMetadata(metadata);
}
// log initialization params
emit Initialized(operator, proofHash, metadata);
}
// state functions
/// @notice Submit proofhash to add to feed
/// @dev Access Control: creator OR operator
/// State Machine: anytime
/// @param proofHash Proofhash (bytes32) sha256 hash of timestampled data
function submitHash(bytes32 proofHash) public {
// only operator or creator
require(Template.isCreator(msg.sender) || Operated.isOperator(msg.sender), "only operator or creator");
// submit proofHash
ProofHashes._submitHash(proofHash);
}
/// @notice Emit metadata event
/// @dev Access Control: creator OR operator
/// State Machine: anytime
/// @param metadata Data (any format) to emit as event
function setMetadata(bytes memory metadata) public {
// only operator or creator
require(Template.isCreator(msg.sender) || Operated.isOperator(msg.sender), "only operator or creator");
// set metadata
EventMetadata._setMetadata(metadata);
}
/// @notice Called by the operator to transfer control to new operator
/// @dev Access Control: operator
/// State Machine: anytime
/// @param operator Address of the new operator
function transferOperator(address operator) public {
// restrict access
require(Operated.isOperator(msg.sender), "only operator");
// transfer operator
Operated._transferOperator(operator);
}
/// @notice Called by the operator to renounce control
/// @dev Access Control: operator
/// State Machine: anytime
function renounceOperator() public {
// restrict access
require(Operated.isOperator(msg.sender), "only operator");
// renounce operator
Operated._renounceOperator();
}
}
/// @title Feed_Factory
/// @author Stephane Gosselin (@thegostep) for Numerai Inc
/// @dev Security contact: [email protected]
/// @dev Version: 1.2.0
/// @notice This factory is used to deploy instances of the template contract.
/// New instances can be created with the following functions:
/// `function create(bytes calldata initData) external returns (address instance);`
/// `function createSalty(bytes calldata initData, bytes32 salt) external returns (address instance);`
/// The `initData` parameter is ABI encoded calldata to use on the initialize function of the instance after creation.
/// The optional `salt` parameter can be used to deterministically generate the instance address instead of using a nonce.
/// See documentation of the template for additional details on initialization parameters.
/// The template contract address can be optained with the following function:
/// `function getTemplate() external view returns (address template);`
contract Feed_Factory is Factory {
constructor(address instanceRegistry, address templateContract) public {
Feed template;
// set instance type
bytes4 instanceType = bytes4(keccak256(bytes('Post')));
// set initSelector
bytes4 initSelector = template.initialize.selector;
// initialize factory params
Factory._initialize(instanceRegistry, templateContract, instanceType, initSelector);
}
}
| [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["691"]}, {"defect": "DelegateCall", "type": "Function_call", "severity": "High", "lines": ["16"]}, {"defect": "Transaction_order_dependency", "type": "Business_logic", "severity": "Medium", "lines": ["760"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["691"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["235"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["372", "700", "638"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"Feed_Factory.sol": [128, 129, 130, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"Feed_Factory.sol": [313]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"Feed_Factory.sol": [33, 34, 35]}}, {"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium", "lines": {"Feed_Factory.sol": [16]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Feed_Factory.sol": [632, 630, 631]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Feed_Factory.sol": [672, 673, 674, 675, 676, 677, 678, 664, 665, 666, 667, 668, 669, 670, 671]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Feed_Factory.sol": [736, 737, 731, 732, 733, 734, 735]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Feed_Factory.sol": [743, 744, 745, 746, 747, 748, 749]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Feed_Factory.sol": [659, 660, 661]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Feed_Factory.sol": [701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Feed_Factory.sol": [594, 595, 596, 597, 598, 599, 600, 601]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Feed_Factory.sol": [634, 635, 636]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Feed_Factory.sol": [640, 638, 639]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Feed_Factory.sol": [461, 462, 463]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Feed_Factory.sol": [768, 769, 770, 771, 772, 766, 767]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Feed_Factory.sol": [623, 624, 625, 626, 627, 628]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Feed_Factory.sol": [650, 651, 652]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Feed_Factory.sol": [579, 580, 581, 582, 583, 584, 585, 586]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Feed_Factory.sol": [505, 506, 507]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Feed_Factory.sol": [656, 657, 654, 655]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Feed_Factory.sol": [755, 756, 757, 758, 759, 760, 761]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Feed_Factory.sol": [615, 616, 617, 618, 619, 620, 621]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Feed_Factory.sol": [1]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Feed_Factory.sol": [16]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"Feed_Factory.sol": [16]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Feed_Factory.sol": [800, 801, 802, 803, 804, 805, 792, 793, 794, 795, 796, 797, 798, 799]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Feed_Factory.sol": [324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Feed_Factory.sol": [384, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"Feed_Factory.sol": [611]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"Feed_Factory.sol": [272, 269, 270, 271]}}] | [] | null | [{"inputs":[{"internalType":"address","name":"instanceRegistry","type":"address"},{"internalType":"address","name":"templateContract","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"instance","type":"address"},{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":false,"internalType":"bytes","name":"callData","type":"bytes"}],"name":"InstanceCreated","type":"event"},{"constant":false,"inputs":[{"internalType":"bytes","name":"callData","type":"bytes"}],"name":"create","outputs":[{"internalType":"address","name":"instance","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"bytes32","name":"salt","type":"bytes32"}],"name":"createSalty","outputs":[{"internalType":"address","name":"instance","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getInitSelector","outputs":[{"internalType":"bytes4","name":"initSelector","type":"bytes4"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getInstance","outputs":[{"internalType":"address","name":"instance","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getInstanceCount","outputs":[{"internalType":"uint256","name":"count","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"instance","type":"address"}],"name":"getInstanceCreator","outputs":[{"internalType":"address","name":"creator","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getInstanceRegistry","outputs":[{"internalType":"address","name":"instanceRegistry","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getInstanceType","outputs":[{"internalType":"bytes4","name":"instanceType","type":"bytes4"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getInstances","outputs":[{"internalType":"address[]","name":"instances","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"}],"name":"getNextNonceInstance","outputs":[{"internalType":"address","name":"target","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"uint256","name":"startIndex","type":"uint256"},{"internalType":"uint256","name":"endIndex","type":"uint256"}],"name":"getPaginatedInstances","outputs":[{"internalType":"address[]","name":"instances","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"bytes32","name":"salt","type":"bytes32"}],"name":"getSaltyInstance","outputs":[{"internalType":"address","name":"instance","type":"address"},{"internalType":"bool","name":"validity","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getTemplate","outputs":[{"internalType":"address","name":"template","type":"address"}],"payable":false,"stateMutability":"view","type":"function"}] | v0.5.13+commit.5b0b510c | false | 200 | 000000000000000000000000348fa9dcff507b81c7a1d7981244ea92e8c6af29000000000000000000000000ea14477b327b9e4be4cdfbce2df04c09f7d2a196 | Default | false | bzzr://015bcd3a13b8d72c19cad35ba1b0d3119894e4208fedc85cef539daaebcc8e7b |
|||
NEWSOKUCOIN | 0x4c1a22be48ef517391a491547389fb5f4f75a885 | Solidity | 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 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) onlyOwner public {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
/**
* @title ERC223
* @dev ERC223 contract interface with ERC20 functions and events
* Fully backward compatible with ERC20
* Recommended implementation used at https://github.com/Dexaran/ERC223-token-standard/tree/Recommended
*/
contract ERC223 {
uint public totalSupply;
// ERC223 and ERC20 functions and events
function balanceOf(address who) public view returns (uint);
function totalSupply() public view returns (uint256 _supply);
function transfer(address to, uint value) public returns (bool ok);
function transfer(address to, uint value, bytes data) public returns (bool ok);
function transfer(address to, uint value, bytes data, string customFallback) public returns (bool ok);
event Transfer(address indexed from, address indexed to, uint value, bytes indexed data);
// ERC223 functions
function name() public view returns (string _name);
function symbol() public view returns (string _symbol);
function decimals() public view returns (uint8 _decimals);
// ERC20 functions and events
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);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
}
/**
* @title ContractReceiver
* @dev Contract that is working with ERC223 tokens
*/
contract ContractReceiver {
struct TKN {
address sender;
uint value;
bytes data;
bytes4 sig;
}
function tokenFallback(address _from, uint _value, bytes _data) public pure {
TKN memory tkn;
tkn.sender = _from;
tkn.value = _value;
tkn.data = _data;
uint32 u = uint32(_data[3]) + (uint32(_data[2]) << 8) + (uint32(_data[1]) << 16) + (uint32(_data[0]) << 24);
tkn.sig = bytes4(u);
/**
* tkn variable is analogue of msg variable of Ether transaction
* tkn.sender is person who initiated this token transaction (analogue of msg.sender)
* tkn.value the number of tokens that were sent (analogue of msg.value)
* tkn.data is data of token transaction (analogue of msg.data)
* tkn.sig is 4 bytes signature of function if data of token transaction is a function execution
*/
}
}
/**
* @title NEWSOKUCOIN
* @author NEWSOKUCOIN
* @dev NEWSOKUCOIN is an ERC223 Token with ERC20 functions and events
* Fully backward compatible with ERC20
*/
contract NEWSOKUCOIN is ERC223, Ownable {
using SafeMath for uint256;
string public name = "NEWSOKUCOIN";
string public symbol = "NSOK";
uint8 public decimals = 18;
uint256 public totalSupply = 4e10 * 1e18;
uint256 public distributeAmount = 0;
bool public mintingFinished = false;
mapping(address => uint256) public balanceOf;
mapping(address => mapping (address => uint256)) public allowance;
mapping (address => bool) public frozenAccount;
mapping (address => uint256) public unlockUnixTime;
event FrozenFunds(address indexed target, bool frozen);
event LockedFunds(address indexed target, uint256 locked);
event Burn(address indexed from, uint256 amount);
event Mint(address indexed to, uint256 amount);
event MintFinished();
/**
* @dev Constructor is called only once and can not be called again
*/
function NEWSOKUCOIN() public {
balanceOf[msg.sender] = totalSupply;
}
function name() public view returns (string _name) {
return name;
}
function symbol() public view returns (string _symbol) {
return symbol;
}
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
function totalSupply() public view returns (uint256 _totalSupply) {
return totalSupply;
}
function balanceOf(address _owner) public view returns (uint256 balance) {
return balanceOf[_owner];
}
/**
* @dev Prevent targets from sending or receiving tokens
* @param targets Addresses to be frozen
* @param isFrozen either to freeze it or not
*/
function freezeAccounts(address[] targets, bool isFrozen) onlyOwner public {
require(targets.length > 0);
for (uint j = 0; j < targets.length; j++) {
require(targets[j] != 0x0);
frozenAccount[targets[j]] = isFrozen;
FrozenFunds(targets[j], isFrozen);
}
}
/**
* @dev Prevent targets from sending or receiving tokens by setting Unix times
* @param targets Addresses to be locked funds
* @param unixTimes Unix times when locking up will be finished
*/
function lockupAccounts(address[] targets, uint[] unixTimes) onlyOwner public {
require(targets.length > 0
&& targets.length == unixTimes.length);
for(uint j = 0; j < targets.length; j++){
require(unlockUnixTime[targets[j]] < unixTimes[j]);
unlockUnixTime[targets[j]] = unixTimes[j];
LockedFunds(targets[j], unixTimes[j]);
}
}
/**
* @dev Function that is called when a user or another contract wants to transfer funds
*/
function transfer(address _to, uint _value, bytes _data, string _custom_fallback) public returns (bool success) {
require(_value > 0
&& frozenAccount[msg.sender] == false
&& frozenAccount[_to] == false
&& now > unlockUnixTime[msg.sender]
&& now > unlockUnixTime[_to]);
if (isContract(_to)) {
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value);
balanceOf[_to] = balanceOf[_to].add(_value);
assert(_to.call.value(0)(bytes4(keccak256(_custom_fallback)), msg.sender, _value, _data));
Transfer(msg.sender, _to, _value, _data);
Transfer(msg.sender, _to, _value);
return true;
} else {
return transferToAddress(_to, _value, _data);
}
}
function transfer(address _to, uint _value, bytes _data) public returns (bool success) {
require(_value > 0
&& frozenAccount[msg.sender] == false
&& frozenAccount[_to] == false
&& now > unlockUnixTime[msg.sender]
&& now > unlockUnixTime[_to]);
if (isContract(_to)) {
return transferToContract(_to, _value, _data);
} else {
return transferToAddress(_to, _value, _data);
}
}
/**
* @dev Standard function transfer similar to ERC20 transfer with no _data
* Added due to backwards compatibility reasons
*/
function transfer(address _to, uint _value) public returns (bool success) {
require(_value > 0
&& frozenAccount[msg.sender] == false
&& frozenAccount[_to] == false
&& now > unlockUnixTime[msg.sender]
&& now > unlockUnixTime[_to]);
bytes memory empty;
if (isContract(_to)) {
return transferToContract(_to, _value, empty);
} else {
return transferToAddress(_to, _value, empty);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private view returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint _value, bytes _data) private returns (bool success) {
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value);
balanceOf[_to] = balanceOf[_to].add(_value);
Transfer(msg.sender, _to, _value, _data);
Transfer(msg.sender, _to, _value);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint _value, bytes _data) private returns (bool success) {
require(balanceOf[msg.sender] >= _value);
balanceOf[msg.sender] = balanceOf[msg.sender].sub(_value);
balanceOf[_to] = balanceOf[_to].add(_value);
ContractReceiver receiver = ContractReceiver(_to);
receiver.tokenFallback(msg.sender, _value, _data);
Transfer(msg.sender, _to, _value, _data);
Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* Added due to backwards compatibility with ERC20
* @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 success) {
require(_to != address(0)
&& _value > 0
&& balanceOf[_from] >= _value
&& allowance[_from][msg.sender] >= _value
&& frozenAccount[_from] == false
&& frozenAccount[_to] == false
&& now > unlockUnixTime[_from]
&& now > unlockUnixTime[_to]);
balanceOf[_from] = balanceOf[_from].sub(_value);
balanceOf[_to] = balanceOf[_to].add(_value);
allowance[_from][msg.sender] = allowance[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
/**
* @dev Allows _spender to spend no more than _value tokens in your behalf
* Added due to backwards compatibility with ERC20
* @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;
Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender
* Added due to backwards compatibility with ERC20
* @param _owner address The address which owns the funds
* @param _spender address The address which will spend the funds
*/
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
return allowance[_owner][_spender];
}
/**
* @dev Burns a specific amount of tokens.
* @param _from The address that will burn the tokens.
* @param _unitAmount The amount of token to be burned.
*/
function burn(address _from, uint256 _unitAmount) onlyOwner public {
require(_unitAmount > 0
&& balanceOf[_from] >= _unitAmount);
balanceOf[_from] = balanceOf[_from].sub(_unitAmount);
totalSupply = totalSupply.sub(_unitAmount);
Burn(_from, _unitAmount);
}
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _unitAmount The amount of tokens to mint.
*/
function mint(address _to, uint256 _unitAmount) onlyOwner canMint public returns (bool) {
require(_unitAmount > 0);
totalSupply = totalSupply.add(_unitAmount);
balanceOf[_to] = balanceOf[_to].add(_unitAmount);
Mint(_to, _unitAmount);
Transfer(address(0), _to, _unitAmount);
return true;
}
/**
* @dev Function to stop minting new tokens.
*/
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
MintFinished();
return true;
}
/**
* @dev Function to distribute tokens to the list of addresses by the provided amount
*/
function distributeAirdrop(address[] addresses, uint256 amount) public returns (bool) {
require(amount > 0
&& addresses.length > 0
&& frozenAccount[msg.sender] == false
&& now > unlockUnixTime[msg.sender]);
amount = amount.mul(1e18);
uint256 totalAmount = amount.mul(addresses.length);
require(balanceOf[msg.sender] >= totalAmount);
for (uint j = 0; j < addresses.length; j++) {
require(addresses[j] != 0x0
&& frozenAccount[addresses[j]] == false
&& now > unlockUnixTime[addresses[j]]);
balanceOf[addresses[j]] = balanceOf[addresses[j]].add(amount);
Transfer(msg.sender, addresses[j], amount);
}
balanceOf[msg.sender] = balanceOf[msg.sender].sub(totalAmount);
return true;
}
function distributeAirdrop(address[] addresses, uint[] amounts) public returns (bool) {
require(addresses.length > 0
&& addresses.length == amounts.length
&& frozenAccount[msg.sender] == false
&& now > unlockUnixTime[msg.sender]);
uint256 totalAmount = 0;
for(uint j = 0; j < addresses.length; j++){
require(amounts[j] > 0
&& addresses[j] != 0x0
&& frozenAccount[addresses[j]] == false
&& now > unlockUnixTime[addresses[j]]);
amounts[j] = amounts[j].mul(1e18);
totalAmount = totalAmount.add(amounts[j]);
}
require(balanceOf[msg.sender] >= totalAmount);
for (j = 0; j < addresses.length; j++) {
balanceOf[addresses[j]] = balanceOf[addresses[j]].add(amounts[j]);
Transfer(msg.sender, addresses[j], amounts[j]);
}
balanceOf[msg.sender] = balanceOf[msg.sender].sub(totalAmount);
return true;
}
/**
* @dev Function to collect tokens from the list of addresses
*/
function collectTokens(address[] addresses, uint[] amounts) onlyOwner public returns (bool) {
require(addresses.length > 0
&& addresses.length == amounts.length);
uint256 totalAmount = 0;
for (uint j = 0; j < addresses.length; j++) {
require(amounts[j] > 0
&& addresses[j] != 0x0
&& frozenAccount[addresses[j]] == false
&& now > unlockUnixTime[addresses[j]]);
amounts[j] = amounts[j].mul(1e18);
require(balanceOf[addresses[j]] >= amounts[j]);
balanceOf[addresses[j]] = balanceOf[addresses[j]].sub(amounts[j]);
totalAmount = totalAmount.add(amounts[j]);
Transfer(addresses[j], msg.sender, amounts[j]);
}
balanceOf[msg.sender] = balanceOf[msg.sender].add(totalAmount);
return true;
}
function setDistributeAmount(uint256 _unitAmount) onlyOwner public {
distributeAmount = _unitAmount;
}
/**
* @dev Function to distribute tokens to the msg.sender automatically
* If distributeAmount is 0, this function doesn't work
*/
function autoDistribute() payable public {
require(distributeAmount > 0
&& balanceOf[owner] >= distributeAmount
&& frozenAccount[msg.sender] == false
&& now > unlockUnixTime[msg.sender]);
if(msg.value > 0) owner.transfer(msg.value);
balanceOf[owner] = balanceOf[owner].sub(distributeAmount);
balanceOf[msg.sender] = balanceOf[msg.sender].add(distributeAmount);
Transfer(owner, msg.sender, distributeAmount);
}
/**
* @dev fallback function
*/
function() payable public {
autoDistribute();
}
} | [{"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["461", "200", "413", "216", "433", "444"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["110"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["82", "304"]}, {"defect": "Balance_manipulation", "type": "Business_logic", "severity": "Medium", "lines": ["486", "319"]}, {"defect": "Redefine_variable", "type": "Code_specification", "severity": "Low", "lines": ["150"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["63"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["150", "124"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["426", "414", "404", "247", "265", "319", "462", "434", "227", "486"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [282, 283, 284, 285, 286]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [464, 465, 462, 463]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [265, 266, 267, 268, 269]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [434, 435, 436, 437]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [488, 489, 486, 487]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [426, 427, 428, 429]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [247, 248, 249, 250, 251]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [416, 414, 415]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [404, 405, 406, 407]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [227, 228, 229, 230, 231]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [320, 321, 322, 323, 324, 325, 326, 319]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [148]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [82]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [149]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [147]}}, {"check": "constant-function-asm", "impact": "Medium", "confidence": "Medium", "lines": {"NEWSOKUCOIN.sol": [280, 281, 282, 283, 284, 285, 286, 287]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"NEWSOKUCOIN.sol": [17, 18, 19, 20, 21, 22]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [184, 185, 186]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [176, 177, 178]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [353, 354, 355]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [394, 395, 396, 397, 398]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [180, 181, 182]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [500, 501, 502]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [256, 257, 258, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [67, 68, 69, 70, 71]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [188, 189, 190]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [477, 478, 479]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [172, 173, 174]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [362, 363, 364, 365, 366, 367, 368, 369]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [128, 129, 130, 131, 132, 133, 134, 119, 120, 121, 122, 123, 124, 125, 126, 127]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [384, 385, 386, 387, 388, 389, 381, 382, 383]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [341, 342, 343, 344, 345]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [197, 198, 199, 200, 201, 202, 203, 204, 205]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [212, 213, 214, 215, 216, 217, 218, 219, 220, 221]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 318, 319]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [1]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [237]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"NEWSOKUCOIN.sol": [478]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [362]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [119]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [226]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [300]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [300]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [188]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [290]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [353]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [119]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [341]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [318]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [300]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [318]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [290]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [246]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [246]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [226]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [477]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [362]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [264]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [119]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [290]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [381]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [226]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [353]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [226]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [246]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [381]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [341]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [264]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [318]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"NEWSOKUCOIN.sol": [239]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"NEWSOKUCOIN.sol": [307]}}, {"check": "reentrancy-unlimited-gas", "impact": "Informational", "confidence": "Medium", "lines": {"NEWSOKUCOIN.sol": [494]}}, {"check": "shadowing-abstract", "impact": "Medium", "confidence": "High", "lines": {"NEWSOKUCOIN.sol": [82]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"NEWSOKUCOIN.sol": [265, 266, 267, 268, 269]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"NEWSOKUCOIN.sol": [416, 414, 415]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"NEWSOKUCOIN.sol": [227, 228, 229, 230, 231]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"NEWSOKUCOIN.sol": [320, 321, 322, 323, 324, 325, 326, 319]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"NEWSOKUCOIN.sol": [464, 465, 462, 463]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"NEWSOKUCOIN.sol": [434, 435, 436, 437]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"NEWSOKUCOIN.sol": [488, 489, 486, 487]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"NEWSOKUCOIN.sol": [247, 248, 249, 250, 251]}}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium", "lines": {"NEWSOKUCOIN.sol": [271]}}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium", "lines": {"NEWSOKUCOIN.sol": [120]}}] | [{"error": "Integer Overflow.", "line": 119, "level": "Warning"}, {"error": "Integer Underflow.", "line": 177, "level": "Warning"}, {"error": "Integer Underflow.", "line": 173, "level": "Warning"}, {"error": "Integer Overflow.", "line": 246, "level": "Warning"}, {"error": "Integer Overflow.", "line": 455, "level": "Warning"}, {"error": "Integer Overflow.", "line": 425, "level": "Warning"}, {"error": "Integer Overflow.", "line": 212, "level": "Warning"}, {"error": "Integer Overflow.", "line": 403, "level": "Warning"}, {"error": "Integer Overflow.", "line": 226, "level": "Warning"}, {"error": "Integer Overflow.", "line": 197, "level": "Warning"}, {"error": "Integer Overflow.", "line": 30, "level": "Warning"}, {"error": "Timestamp Dependency.", "line": 486, "level": "Warning"}] | [{"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 200, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 216, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 413, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 433, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 444, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 461, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 200, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 216, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 413, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 433, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 444, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 461, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 477, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 145, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 280, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 237, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 500, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 88, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 89, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 89, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 93, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 94, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 119, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 172, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 176, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 197, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 212, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 212, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 226, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 226, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 246, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 290, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 300, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 403, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 425, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 425, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 455, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 455, "severity": 1}] | [{"constant":true,"inputs":[],"name":"mintingFinished","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"_name","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"_totalSupply","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"_decimals","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_unitAmount","type":"uint256"}],"name":"mint","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"distributeAmount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"targets","type":"address[]"},{"name":"unixTimes","type":"uint256[]"}],"name":"lockupAccounts","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"finishMinting","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"addresses","type":"address[]"},{"name":"amount","type":"uint256"}],"name":"distributeAirdrop","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"_symbol","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_unitAmount","type":"uint256"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"autoDistribute","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"frozenAccount","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"targets","type":"address[]"},{"name":"isFrozen","type":"bool"}],"name":"freezeAccounts","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"unlockUnixTime","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_unitAmount","type":"uint256"}],"name":"setDistributeAmount","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"addresses","type":"address[]"},{"name":"amounts","type":"uint256[]"}],"name":"distributeAirdrop","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"addresses","type":"address[]"},{"name":"amounts","type":"uint256[]"}],"name":"collectTokens","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"},{"name":"_data","type":"bytes"},{"name":"_custom_fallback","type":"string"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"target","type":"address"},{"indexed":false,"name":"frozen","type":"bool"}],"name":"FrozenFunds","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"target","type":"address"},{"indexed":false,"name":"locked","type":"uint256"}],"name":"LockedFunds","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[],"name":"MintFinished","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"},{"indexed":true,"name":"data","type":"bytes"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"}] | v0.4.18+commit.9cf6e910 | true | 200 | Default | false | bzzr://5a96d70a5933ce9d520e898ebf3f3f8ba3f763642ad862c4638a10383592f70e |
||||
TokenTrustMinimizedProxy | 0x5d584344246c59231be750865cccab27309e1bfd | Solidity | pragma solidity >=0.7.0 <0.8.0;
// OpenZeppelin Upgradeability contracts modified by Sam Porter. Proxy for Nameless Protocol contracts
// You can find original set of contracts here: https://github.com/OpenZeppelin/openzeppelin-contracts/tree/master/contracts/proxy
// Had to pack OpenZeppelin upgradeability contracts in one single contract for readability. It's basically the same OpenZeppelin functions
// but in one contract with some differences:
// 1. DEADLINE is a block after which it becomes impossible to upgrade the contract. Defined in constructor and here it's ~2 years.
// Maybe not even required for most contracts, but I kept it in case if something happens to developers.
// 2. PROPOSE_BLOCK defines how often the contract can be upgraded. Defined in _setNextLogic() function and the interval here is set
// to 172800 blocks ~1 month.
// 3. Admin rights are burnable. Rather not do that without deadline
// 4. prolongLock() allows to add to PROPOSE_BLOCK. Basically allows to prolong lock. For example if there no upgrades planned soon,
// then this function could be called to set next upgrade being possible only in a year, so investors won't need to monitor the code too closely
// all the time. Could prolong to maximum solidity number so the deadline might not be needed
// 5. logic contract is not being set suddenly. it's being stored in NEXT_LOGIC_SLOT for a month and only after that it can be set as LOGIC_SLOT.
// Users have time to decide on if the deployer or the governance is malicious and exit safely.
// 6. constructor does not require arguments
// It fixes "upgradeability bug" I believe. Also I sincerely believe that upgradeability is not about fixing bugs, but about upgradeability,
// so yeah, proposed logic has to be clean.
// In my heart it exists as eip-1984 but it's too late for that number. https://ethereum-magicians.org/t/trust-minimized-proxy/5742/2
contract TokenTrustMinimizedProxy{
event Upgraded(address indexed toLogic);
event AdminChanged(address indexed previousAdmin, address indexed newAdmin);
event NextLogicDefined(address indexed nextLogic, uint timeOfArrivalBlock);
event UpgradesRestrictedUntil(uint block);
event NextLogicCanceled(address indexed toLogic);
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
bytes32 internal constant LOGIC_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
bytes32 internal constant NEXT_LOGIC_SLOT = 0xb182d207b11df9fb38eec1e3fe4966cf344774ba58fb0e9d88ea35ad46f3601e;
bytes32 internal constant NEXT_LOGIC_BLOCK_SLOT = 0x96de003e85302815fe026bddb9630a50a1d4dc51c5c355def172204c3fd1c733;
bytes32 internal constant PROPOSE_BLOCK_SLOT = 0xbc9d35b69e82e85049be70f91154051f5e20e574471195334bde02d1a9974c90;
// bytes32 internal constant DEADLINE_SLOT = 0xb124b82d2ac46ebdb08de751ebc55102cc7325d133e09c1f1c25014e20b979ad;
constructor() payable {
// require(ADMIN_SLOT == bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1) && LOGIC_SLOT==bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1) // this require is simply against human error, can be removed if you know what you are doing
// && NEXT_LOGIC_SLOT == bytes32(uint256(keccak256('eip1984.proxy.nextLogic')) - 1) && NEXT_LOGIC_BLOCK_SLOT == bytes32(uint256(keccak256('eip1984.proxy.nextLogicBlock')) - 1)
// && PROPOSE_BLOCK_SLOT == bytes32(uint256(keccak256('eip1984.proxy.proposeBlock')) - 1)/* && DEADLINE_SLOT == bytes32(uint256(keccak256('eip1984.proxy.deadline')) - 1)*/);
_setAdmin(msg.sender);
// uint deadline = block.number + 4204800; // ~2 years as default
// assembly {sstore(DEADLINE_SLOT,deadline)}
}
modifier ifAdmin() {if (msg.sender == _admin()) {_;} else {_fallback();}}
function _logic() internal view returns (address logic) {assembly { logic := sload(LOGIC_SLOT) }}
function _proposeBlock() internal view returns (uint bl) {assembly { bl := sload(PROPOSE_BLOCK_SLOT) }}
function _nextLogicBlock() internal view returns (uint bl) {assembly { bl := sload(NEXT_LOGIC_BLOCK_SLOT) }}
// function _deadline() internal view returns (uint bl) {assembly { bl := sload(DEADLINE_SLOT) }}
function _admin() internal view returns (address adm) {assembly { adm := sload(ADMIN_SLOT) }}
function _isContract(address account) internal view returns (bool b) {uint256 size;assembly {size := extcodesize(account)}return size > 0;}
function _setAdmin(address newAdm) internal {assembly {sstore(ADMIN_SLOT, newAdm)}}
function changeAdmin(address newAdm) external ifAdmin {emit AdminChanged(_admin(), newAdm);_setAdmin(newAdm);}
function upgrade() external ifAdmin {require(block.number>=_nextLogicBlock());address logic;assembly {logic := sload(NEXT_LOGIC_SLOT) sstore(LOGIC_SLOT,logic)}emit Upgraded(logic);}
fallback () external payable {_fallback();}
receive () external payable {_fallback();}
function _fallback() internal {require(msg.sender != _admin());_delegate(_logic());}
function cancelUpgrade() external ifAdmin {address logic; assembly {logic := sload(LOGIC_SLOT)sstore(NEXT_LOGIC_SLOT, logic)}emit NextLogicCanceled(logic);}
function proposeTo(address newLogic) external ifAdmin {
if (_logic() == address(0)) {_updateBlockSlots();assembly {sstore(LOGIC_SLOT,newLogic)}emit Upgraded(newLogic);} else{_setNextLogic(newLogic);}
}
function prolongLock(uint block_) external ifAdmin {
uint pb; assembly {pb := sload(PROPOSE_BLOCK_SLOT) pb := add(pb,block_) sstore(PROPOSE_BLOCK_SLOT,pb)}emit UpgradesRestrictedUntil(pb);
}
function proposeToAndCall(address newLogic, bytes calldata data) payable external ifAdmin {
if (_logic() == address(0)) {_updateBlockSlots();assembly {sstore(LOGIC_SLOT,newLogic)}}else{_setNextLogic(newLogic);}
(bool success,) = newLogic.delegatecall(data);require(success);
}
function _setNextLogic(address nextLogic) internal {
require(block.number >= _proposeBlock() && _isContract(nextLogic));
_updateBlockSlots();
assembly { sstore(NEXT_LOGIC_SLOT, nextLogic)}
emit NextLogicDefined(nextLogic,block.number + 172800);
}
function _updateBlockSlots() internal {
uint proposeBlock = block.number + 172800;uint nextLogicBlock = block.number + 172800; assembly {sstore(NEXT_LOGIC_BLOCK_SLOT,nextLogicBlock) sstore(PROPOSE_BLOCK_SLOT,proposeBlock)}
}
function _delegate(address logic_) internal {
assembly {
calldatacopy(0, 0, calldatasize())
let result := delegatecall(gas(), logic_, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch result
case 0 { revert(0, returndatasize()) }
default { return(0, returndatasize()) }
}
}
} | [{"defect": "DelegateCall", "type": "Function_call", "severity": "High", "lines": ["72"]}, {"defect": "Bad_randomness", "type": "Business_logic", "severity": "Medium", "lines": ["83", "83"]}, {"defect": "Frozen_Ether", "type": "Code_specification", "severity": "Medium", "lines": ["24"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["35", "OGIC_SLOT.L32", "31", "34", "33", "60", "56", "67", "83", "83"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["83", "83"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TokenTrustMinimizedProxy.sol": [78]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TokenTrustMinimizedProxy.sol": [49]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TokenTrustMinimizedProxy.sol": [56]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TokenTrustMinimizedProxy.sol": [67]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TokenTrustMinimizedProxy.sol": [54]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TokenTrustMinimizedProxy.sol": [48]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TokenTrustMinimizedProxy.sol": [60]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TokenTrustMinimizedProxy.sol": [71]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TokenTrustMinimizedProxy.sol": [52]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TokenTrustMinimizedProxy.sol": [53]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TokenTrustMinimizedProxy.sol": [83]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TokenTrustMinimizedProxy.sol": [87, 88, 89, 90, 91, 92, 93, 94]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TokenTrustMinimizedProxy.sol": [50]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TokenTrustMinimizedProxy.sol": [63]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"TokenTrustMinimizedProxy.sol": [1]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"TokenTrustMinimizedProxy.sol": [72]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"TokenTrustMinimizedProxy.sol": [72]}}, {"check": "incorrect-modifier", "impact": "Low", "confidence": "High", "lines": {"TokenTrustMinimizedProxy.sol": [47]}}] | [] | [{"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 48, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 49, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 50, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 52, "severity": 1}, {"rule": "SOLIDITY_LOCKED_MONEY", "line": 24, "severity": 3}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 48, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 49, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 50, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 52, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 53, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 48, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 49, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 50, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 52, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 54, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 56, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 38, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 57, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 57, "severity": 1}] | [{"inputs":[],"stateMutability":"payable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":true,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"toLogic","type":"address"}],"name":"NextLogicCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"nextLogic","type":"address"},{"indexed":false,"internalType":"uint256","name":"timeOfArrivalBlock","type":"uint256"}],"name":"NextLogicDefined","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"toLogic","type":"address"}],"name":"Upgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"block","type":"uint256"}],"name":"UpgradesRestrictedUntil","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"cancelUpgrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAdm","type":"address"}],"name":"changeAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"block_","type":"uint256"}],"name":"prolongLock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newLogic","type":"address"}],"name":"proposeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newLogic","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"proposeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"upgrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}] | v0.7.6+commit.7338295f | false | 200 | Default | MIT | true | 0x1e2febe34ef16fc391f51689ed110a31fa004dbc | ipfs://79a7d229b46cb68de529029ec0358470e0df18c23c627c31ae33035d8d975e13 |
||
PerkscoinToken | 0x5ebe6a342a93102393edd9d2e458c689e5ac0bb3 | Solidity | pragma solidity ^0.4.16;
/*
* Abstract Token Smart Contract. Copyright © 2017 by ABDK Consulting.
* Author: Mikhail Vladimirov <[email protected]>
*/
pragma solidity ^0.4.20;
/*
* EIP-20 Standard Token Smart Contract Interface.
* Copyright © 2016–2018 by ABDK Consulting.
* Author: Mikhail Vladimirov <[email protected]>
*/
pragma solidity ^0.4.20;
/**
* ERC-20 standard token interface, as defined
* <a href="https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md">here</a>.
*/
contract Token {
/**
* Get total number of tokens in circulation.
*
* @return total number of tokens in circulation
*/
function totalSupply () public view 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 view 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)
public view 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 <[email protected]>
*/
pragma solidity ^0.4.20;
/**
* 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 view returns (uint256 balance) {
return accounts [_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) {
uint256 fromBalance = accounts [msg.sender];
if (fromBalance < _value) return false;
if (_value > 0 && msg.sender != _to) {
accounts [msg.sender] = safeSub (fromBalance, _value);
accounts [_to] = safeAdd (accounts [_to], _value);
}
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) {
uint256 spenderAllowance = allowances [_from][msg.sender];
if (spenderAllowance < _value) return false;
uint256 fromBalance = accounts [_from];
if (fromBalance < _value) return false;
allowances [_from][msg.sender] =
safeSub (spenderAllowance, _value);
if (_value > 0 && _from != _to) {
accounts [_from] = safeSub (fromBalance, _value);
accounts [_to] = safeAdd (accounts [_to], _value);
}
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;
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 view 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) internal accounts;
/**
* 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)) internal allowances;
}
/**
* CannaSOS token smart contract.
*/
contract PerkscoinToken is AbstractToken {
/**
* Total number of tokens in circulation.
*/
uint256 tokenCount;
/**
* Create new CannaSOS token smart contract, with given number of tokens issued
* and given to msg.sender.
*
* @param _tokenCount number of tokens to issue and give to msg.sender
*/
function PerkscoinToken (uint256 _tokenCount) public {
tokenCount = _tokenCount;
accounts [msg.sender] = _tokenCount;
}
/**
* Get total number of tokens in circulation.
*
* @return total number of tokens in circulation
*/
function totalSupply () public view returns (uint256 supply) {
return tokenCount;
}
/**
* Get name of this token.
*
* @return name of this token
*/
function name () public pure returns (string result) {
return "Perkscoin";
}
/**
* Get symbol of this token.
*
* @return symbol of this token
*/
function symbol () public pure returns (string result) {
return "PCT";
}
/**
* Get number of decimals for this token.
*
* @return number of decimals for this token
*/
function decimals () public pure returns (uint8 result) {
return 8;
}
/**
* 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;
}
} | [] | [{"check": "pragma", "impact": "Informational", "confidence": "High", "lines": {"PerkscoinToken.sol": [109]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"PerkscoinToken.sol": [153, 154, 155, 156, 157, 158, 159]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PerkscoinToken.sol": [312, 313, 314]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PerkscoinToken.sol": [44, 45]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PerkscoinToken.sol": [352, 347, 348, 349, 350, 351]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PerkscoinToken.sol": [35]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PerkscoinToken.sol": [56, 57]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PerkscoinToken.sol": [321, 322, 323]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PerkscoinToken.sol": [330, 331, 332]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"PerkscoinToken.sol": [26]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PerkscoinToken.sol": [1]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PerkscoinToken.sol": [7]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PerkscoinToken.sol": [109]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"PerkscoinToken.sol": [14]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PerkscoinToken.sol": [240]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PerkscoinToken.sol": [259]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PerkscoinToken.sol": [182]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PerkscoinToken.sol": [193]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PerkscoinToken.sol": [347]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PerkscoinToken.sol": [240]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PerkscoinToken.sol": [214]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PerkscoinToken.sol": [214]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PerkscoinToken.sol": [347]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PerkscoinToken.sol": [259]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PerkscoinToken.sol": [193]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PerkscoinToken.sol": [347]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"PerkscoinToken.sol": [214]}}] | [] | [{"rule": "SOLIDITY_ERC20_APPROVE", "line": 240, "severity": 2}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 347, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 7, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 14, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 109, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 115, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 312, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 321, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 285, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"result","type":"string"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"supply","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"result","type":"uint8"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_currentValue","type":"uint256"},{"name":"_newValue","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"result","type":"string"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_tokenCount","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"}] | v0.4.20+commit.3155dd80 | true | 200 | 000000000000000000000000000000000000000000000000002386f26fc10000 | Default | false | bzzr://d5bae0811ea6e3c33d35a0e4c4a5e5090859e5be28414675f56393aef5eab780 |
|||
F1 | 0x203f02763e3c5b1afee3823eb207a1631c4f0982 | Solidity | /**
*Submitted for verification at Etherscan.io on 2021-06-06
*/
//ppppppppppppppppppbbbbbbCbbbbbbbbbbbbbbbbbbbbbbbbbbbCbbQQQQQQQQQQQQQQQQQQQQQQQQQ
//bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbQQQQQQP)(uu·))QQQQQQQQQQQQqqqqqqqqqqqqqqqqqqqqqqqq
//QQQQQQQQQQQQQQQQQQQQQQQQQQQQQqqqqqqqqqqdeqqqqqqqqqqqqqqqqqqddddddddddddddddddddd
//QQqqqqqqqqqqqqqqqqqqqqqqqqqqqqqdddddddd··)DGGdddddddddGGGGGGGGGGGGGGGGGGGGGGGGGG
//qqqddddddddddddddddddddddDGDdddqppQpqpD··uQQpQGqDDDDdDGGGGGGDGDDGGGGDGDDDDGDGGGG
//DGGGGGGGGGDDGDDGGGGGDGDDGDGDPPPdGDPQDDGGDDdGPPDGDoS(eDDDDDGGGGGGGGGGGGDGGGDDGDGG
//GDGGGDGDGGDGDGDGGDqqqqDDGGGDCQQPQbPQqGDGDDGQQPCCQQQQCGDGGDpqqqDGGGGGGGGGGGGDGGGD
//DDGGGGGGGGdGGGGGGGGGd))PP(dQqqqDQqdqGqDPDQPdQqqqdqqqsGPPPPPGdDGDPPPPPGGGDGDGGGGG
//GDGDGGDGD···········dDDqqqqDDDGDGDDDDGddDDGGGDGDDGdddqqqqqQqd··········)GGGDGDGG
//DDGGGGGqQ····u······PQdo······))·u)bDSDDDDDQdCu·uS·······dqQD··········qDGGDDGGD
//GGGGGGDdD·upcpco····CQGb···········GDGDDDDddG············DQQ······u·uu·dDGGGGGGG
//GDGGGGDDC)DDDDDPod·u···)du·qqqdGDD)DDDppqpGGGCdDGDqqq··pp····uDc(oqsGGDdDGGGGDDG
//GGDGGDGD···)(()ppdpuu·)QqddDDDDGDqDDGDGGPDGDDDGdGGDDGDdqQu··ubGpuu)u(··)GGGGGDGG
//GDGGGGGD······)D)DDPGdDQQqqoqqqq···)QPCCC)PQ(cc·qqqqqqqQDDGPGGDqdD······GDDGGGGD
//GGGGGGGD····))du···()PPPPPPP)qqbDCpcQpu··cc)uc(G))eqGdddPPPP(cb)QDo·····GDGDGGGG
//GGGDGDDQ·····dC·············)eoS(PPPQPd)P)CSS((·uoco·············GD·····dDGDDGGG
//DGGGDDDq············ddDDDDDDDDqp·e)cQ······b····)qdGGDDDDDDDu···········GGGGGGDG
//DDDDDDDDp··········eGGDDGGDDDDDDDbu··········usDDGDDDDDGGGDDG··········)dGGGGGDD
//GDDGGDDDDDqocccuucpqqdddqqqqqqqqqqDQpppooooppGqqqqqqqqqddqqqqqoocooppqGGGGGGGGDD
//GGGDGGDDGGGGGGGGGGGGGGGGDGGDGDDDGGGGDGGGGGGDGGGGGGGGDGGGGGGDDGGGGGGGGGGGGGDDGDGD
//
// https://t.me/F1token
//
// 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 F1 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 = 10**9 * 10**6 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'F1';
string private _symbol = 'F1';
uint8 private _decimals = 9;
address private F1 = 0xF1f1110089C76a860Bf3B00d3487398d60CBdbE4;
address private burn = 0xf1F1f1f1f1F1F1f1F1F1f1F1f1f1f1f1f1f1f11f;
constructor () public {
_rOwned[F1] = _rTotal.div(2);
_rOwned[burn] = _rTotal.div(2);
emit Transfer(address(0), burn, _tTotal.div(2));
emit Transfer(address(0), F1, _tTotal.div(2));
}
function name() external view returns (string memory) {
return _name;
}
function symbol() external view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() external view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) external 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) external 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 isExcluded(address account) external view returns (bool) {
return _isExcluded[account];
}
function totalFees() external view returns (uint256) {
return _tFeeTotal;
}
function reflect(uint256 tAmount) external {
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) 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 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 included");
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]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee) = _getTValues(tAmount);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee);
}
function _getTValues(uint256 tAmount) private pure returns (uint256, uint256) {
uint256 tFee = tAmount.div(100).mul(2);
uint256 tTransferAmount = tAmount.sub(tFee);
return (tTransferAmount, tFee);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
} | [{"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["573"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["421", "406", "433"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["459"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"F1.sol": [282]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"F1.sol": [384, 381, 382, 383]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"F1.sol": [462]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"F1.sol": [463]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"F1.sol": [464]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"F1.sol": [467]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"F1.sol": [466]}}, {"check": "costly-loop", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [578]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [302, 303, 304, 305, 306, 307, 308]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [353, 354, 355]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [251, 252, 253, 254]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [363, 364, 365, 366]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [40, 37, 38, 39]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [235, 236, 237]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [384, 385, 386, 387, 388, 389, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [275, 276, 277, 278, 279, 280, 281, 282, 283, 284]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [338, 339, 340]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [328, 329, 330]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"F1.sol": [656]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"F1.sol": [428, 429, 430, 431]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"F1.sol": [409, 410, 411]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"F1.sol": [485, 486, 487]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"F1.sol": [437, 438, 439, 440, 441]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"F1.sol": [409, 410, 411]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"F1.sol": [409, 410, 411]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"F1.sol": [372]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"F1.sol": [306]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"F1.sol": [458]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"F1.sol": [466]}}, {"check": "redundant-statements", "impact": "Informational", "confidence": "High", "lines": {"F1.sol": [32, 33, 34, 35, 36, 37, 38, 39, 40, 41]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [634]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [625]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [625]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [657]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [608]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [608]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [616]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [634]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [657]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [608]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [657]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [616]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [657]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [625]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [634]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [625]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [649]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [616]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [657]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [634]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [608]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [616]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [649]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [608]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [625]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [657]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [616]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [608]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [616]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [616]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [649]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [634]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [649]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [649]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [634]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [625]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [657]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [634]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [625]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [608]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [649]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"F1.sol": [649]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 466, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 467, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 430, "severity": 1}, {"rule": "SOLIDITY_DIV_MUL", "line": 656, "severity": 2}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 507, "severity": 2}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 573, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 676, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 573, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 676, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 30, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 393, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 450, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 451, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 452, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 454, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 455, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 457, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 458, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 459, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 460, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 462, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 463, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 464, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 466, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 467, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 447, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 275, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 648, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 655, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 661, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 673, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 282, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 302, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 302, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 302, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 303, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 303, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 303, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 303, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 306, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 306, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 306, "severity": 1}] | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"excludeAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"includeAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isExcluded","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tAmount","type":"uint256"}],"name":"reflect","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tAmount","type":"uint256"},{"internalType":"bool","name":"deductTransferFee","type":"bool"}],"name":"reflectionFromToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"rAmount","type":"uint256"}],"name":"tokenFromReflection","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}] | v0.6.12+commit.27d51765 | false | 200 | Default | MIT | false | ipfs://db43ae412f07d5be995daf685e6730f90fe765828734c039341e2f2a6dc0cf55 |
|||
VIBES | 0x48f1a5a16b2f208243b3a29e25e7c736e8873391 | Solidity | /**
*Submitted for verification at Etherscan.io on 2021-12-29
*/
/**
---------------------------------------------------------------------
VIBES Token
T.me/VIBESERC
VIBES aspires to establish a decentralized project where the investor is an active contributor to the project. All investors in the pack will be working together to reach the moon and beyond. Every investor is able to vote and create ideas that can improve the ecosystem. Every investor has a chance to build on the project with other contributors.
3% Development
5% Marketing
2% Auto-Liquidity
🔓Contract locked
*/
/**
██████╗░██████╗░░░░ ██████╗░███████╗██╗░░░██╗
██╔══██╗██╔══██╗░░░ ██╔══██╗██╔════╝██║░░░██║
██║░░██║██████╔╝░░░ ██║░░██║█████╗░░╚██╗░██╔╝
██║░░██║██╔══██╗░░░ ██║░░██║██╔══╝░░░╚████╔╝░
██████╔╝██║░░██║██╗ ██████╔╝███████╗░░╚██╔╝░░
╚═════╝░╚═╝░░╚═╝╚═╝ ╚═════╝░╚══════╝░░░╚═╝░░░
t.me/doctordevv
t.me/drdevcalls
*/
// SPDX-License-Identifier: Unlicensed
pragma solidity 0.8.9;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
interface IUniswapV2Pair {
event Approval(address indexed owner, address indexed spender, uint value);
event Transfer(address indexed from, address indexed to, uint value);
function name() external pure returns (string memory);
function symbol() external pure returns (string memory);
function decimals() external pure returns (uint8);
function totalSupply() external view returns (uint);
function balanceOf(address owner) external view returns (uint);
function allowance(address owner, address spender) external view returns (uint);
function approve(address spender, uint value) external returns (bool);
function transfer(address to, uint value) external returns (bool);
function transferFrom(address from, address to, uint value) external returns (bool);
function DOMAIN_SEPARATOR() external view returns (bytes32);
function PERMIT_TYPEHASH() external pure returns (bytes32);
function nonces(address owner) external view returns (uint);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
event Mint(address indexed sender, uint amount0, uint amount1);
event Burn(address indexed sender, uint amount0, uint amount1, address indexed to);
event Swap(
address indexed sender,
uint amount0In,
uint amount1In,
uint amount0Out,
uint amount1Out,
address indexed to
);
event Sync(uint112 reserve0, uint112 reserve1);
function MINIMUM_LIQUIDITY() external pure returns (uint);
function factory() external view returns (address);
function token0() external view returns (address);
function token1() external view returns (address);
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
function price0CumulativeLast() external view returns (uint);
function price1CumulativeLast() external view returns (uint);
function kLast() external view returns (uint);
function mint(address to) external returns (uint liquidity);
function burn(address to) external returns (uint amount0, uint amount1);
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function skim(address to) external;
function sync() external;
function initialize(address, address) external;
}
interface IUniswapV2Factory {
event PairCreated(address indexed token0, address indexed token1, address pair, uint);
function feeTo() external view returns (address);
function feeToSetter() external view returns (address);
function getPair(address tokenA, address tokenB) external view returns (address pair);
function allPairs(uint) external view returns (address pair);
function allPairsLength() external view returns (uint);
function createPair(address tokenA, address tokenB) external returns (address pair);
function setFeeTo(address) external;
function setFeeToSetter(address) external;
}
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
contract ERC20 is Context, IERC20, IERC20Metadata {
using SafeMath for uint256;
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
library SafeMathInt {
int256 private constant MIN_INT256 = int256(1) << 255;
int256 private constant MAX_INT256 = ~(int256(1) << 255);
/**
* @dev Multiplies two int256 variables and fails on overflow.
*/
function mul(int256 a, int256 b) internal pure returns (int256) {
int256 c = a * b;
// Detect overflow when multiplying MIN_INT256 with -1
require(c != MIN_INT256 || (a & MIN_INT256) != (b & MIN_INT256));
require((b == 0) || (c / b == a));
return c;
}
/**
* @dev Division of two int256 variables and fails on overflow.
*/
function div(int256 a, int256 b) internal pure returns (int256) {
// Prevent overflow when dividing MIN_INT256 by -1
require(b != -1 || a != MIN_INT256);
// Solidity already throws when dividing by 0.
return a / b;
}
/**
* @dev Subtracts two int256 variables and fails on overflow.
*/
function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a));
return c;
}
/**
* @dev Adds two int256 variables and fails on overflow.
*/
function add(int256 a, int256 b) internal pure returns (int256) {
int256 c = a + b;
require((b >= 0 && c >= a) || (b < 0 && c < a));
return c;
}
/**
* @dev Converts to absolute value, and fails on overflow.
*/
function abs(int256 a) internal pure returns (int256) {
require(a != MIN_INT256);
return a < 0 ? -a : a;
}
function toUint256Safe(int256 a) internal pure returns (uint256) {
require(a >= 0);
return uint256(a);
}
}
library SafeMathUint {
function toInt256Safe(uint256 a) internal pure returns (int256) {
int256 b = int256(a);
require(b >= 0);
return b;
}
}
interface IUniswapV2Router01 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB, uint liquidity);
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external payable returns (uint amountToken, uint amountETH, uint liquidity);
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external returns (uint amountA, uint amountB);
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountToken, uint amountETH);
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountA, uint amountB);
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountToken, uint amountETH);
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external returns (uint[] memory amounts);
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
returns (uint[] memory amounts);
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
payable
returns (uint[] memory amounts);
function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}
interface IUniswapV2Router02 is IUniswapV2Router01 {
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external returns (uint amountETH);
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external returns (uint amountETH);
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external payable;
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
contract VIBES is ERC20, Ownable {
using SafeMath for uint256;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
address public constant deadAddress = address(0x000000000000000000000000000000000000dEaD);
bool private swapping;
address public marketingWallet;
address public devWallet;
uint256 public maxTransactionAmount;
uint256 public swapTokensAtAmount;
uint256 public maxWallet;
uint256 public percentForLPBurn = 25; // 25 = .25%
bool public lpBurnEnabled = true;
uint256 public lpBurnFrequency = 3600 seconds;
uint256 public lastLpBurnTime;
uint256 public manualBurnFrequency = 30 minutes;
uint256 public lastManualLpBurnTime;
bool public limitsInEffect = true;
bool public tradingActive = false;
bool public swapEnabled = false;
bool public enableEarlySellTax = true;
// Anti-bot and anti-whale mappings and variables
mapping(address => uint256) private _holderLastTransferTimestamp; // to hold last Transfers temporarily during launch
// Seller Map
mapping (address => uint256) private _holderFirstBuyTimestamp;
// Blacklist Map
mapping (address => bool) private _blacklist;
bool public transferDelayEnabled = true;
uint256 public buyTotalFees;
uint256 public buyMarketingFee;
uint256 public buyLiquidityFee;
uint256 public buyDevFee;
uint256 public sellTotalFees;
uint256 public sellMarketingFee;
uint256 public sellLiquidityFee;
uint256 public sellDevFee;
uint256 public earlySellLiquidityFee;
uint256 public earlySellMarketingFee;
uint256 public tokensForMarketing;
uint256 public tokensForLiquidity;
uint256 public tokensForDev;
// block number of opened trading
uint256 launchedAt;
/******************/
// exclude from fees and max transaction amount
mapping (address => bool) private _isExcludedFromFees;
mapping (address => bool) public _isExcludedMaxTransactionAmount;
// store addresses that a automatic market maker pairs. Any transfer *to* these addresses
// could be subject to a maximum transfer amount
mapping (address => bool) public automatedMarketMakerPairs;
event UpdateUniswapV2Router(address indexed newAddress, address indexed oldAddress);
event ExcludeFromFees(address indexed account, bool isExcluded);
event SetAutomatedMarketMakerPair(address indexed pair, bool indexed value);
event marketingWalletUpdated(address indexed newWallet, address indexed oldWallet);
event devWalletUpdated(address indexed newWallet, address indexed oldWallet);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
uint256 tokensIntoLiquidity
);
event AutoNukeLP();
event ManualNukeLP();
constructor() ERC20("VIBES", "VIBES") {
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 = 2;
uint256 _buyDevFee = 3;
uint256 _sellMarketingFee = 5;
uint256 _sellLiquidityFee = 2;
uint256 _sellDevFee = 3;
uint256 _earlySellLiquidityFee = 10;
uint256 _earlySellMarketingFee = 17;
uint256 totalSupply = 1 * 1e11 * 1e18;
maxTransactionAmount = totalSupply * 10 / 1000; // 0.1% maxTransactionAmountTxn
maxWallet = totalSupply * 10 / 1000; // 1.% maxWallet
swapTokensAtAmount = totalSupply * 5 / 10000; // 0.05% swap wallet
buyMarketingFee = _buyMarketingFee;
buyLiquidityFee = _buyLiquidityFee;
buyDevFee = _buyDevFee;
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
sellMarketingFee = _sellMarketingFee;
sellLiquidityFee = _sellLiquidityFee;
sellDevFee = _sellDevFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
earlySellLiquidityFee = _earlySellLiquidityFee;
earlySellMarketingFee = _earlySellMarketingFee;
marketingWallet = address(owner()); // set as marketing wallet
devWallet = address(owner()); // set as dev wallet
// exclude from paying fees or having max transaction amount
excludeFromFees(owner(), true);
excludeFromFees(address(this), true);
excludeFromFees(address(0xdead), true);
excludeFromMaxTransaction(owner(), true);
excludeFromMaxTransaction(address(this), true);
excludeFromMaxTransaction(address(0xdead), true);
/*
_mint is an internal function in ERC20.sol that is only called here,
and CANNOT be called ever again
*/
_mint(msg.sender, totalSupply);
}
receive() external payable {
}
// once enabled, can never be turned off
function enableTrading() external onlyOwner {
tradingActive = true;
swapEnabled = true;
lastLpBurnTime = block.timestamp;
launchedAt = block.number;
}
// remove limits after token is stable
function removeLimits() external onlyOwner returns (bool){
limitsInEffect = false;
return true;
}
// disable Transfer delay - cannot be reenabled
function disableTransferDelay() external onlyOwner returns (bool){
transferDelayEnabled = false;
return true;
}
function setEarlySellTax(bool onoff) external onlyOwner {
enableEarlySellTax = onoff;
}
// change the minimum amount of tokens to sell from fees
function updateSwapTokensAtAmount(uint256 newAmount) external onlyOwner returns (bool){
require(newAmount >= totalSupply() * 1 / 100000, "Swap amount cannot be lower than 0.001% total supply.");
require(newAmount <= totalSupply() * 5 / 1000, "Swap amount cannot be higher than 0.5% total supply.");
swapTokensAtAmount = newAmount;
return true;
}
function updateMaxTxnAmount(uint256 newNum) external onlyOwner {
require(newNum >= (totalSupply() * 1 / 1000)/1e18, "Cannot set maxTransactionAmount lower than 0.1%");
maxTransactionAmount = newNum * (10**18);
}
function updateMaxWalletAmount(uint256 newNum) external onlyOwner {
require(newNum >= (totalSupply() * 5 / 1000)/1e18, "Cannot set maxWallet lower than 0.5%");
maxWallet = newNum * (10**18);
}
function excludeFromMaxTransaction(address updAds, bool isEx) public onlyOwner {
_isExcludedMaxTransactionAmount[updAds] = isEx;
}
// only use to disable contract sales if absolutely necessary (emergency use only)
function updateSwapEnabled(bool enabled) external onlyOwner(){
swapEnabled = enabled;
}
function updateBuyFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee) external onlyOwner {
buyMarketingFee = _marketingFee;
buyLiquidityFee = _liquidityFee;
buyDevFee = _devFee;
buyTotalFees = buyMarketingFee + buyLiquidityFee + buyDevFee;
require(buyTotalFees <= 20, "Must keep fees at 20% or less");
}
function updateSellFees(uint256 _marketingFee, uint256 _liquidityFee, uint256 _devFee, uint256 _earlySellLiquidityFee, uint256 _earlySellMarketingFee) external onlyOwner {
sellMarketingFee = _marketingFee;
sellLiquidityFee = _liquidityFee;
sellDevFee = _devFee;
earlySellLiquidityFee = _earlySellLiquidityFee;
earlySellMarketingFee = _earlySellMarketingFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
require(sellTotalFees <= 25, "Must keep fees at 25% or less");
}
function excludeFromFees(address account, bool excluded) public onlyOwner {
_isExcludedFromFees[account] = excluded;
emit ExcludeFromFees(account, excluded);
}
function blacklistAccount (address[] calldata accounts, bool[] calldata isBlacklisted) public onlyOwner {
for (uint256 i = 0; i < accounts.length; i++){
address account = accounts[i];
_blacklist[account] = isBlacklisted[i];
}
}
function setAutomatedMarketMakerPair(address pair, bool value) public onlyOwner {
require(pair != uniswapV2Pair, "The pair cannot be removed from automatedMarketMakerPairs");
_setAutomatedMarketMakerPair(pair, value);
}
function _setAutomatedMarketMakerPair(address pair, bool value) private {
automatedMarketMakerPairs[pair] = value;
emit SetAutomatedMarketMakerPair(pair, value);
}
function updateMarketingWallet(address newMarketingWallet) external onlyOwner {
emit marketingWalletUpdated(newMarketingWallet, marketingWallet);
marketingWallet = newMarketingWallet;
}
function updateDevWallet(address newWallet) external onlyOwner {
emit devWalletUpdated(newWallet, devWallet);
devWallet = newWallet;
}
function isExcludedFromFees(address account) public view returns(bool) {
return _isExcludedFromFees[account];
}
event BoughtEarly(address indexed sniper);
function _transfer(
address from,
address to,
uint256 amount
) internal override {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(!_blacklist[to] && !_blacklist[from], "You have been blacklisted from transfering tokens");
if(amount == 0) {
super._transfer(from, to, 0);
return;
}
if(limitsInEffect){
if (
from != owner() &&
to != owner() &&
to != address(0) &&
to != address(0xdead) &&
!swapping
){
if(!tradingActive){
require(_isExcludedFromFees[from] || _isExcludedFromFees[to], "Trading is not active.");
}
// at launch if the transfer delay is enabled, ensure the block timestamps for purchasers is set -- during launch.
if (transferDelayEnabled){
if (to != owner() && to != address(uniswapV2Router) && to != address(uniswapV2Pair)){
require(_holderLastTransferTimestamp[tx.origin] < block.number, "_transfer:: Transfer Delay enabled. Only one purchase per block allowed.");
_holderLastTransferTimestamp[tx.origin] = block.number;
}
}
//when buy
if (automatedMarketMakerPairs[from] && !_isExcludedMaxTransactionAmount[to]) {
require(amount <= maxTransactionAmount, "Buy transfer amount exceeds the maxTransactionAmount.");
require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded");
}
//when sell
else if (automatedMarketMakerPairs[to] && !_isExcludedMaxTransactionAmount[from]) {
require(amount <= maxTransactionAmount, "Sell transfer amount exceeds the maxTransactionAmount.");
}
else if(!_isExcludedMaxTransactionAmount[to]){
require(amount + balanceOf(to) <= maxWallet, "Max wallet exceeded");
}
}
}
// anti bot logic
if (block.number <= (launchedAt + 1) &&
to != uniswapV2Pair &&
to != address(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D)
) {
_blacklist[to] = true;
}
// early sell logic
bool isBuy = from == uniswapV2Pair;
if (!isBuy && enableEarlySellTax) {
if (_holderFirstBuyTimestamp[from] != 0 &&
(_holderFirstBuyTimestamp[from] + (24 hours) >= block.timestamp)) {
sellLiquidityFee = earlySellLiquidityFee;
sellMarketingFee = earlySellMarketingFee;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
} else {
sellLiquidityFee = 2;
sellMarketingFee = 5;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
}
} else {
if (_holderFirstBuyTimestamp[to] == 0) {
_holderFirstBuyTimestamp[to] = block.timestamp;
}
if (!enableEarlySellTax) {
sellLiquidityFee = 2;
sellMarketingFee = 5;
sellTotalFees = sellMarketingFee + sellLiquidityFee + sellDevFee;
}
}
uint256 contractTokenBalance = balanceOf(address(this));
bool canSwap = contractTokenBalance >= swapTokensAtAmount;
if(
canSwap &&
swapEnabled &&
!swapping &&
!automatedMarketMakerPairs[from] &&
!_isExcludedFromFees[from] &&
!_isExcludedFromFees[to]
) {
swapping = true;
swapBack();
swapping = false;
}
if(!swapping && automatedMarketMakerPairs[to] && lpBurnEnabled && block.timestamp >= lastLpBurnTime + lpBurnFrequency && !_isExcludedFromFees[from]){
autoBurnLiquidityPairTokens();
}
bool takeFee = !swapping;
// if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
takeFee = false;
}
uint256 fees = 0;
// only take fees on buys/sells, do not take on wallet transfers
if(takeFee){
// on sell
if (automatedMarketMakerPairs[to] && sellTotalFees > 0){
fees = amount.mul(sellTotalFees).div(100);
tokensForLiquidity += fees * sellLiquidityFee / sellTotalFees;
tokensForDev += fees * sellDevFee / sellTotalFees;
tokensForMarketing += fees * sellMarketingFee / sellTotalFees;
}
// on buy
else if(automatedMarketMakerPairs[from] && buyTotalFees > 0) {
fees = amount.mul(buyTotalFees).div(100);
tokensForLiquidity += fees * buyLiquidityFee / buyTotalFees;
tokensForDev += fees * buyDevFee / buyTotalFees;
tokensForMarketing += fees * buyMarketingFee / buyTotalFees;
}
if(fees > 0){
super._transfer(from, address(this), fees);
}
amount -= fees;
}
super._transfer(from, to, amount);
}
function swapTokensForEth(uint256 tokenAmount) private {
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function addLiquidity(uint256 tokenAmount, uint256 ethAmount) private {
// approve token transfer to cover all possible scenarios
_approve(address(this), address(uniswapV2Router), tokenAmount);
// add the liquidity
uniswapV2Router.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
0, // slippage is unavoidable
0, // slippage is unavoidable
deadAddress,
block.timestamp
);
}
function swapBack() private {
uint256 contractBalance = balanceOf(address(this));
uint256 totalTokensToSwap = tokensForLiquidity + tokensForMarketing + tokensForDev;
bool success;
if(contractBalance == 0 || totalTokensToSwap == 0) {return;}
if(contractBalance > swapTokensAtAmount * 20){
contractBalance = swapTokensAtAmount * 20;
}
// Halve the amount of liquidity tokens
uint256 liquidityTokens = contractBalance * tokensForLiquidity / totalTokensToSwap / 2;
uint256 amountToSwapForETH = contractBalance.sub(liquidityTokens);
uint256 initialETHBalance = address(this).balance;
swapTokensForEth(amountToSwapForETH);
uint256 ethBalance = address(this).balance.sub(initialETHBalance);
uint256 ethForMarketing = ethBalance.mul(tokensForMarketing).div(totalTokensToSwap);
uint256 ethForDev = ethBalance.mul(tokensForDev).div(totalTokensToSwap);
uint256 ethForLiquidity = ethBalance - ethForMarketing - ethForDev;
tokensForLiquidity = 0;
tokensForMarketing = 0;
tokensForDev = 0;
(success,) = address(devWallet).call{value: ethForDev}("");
if(liquidityTokens > 0 && ethForLiquidity > 0){
addLiquidity(liquidityTokens, ethForLiquidity);
emit SwapAndLiquify(amountToSwapForETH, ethForLiquidity, tokensForLiquidity);
}
(success,) = address(marketingWallet).call{value: address(this).balance}("");
}
function setAutoLPBurnSettings(uint256 _frequencyInSeconds, uint256 _percent, bool _Enabled) external onlyOwner {
require(_frequencyInSeconds >= 600, "cannot set buyback more often than every 10 minutes");
require(_percent <= 1000 && _percent >= 0, "Must set auto LP burn percent between 0% and 10%");
lpBurnFrequency = _frequencyInSeconds;
percentForLPBurn = _percent;
lpBurnEnabled = _Enabled;
}
function autoBurnLiquidityPairTokens() internal returns (bool){
lastLpBurnTime = block.timestamp;
// get balance of liquidity pair
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
// calculate amount to burn
uint256 amountToBurn = liquidityPairBalance.mul(percentForLPBurn).div(10000);
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0){
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
}
//sync price since this is not in a swap transaction!
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit AutoNukeLP();
return true;
}
function manualBurnLiquidityPairTokens(uint256 percent) external onlyOwner returns (bool){
require(block.timestamp > lastManualLpBurnTime + manualBurnFrequency , "Must wait for cooldown to finish");
require(percent <= 1000, "May not nuke more than 10% of tokens in LP");
lastManualLpBurnTime = block.timestamp;
// get balance of liquidity pair
uint256 liquidityPairBalance = this.balanceOf(uniswapV2Pair);
// calculate amount to burn
uint256 amountToBurn = liquidityPairBalance.mul(percent).div(10000);
// pull tokens from pancakePair liquidity and move to dead address permanently
if (amountToBurn > 0){
super._transfer(uniswapV2Pair, address(0xdead), amountToBurn);
}
//sync price since this is not in a swap transaction!
IUniswapV2Pair pair = IUniswapV2Pair(uniswapV2Pair);
pair.sync();
emit ManualNukeLP();
return true;
}
} | [] | [{"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"VIBES.sol": [905]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"VIBES.sol": [704, 705, 699, 700, 701, 702, 703]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"VIBES.sol": [728, 729, 730, 731]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"VIBES.sol": [741, 742, 743, 744, 745]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"VIBES.sol": [687, 688, 689, 690, 691, 692, 693, 694]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"VIBES.sol": [427, 428, 429, 430, 431, 432, 433, 434, 435]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"VIBES.sol": [620, 621, 622, 623]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"VIBES.sol": [736, 737, 734, 735]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"VIBES.sol": [710, 711, 712, 713, 714]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"VIBES.sol": [40, 41, 42, 39]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"VIBES.sol": [604, 605, 606]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"VIBES.sol": [719, 720, 721, 722, 723]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"VIBES.sol": [1271]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"VIBES.sol": [1273]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"VIBES.sol": [1266]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"VIBES.sol": [1272]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"VIBES.sol": [1274]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"VIBES.sol": [1265]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"VIBES.sol": [322, 323, 324, 325, 326, 327, 328, 329, 330]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"VIBES.sol": [664, 665, 662, 663]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"VIBES.sol": [259, 260, 261]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"VIBES.sol": [363, 364, 365, 366]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"VIBES.sol": [242, 243, 244]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"VIBES.sol": [288, 285, 286, 287]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"VIBES.sol": [344, 345, 346, 347]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"VIBES.sol": [672, 673, 674, 675, 671]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"VIBES.sol": [1111, 1112, 1113, 1114, 1115, 1116]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"VIBES.sol": [234, 235, 236]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"VIBES.sol": [1120, 1121, 1122, 1118, 1119]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"VIBES.sol": [1141, 1142, 1143]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"VIBES.sol": [304, 305, 306, 307]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"VIBES.sol": [293, 294, 295]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [32]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"VIBES.sol": [1329]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"VIBES.sol": [116]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [1364]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"VIBES.sol": [1371]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"VIBES.sol": [1071]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"VIBES.sol": [1076]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"VIBES.sol": [1065]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"VIBES.sol": [1092]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"VIBES.sol": [1102]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"VIBES.sol": [1137]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"VIBES.sol": [1132]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [1088]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [1096]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [1088]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [1096]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [61]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [78]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [1367]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [60]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [1367]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [961]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [1096]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [959]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [1096]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [1096]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [751]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [1367]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [1088]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [889]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [947]}}, {"check": "redundant-statements", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [34, 35, 36, 37, 38, 39, 40, 41, 42, 43]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"VIBES.sol": [458]}}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium", "lines": {"VIBES.sol": [1274]}}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium", "lines": {"VIBES.sol": [1245]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"VIBES.sol": [1360]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"VIBES.sol": [1393]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"VIBES.sol": [1416]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"VIBES.sol": [1249]}}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium", "lines": {"VIBES.sol": [1353]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"VIBES.sol": [757]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"VIBES.sol": [1248]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"VIBES.sol": [1398]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"VIBES.sol": [889]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"VIBES.sol": [1063]}}, {"check": "tx-origin", "impact": "Medium", "confidence": "Medium", "lines": {"VIBES.sol": [1175]}}, {"check": "tautology", "impact": "Medium", "confidence": "High", "lines": {"VIBES.sol": [1369]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"VIBES.sol": [1314, 1315, 1316, 1317, 1318, 1319, 1320, 1321]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"VIBES.sol": [680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 889, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 975, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1020, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1024, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 409, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 430, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 664, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 304, "severity": 2}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 208, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 210, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 212, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 214, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 215, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 627, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 681, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 682, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 891, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 914, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 917, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 920, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 946, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 206, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 885, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 82, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 88, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 762, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 770, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 779, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 787, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 797, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 806, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 39, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 226, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 634, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 807, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 814, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 821, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 825, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 828, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 831, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 862, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 869, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 875, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 973, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 810, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 811, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 812, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 813, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 817, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 818, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 819, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 820, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 821, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 821, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 821, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 824, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 825, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 825, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 825, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 827, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 828, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 828, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 828, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 830, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 831, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 831, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 831, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 834, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 865, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 866, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 867, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 871, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 872, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 873, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 878, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 879, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 880, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 941, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1033, "severity": 1}] | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[],"name":"AutoNukeLP","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sniper","type":"address"}],"name":"BoughtEarly","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bool","name":"isExcluded","type":"bool"}],"name":"ExcludeFromFees","type":"event"},{"anonymous":false,"inputs":[],"name":"ManualNukeLP","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"pair","type":"address"},{"indexed":true,"internalType":"bool","name":"value","type":"bool"}],"name":"SetAutomatedMarketMakerPair","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokensSwapped","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"ethReceived","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"tokensIntoLiquidity","type":"uint256"}],"name":"SwapAndLiquify","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newAddress","type":"address"},{"indexed":true,"internalType":"address","name":"oldAddress","type":"address"}],"name":"UpdateUniswapV2Router","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newWallet","type":"address"},{"indexed":true,"internalType":"address","name":"oldWallet","type":"address"}],"name":"devWalletUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newWallet","type":"address"},{"indexed":true,"internalType":"address","name":"oldWallet","type":"address"}],"name":"marketingWalletUpdated","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"_isExcludedMaxTransactionAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"automatedMarketMakerPairs","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"bool[]","name":"isBlacklisted","type":"bool[]"}],"name":"blacklistAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"buyDevFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"buyLiquidityFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"buyMarketingFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"buyTotalFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"deadAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"devWallet","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"disableTransferDelay","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"earlySellLiquidityFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"earlySellMarketingFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"enableEarlySellTax","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"enableTrading","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bool","name":"excluded","type":"bool"}],"name":"excludeFromFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"updAds","type":"address"},{"internalType":"bool","name":"isEx","type":"bool"}],"name":"excludeFromMaxTransaction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"isExcludedFromFees","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastLpBurnTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastManualLpBurnTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"limitsInEffect","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpBurnEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpBurnFrequency","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manualBurnFrequency","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"percent","type":"uint256"}],"name":"manualBurnLiquidityPairTokens","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"marketingWallet","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxTransactionAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxWallet","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"percentForLPBurn","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"removeLimits","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sellDevFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sellLiquidityFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sellMarketingFee","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"sellTotalFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_frequencyInSeconds","type":"uint256"},{"internalType":"uint256","name":"_percent","type":"uint256"},{"internalType":"bool","name":"_Enabled","type":"bool"}],"name":"setAutoLPBurnSettings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"pair","type":"address"},{"internalType":"bool","name":"value","type":"bool"}],"name":"setAutomatedMarketMakerPair","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"onoff","type":"bool"}],"name":"setEarlySellTax","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"swapTokensAtAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokensForDev","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokensForLiquidity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokensForMarketing","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tradingActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"transferDelayEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"uniswapV2Pair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"uniswapV2Router","outputs":[{"internalType":"contract IUniswapV2Router02","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_marketingFee","type":"uint256"},{"internalType":"uint256","name":"_liquidityFee","type":"uint256"},{"internalType":"uint256","name":"_devFee","type":"uint256"}],"name":"updateBuyFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newWallet","type":"address"}],"name":"updateDevWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newMarketingWallet","type":"address"}],"name":"updateMarketingWallet","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newNum","type":"uint256"}],"name":"updateMaxTxnAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newNum","type":"uint256"}],"name":"updateMaxWalletAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_marketingFee","type":"uint256"},{"internalType":"uint256","name":"_liquidityFee","type":"uint256"},{"internalType":"uint256","name":"_devFee","type":"uint256"},{"internalType":"uint256","name":"_earlySellLiquidityFee","type":"uint256"},{"internalType":"uint256","name":"_earlySellMarketingFee","type":"uint256"}],"name":"updateSellFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"enabled","type":"bool"}],"name":"updateSwapEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newAmount","type":"uint256"}],"name":"updateSwapTokensAtAmount","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}] | v0.8.9+commit.e5eed63a | true | 5,000 | Default | MIT | false | ipfs://c583c8ab7bb661995b1632e15075bae752453edb4ebc43258f6500db68f7eb95 |
|||
rizex | 0xeeda12dbe073b244470127c92cdca516c347a4e9 | Solidity | pragma solidity ^0.4.21;
contract rizex {
uint256 totalSupply_;
string public constant name = "rizex";
string public constant symbol = "REX";
uint8 public constant decimals = 18;
uint256 public constant initialSupply = 25000000*(10**uint256(decimals));
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
function totalSupply() public view returns (uint256){
return totalSupply_;
}
function balanceOf(address _owner) public view returns (uint256){
return balances[_owner];
}
function allowance(address _owner, address _spender) public view returns (uint256) {
return allowed[_owner][_spender];
}
function transfer(address _to, uint256 _value) public returns (bool ) {
require(_to != address(0));
require(balances[msg.sender] >= _value);
balances[msg.sender] = balances[msg.sender] - _value;
balances[_to] = balances[_to] + _value;
emit Transfer(msg.sender, _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 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] - _value;
balances[_to] = balances[_to] + _value;
allowed[_from][msg.sender] = allowed[_from][msg.sender] - _value;
emit Transfer(_from, _to, _value);
return true;
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender] + _addedValue;
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
}
else {
allowed[msg.sender][_spender] = oldValue - _subtractedValue;
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function rizex() public {
totalSupply_ = initialSupply;
balances[msg.sender] = initialSupply;
emit Transfer(0x0, msg.sender, initialSupply);
}
} | [{"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["6", "7"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["56", "33", "32", "68", "50", "49", "48", "9"]}] | [{"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"rizex.sol": [32, 33, 34, 35, 36, 29, 30, 31]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"rizex.sol": [44, 45, 46, 47, 48, 49, 50, 51, 52, 53]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"rizex.sol": [64, 65, 66, 67, 68, 69, 70, 71, 72, 61, 62, 63]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"rizex.sol": [55, 56, 57, 58, 59]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"rizex.sol": [21, 22, 23]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"rizex.sol": [25, 26, 27]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"rizex.sol": [38, 39, 40, 41, 42]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"rizex.sol": [17, 18, 19]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"rizex.sol": [1]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"rizex.sol": [38]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"rizex.sol": [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"rizex.sol": [55]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"rizex.sol": [25]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"rizex.sol": [61]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"rizex.sol": [44]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"rizex.sol": [21]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"rizex.sol": [44]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"rizex.sol": [29]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"rizex.sol": [38]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"rizex.sol": [25]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"rizex.sol": [61]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"rizex.sol": [9]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"rizex.sol": [29]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"rizex.sol": [55]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"rizex.sol": [44]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"rizex.sol": [9]}}] | [{"error": "Integer Overflow.", "line": 56, "level": "Warning"}, {"error": "Integer Overflow.", "line": 33, "level": "Warning"}, {"error": "Integer Overflow.", "line": 49, "level": "Warning"}] | [{"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 5, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 14, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 15, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"initialSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_subtractedValue","type":"uint256"}],"name":"decreaseApproval","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_addedValue","type":"uint256"}],"name":"increaseApproval","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"}] | v0.4.21+commit.dfe3193c | false | 200 | Default | None | false | bzzr://390e928f8e8d8a64f030d18b31c4a2937430736af6cc2b6885c56e6a4d8104dc |
|||
Plant_your_tree_NFT | 0x95eedffbad48e437962cf00e8a969db845dbe348 | Solidity | // SPDX-License-Identifier: MIT
// File: @openzeppelin/contracts/utils/Counters.sol
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)
pragma solidity ^0.8.0;
/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
*/
library Counters {
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}
// File: @openzeppelin/contracts/utils/Strings.sol
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// File: @openzeppelin/contracts/utils/Context.sol
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// File: @openzeppelin/contracts/access/Ownable.sol
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// File: @openzeppelin/contracts/utils/Address.sol
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// File: @openzeppelin/contracts/utils/introspection/ERC165.sol
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
// File: @openzeppelin/contracts/token/ERC721/IERC721.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
// File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
// File: @openzeppelin/contracts/token/ERC721/ERC721.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
// File: contracts/Plant_your_tree_NFT.sol
pragma solidity >=0.7.0 <0.9.0;
contract Plant_your_tree_NFT is ERC721, Ownable {
using Strings for uint256;
using Counters for Counters.Counter;
Counters.Counter private supply;
string public uriPrefix = "";
string public uriSuffix = ".json";
string public hiddenMetadataUri;
uint256 public cost = 0.07 ether;
uint256 public maxSupply = 7777;
uint256 public maxMintAmountPerTx = 10;
bool public paused = false;
bool public revealed = false;
constructor() ERC721("Plant your tree NFT", "PYT") {
setHiddenMetadataUri("ipfs://QmcVoakuCzGD9CRLaX3jhSUfcskDze3UkiamBN58Cppd6Q/hidden.json");
}
modifier mintCompliance(uint256 _mintAmount) {
require(_mintAmount > 0 && _mintAmount <= maxMintAmountPerTx, "Invalid mint amount!");
require(supply.current() + _mintAmount <= maxSupply, "Max supply exceeded!");
_;
}
function totalSupply() public view returns (uint256) {
return supply.current();
}
function mint(uint256 _mintAmount) public payable mintCompliance(_mintAmount) {
require(!paused, "The contract is paused!");
require(msg.value >= cost * _mintAmount, "Insufficient funds!");
_mintLoop(msg.sender, _mintAmount);
}
function mintForAddress(uint256 _mintAmount, address _receiver) public mintCompliance(_mintAmount) onlyOwner {
_mintLoop(_receiver, _mintAmount);
}
function walletOfOwner(address _owner)
public
view
returns (uint256[] memory)
{
uint256 ownerTokenCount = balanceOf(_owner);
uint256[] memory ownedTokenIds = new uint256[](ownerTokenCount);
uint256 currentTokenId = 1;
uint256 ownedTokenIndex = 0;
while (ownedTokenIndex < ownerTokenCount && currentTokenId <= maxSupply) {
address currentTokenOwner = ownerOf(currentTokenId);
if (currentTokenOwner == _owner) {
ownedTokenIds[ownedTokenIndex] = currentTokenId;
ownedTokenIndex++;
}
currentTokenId++;
}
return ownedTokenIds;
}
function tokenURI(uint256 _tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(_tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if (revealed == false) {
return hiddenMetadataUri;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length > 0
? string(abi.encodePacked(currentBaseURI, _tokenId.toString(), uriSuffix))
: "";
}
function setRevealed(bool _state) public onlyOwner {
revealed = _state;
}
function setCost(uint256 _cost) public onlyOwner {
cost = _cost;
}
function setMaxMintAmountPerTx(uint256 _maxMintAmountPerTx) public onlyOwner {
maxMintAmountPerTx = _maxMintAmountPerTx;
}
function setHiddenMetadataUri(string memory _hiddenMetadataUri) public onlyOwner {
hiddenMetadataUri = _hiddenMetadataUri;
}
function setUriPrefix(string memory _uriPrefix) public onlyOwner {
uriPrefix = _uriPrefix;
}
function setUriSuffix(string memory _uriSuffix) public onlyOwner {
uriSuffix = _uriSuffix;
}
function setPaused(bool _state) public onlyOwner {
paused = _state;
}
function withdraw() public onlyOwner {
(bool os, ) = payable(owner()).call{value: address(this).balance}("");
require(os);
}
function _mintLoop(address _receiver, uint256 _mintAmount) internal {
for (uint256 i = 0; i < _mintAmount; i++) {
supply.increment();
_safeMint(_receiver, supply.current());
}
}
function _baseURI() internal view virtual override returns (string memory) {
return uriPrefix;
}
} | [{"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["1265"]}, {"defect": "DelegateCall", "type": "Function_call", "severity": "High", "lines": ["411"]}, {"defect": "Frozen_Ether", "type": "Code_specification", "severity": "Medium", "lines": ["1142"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["218", "72", "1191", "1192", "94"]}, {"defect": "Balance_manipulation", "type": "Business_logic", "severity": "Medium", "lines": ["770"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["204", "1184", "565", "774", "178", "193", "1079"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["993", "1017", "1048", "1047"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1104, 1102, 1103]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [433, 434, 435, 436]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [258, 259, 260]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1221]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1153]}}, {"check": "pragma", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1137]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Plant_your_tree_NFT.sol": [421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Plant_your_tree_NFT.sol": [106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Plant_your_tree_NFT.sol": [280, 281, 282, 283, 284, 285]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Plant_your_tree_NFT.sol": [334, 335, 336, 337, 338, 339, 340]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Plant_your_tree_NFT.sol": [404, 405, 406, 407, 408, 409, 410, 411, 412, 413]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Plant_your_tree_NFT.sol": [96, 97, 98, 99, 100, 101, 90, 91, 92, 93, 94, 95]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Plant_your_tree_NFT.sol": [1009, 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020, 1021]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Plant_your_tree_NFT.sol": [394, 395, 396]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Plant_your_tree_NFT.sol": [44, 45, 46]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Plant_your_tree_NFT.sol": [352, 353, 354, 355, 356, 357, 358, 359, 348, 349, 350, 351]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Plant_your_tree_NFT.sol": [36, 37, 38, 39, 40, 41, 42]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Plant_your_tree_NFT.sol": [141, 142, 143]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Plant_your_tree_NFT.sol": [368, 369, 367]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Plant_your_tree_NFT.sol": [812, 813, 814]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Plant_your_tree_NFT.sol": [320, 321, 315, 316, 317, 318, 319]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Plant_your_tree_NFT.sol": [384, 385, 386, 377, 378, 379, 380, 381, 382, 383]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"Plant_your_tree_NFT.sol": [305, 306, 307]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1232, 1233, 1231]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1248, 1249, 1247]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1240, 1241, 1239]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [793, 794, 795]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [200, 201, 202]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1235, 1236, 1237]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1259, 1260, 1261, 1262]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [871, 872, 873, 874, 875, 876, 877]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1209, 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1251, 1252, 1253]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [864, 865, 866, 857, 858, 859, 860, 861, 862, 863]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [208, 209, 210, 211]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [786, 787, 788]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1173, 1174, 1175, 1176, 1177, 1178]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1169, 1170, 1171]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1256, 1257, 1255]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1180, 1181, 1182]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [843, 844, 845]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [683]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [479]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [8]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1137]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [507]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [151]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [449]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [54]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [229]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [712]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [538]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [124]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [167]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [357]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [411]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1260]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [384]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [283]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1184]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [886]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1209]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1231]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1247]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1170, 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271, 1272, 1273, 1274, 1275]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1180]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1251]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1255]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1239]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1173]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1235]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1243]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1180]}}, {"check": "variable-scope", "impact": "Low", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1097]}}, {"check": "variable-scope", "impact": "Low", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1099]}}, {"check": "variable-scope", "impact": "Low", "confidence": "High", "lines": {"Plant_your_tree_NFT.sol": [1103]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"Plant_your_tree_NFT.sol": [1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 111, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 201, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 970, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 991, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1012, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1015, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1045, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 1194, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 1194, "severity": 1}, {"rule": "SOLIDITY_LOCKED_MONEY", "line": 1142, "severity": 3}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 1231, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 1235, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 1239, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 1243, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 1247, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 1251, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 1255, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 8, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 54, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 124, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 151, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 229, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 449, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 479, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 507, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 538, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 683, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 712, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1137, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1137, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 60, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 167, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 731, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 734, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 737, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 740, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 743, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 746, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1146, "severity": 1}, {"rule": "SOLIDITY_REVERT_REQUIRE", "line": 1099, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 252, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 141, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 1102, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 174, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 280, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 751, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1159, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 280, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 280, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 281, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 281, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 281, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 281, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 283, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 283, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 283, "severity": 1}] | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"hiddenMetadataUri","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxMintAmountPerTx","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_mintAmount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_mintAmount","type":"uint256"},{"internalType":"address","name":"_receiver","type":"address"}],"name":"mintForAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"revealed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_cost","type":"uint256"}],"name":"setCost","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_hiddenMetadataUri","type":"string"}],"name":"setHiddenMetadataUri","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_maxMintAmountPerTx","type":"uint256"}],"name":"setMaxMintAmountPerTx","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_state","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_state","type":"bool"}],"name":"setRevealed","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_uriPrefix","type":"string"}],"name":"setUriPrefix","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_uriSuffix","type":"string"}],"name":"setUriSuffix","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"uriPrefix","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"uriSuffix","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"walletOfOwner","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}] | v0.8.7+commit.e28d00a7 | false | 200 | Default | MIT | false | ipfs://6c965492a64a3cf16e3398614d3a2875ef4e7fd4d51fe265eea9049023165873 |
|||
SmartpoolVersion | 0x09077d92f7a71ae3c4eac8dc9f35ce9aa5a06f7b | Solidity | pragma solidity ^0.4.8;
contract SmartpoolVersion {
address public poolContract;
bytes32 public clientVersion;
mapping (address=>bool) owners;
function SmartpoolVersion( address[3] _owners ) {
owners[_owners[0]] = true;
owners[_owners[1]] = true;
owners[_owners[2]] = true;
}
function updatePoolContract( address newAddress ) {
if( ! owners[msg.sender] ) throw;
poolContract = newAddress;
}
function updateClientVersion( bytes32 version ) {
if( ! owners[msg.sender] ) throw;
clientVersion = version;
}
} | [{"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["9", "9", "9"]}] | [{"check": "deprecated-standards", "impact": "Informational", "confidence": "High", "lines": {"SmartpoolVersion.sol": [16]}}, {"check": "deprecated-standards", "impact": "Informational", "confidence": "High", "lines": {"SmartpoolVersion.sol": [22]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SmartpoolVersion.sol": [15, 16, 17, 18, 19]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"SmartpoolVersion.sol": [21, 22, 23, 24, 25]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"SmartpoolVersion.sol": [1]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"SmartpoolVersion.sol": [18]}}] | [] | [{"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 16, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 22, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_REVERT_REQUIRE", "line": 16, "severity": 1}, {"rule": "SOLIDITY_REVERT_REQUIRE", "line": 22, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 9, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 15, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 21, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 7, "severity": 1}] | [{"constant":false,"inputs":[{"name":"version","type":"bytes32"}],"name":"updateClientVersion","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"clientVersion","outputs":[{"name":"","type":"bytes32"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"poolContract","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"newAddress","type":"address"}],"name":"updatePoolContract","outputs":[],"payable":false,"type":"function"},{"inputs":[{"name":"_owners","type":"address[3]"}],"payable":false,"type":"constructor"}] | v0.4.11+commit.68ef5810 | true | 200 | 000000000000000000000000f214dde57f32f3f34492ba3148641693058d4a9e000000000000000000000000c8a1dab586dee8a30cb88c87b8a3614e0a391fc50000000000000000000000002be2f917397bacfb3c939f6db3bee80aa606ae31 | Default | false | bzzr://fe82205a4553c427e7c48d2ee841383bfb33f706480418960eb9385a74e20ac2 |
|||
PaceArtStore | 0xa3f0cc54e581053cb8af56cbe0e568d66445fe1e | Solidity | // File: @openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../utils/ContextUpgradeable.sol";
import "../proxy/Initializable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
function __Ownable_init() internal initializer {
__Context_init_unchained();
__Ownable_init_unchained();
}
function __Ownable_init_unchained() internal initializer {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
uint256[49] private __gap;
}
// File: @openzeppelin/contracts-upgradeable/introspection/ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "./IERC165Upgradeable.sol";
import "../proxy/Initializable.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts may inherit from this and call {_registerInterface} to declare
* their support of an interface.
*/
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
/*
* bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
*/
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/**
* @dev Mapping of interface ids to whether or not it's supported.
*/
mapping(bytes4 => bool) private _supportedInterfaces;
function __ERC165_init() internal initializer {
__ERC165_init_unchained();
}
function __ERC165_init_unchained() internal initializer {
// Derived contracts need only register support for their own interfaces,
// we register support for ERC165 itself here
_registerInterface(_INTERFACE_ID_ERC165);
}
/**
* @dev See {IERC165-supportsInterface}.
*
* Time complexity O(1), guaranteed to always use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return _supportedInterfaces[interfaceId];
}
/**
* @dev Registers the contract as an implementer of the interface defined by
* `interfaceId`. Support of the actual ERC165 interface is automatic and
* registering its interface id is not required.
*
* See {IERC165-supportsInterface}.
*
* Requirements:
*
* - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
*/
function _registerInterface(bytes4 interfaceId) internal virtual {
require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true;
}
uint256[49] private __gap;
}
// File: @openzeppelin/contracts-upgradeable/introspection/IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165Upgradeable {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// File: @openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMathUpgradeable {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b > a) return (false, 0);
return (true, a - b);
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a / b);
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a % b);
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) return 0;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: modulo by zero");
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
return a - b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryDiv}.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a % b;
}
}
// File: @openzeppelin/contracts-upgradeable/proxy/Initializable.sol
// SPDX-License-Identifier: MIT
// solhint-disable-next-line compiler-version
pragma solidity >=0.4.24 <0.8.0;
import "../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {UpgradeableProxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
*/
bool private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Modifier to protect an initializer function from being invoked twice.
*/
modifier initializer() {
require(_initializing || _isConstructor() || !_initialized, "Initializable: contract is already initialized");
bool isTopLevelCall = !_initializing;
if (isTopLevelCall) {
_initializing = true;
_initialized = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
}
}
/// @dev Returns true if and only if the function is running in the constructor
function _isConstructor() private view returns (bool) {
return !AddressUpgradeable.isContract(address(this));
}
}
// File: @openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../../utils/ContextUpgradeable.sol";
import "./IERC721Upgradeable.sol";
import "./IERC721MetadataUpgradeable.sol";
import "./IERC721EnumerableUpgradeable.sol";
import "./IERC721ReceiverUpgradeable.sol";
import "../../introspection/ERC165Upgradeable.sol";
import "../../math/SafeMathUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/EnumerableSetUpgradeable.sol";
import "../../utils/EnumerableMapUpgradeable.sol";
import "../../utils/StringsUpgradeable.sol";
import "../../proxy/Initializable.sol";
/**
* @title ERC721 Non-Fungible Token Standard basic implementation
* @dev see https://eips.ethereum.org/EIPS/eip-721
*/
contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable, IERC721EnumerableUpgradeable {
using SafeMathUpgradeable for uint256;
using AddressUpgradeable for address;
using EnumerableSetUpgradeable for EnumerableSetUpgradeable.UintSet;
using EnumerableMapUpgradeable for EnumerableMapUpgradeable.UintToAddressMap;
using StringsUpgradeable for uint256;
// Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`
bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;
// Mapping from holder address to their (enumerable) set of owned tokens
mapping (address => EnumerableSetUpgradeable.UintSet) private _holderTokens;
// Enumerable mapping from token ids to their owners
EnumerableMapUpgradeable.UintToAddressMap private _tokenOwners;
// Mapping from token ID to approved address
mapping (uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping (address => mapping (address => bool)) private _operatorApprovals;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Optional mapping for token URIs
mapping (uint256 => string) private _tokenURIs;
// Base URI
string private _baseURI;
/*
* bytes4(keccak256('balanceOf(address)')) == 0x70a08231
* bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e
* bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3
* bytes4(keccak256('getApproved(uint256)')) == 0x081812fc
* bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465
* bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5
* bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd
* bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e
* bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde
*
* => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^
* 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd
*/
bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;
/*
* bytes4(keccak256('name()')) == 0x06fdde03
* bytes4(keccak256('symbol()')) == 0x95d89b41
* bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd
*
* => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f
*/
bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;
/*
* bytes4(keccak256('totalSupply()')) == 0x18160ddd
* bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59
* bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7
*
* => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63
*/
bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
function __ERC721_init(string memory name_, string memory symbol_) internal initializer {
__Context_init_unchained();
__ERC165_init_unchained();
__ERC721_init_unchained(name_, symbol_);
}
function __ERC721_init_unchained(string memory name_, string memory symbol_) internal initializer {
_name = name_;
_symbol = symbol_;
// register the supported interfaces to conform to ERC721 via ERC165
_registerInterface(_INTERFACE_ID_ERC721);
_registerInterface(_INTERFACE_ID_ERC721_METADATA);
_registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _holderTokens[owner].length();
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token");
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory _tokenURI = _tokenURIs[tokenId];
string memory base = baseURI();
// If there is no base URI, return the token URI.
if (bytes(base).length == 0) {
return _tokenURI;
}
// If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
if (bytes(_tokenURI).length > 0) {
return string(abi.encodePacked(base, _tokenURI));
}
// If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.
return string(abi.encodePacked(base, tokenId.toString()));
}
/**
* @dev Returns the base URI set via {_setBaseURI}. This will be
* automatically added as a prefix in {tokenURI} to each token's URI, or
* to the token ID if no specific URI is set for that token ID.
*/
function baseURI() public view virtual returns (string memory) {
return _baseURI;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
return _holderTokens[owner].at(index);
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
// _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds
return _tokenOwners.length();
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
(uint256 tokenId, ) = _tokenOwners.at(index);
return tokenId;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721Upgradeable.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(_msgSender() == owner || ERC721Upgradeable.isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(address from, address to, uint256 tokenId) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _tokenOwners.contains(tokenId);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721Upgradeable.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || ERC721Upgradeable.isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
d*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual {
_mint(to, tokenId);
require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_holderTokens[to].add(tokenId);
_tokenOwners.set(tokenId, to);
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721Upgradeable.ownerOf(tokenId); // internal owner
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
// Clear metadata (if any)
if (bytes(_tokenURIs[tokenId]).length != 0) {
delete _tokenURIs[tokenId];
}
_holderTokens[owner].remove(tokenId);
_tokenOwners.remove(tokenId);
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(address from, address to, uint256 tokenId) internal virtual {
require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); // internal owner
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_holderTokens[from].remove(tokenId);
_holderTokens[to].add(tokenId);
_tokenOwners.set(tokenId, to);
emit Transfer(from, to, tokenId);
}
/**
* @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
_tokenURIs[tokenId] = _tokenURI;
}
/**
* @dev Internal function to set the base URI for all token IDs. It is
* automatically added as a prefix to the value returned in {tokenURI},
* or to the token ID if {tokenURI} is empty.
*/
function _setBaseURI(string memory baseURI_) internal virtual {
_baseURI = baseURI_;
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)
private returns (bool)
{
if (!to.isContract()) {
return true;
}
bytes memory returndata = to.functionCall(abi.encodeWithSelector(
IERC721ReceiverUpgradeable(to).onERC721Received.selector,
_msgSender(),
from,
tokenId,
_data
), "ERC721: transfer to non ERC721Receiver implementer");
bytes4 retval = abi.decode(returndata, (bytes4));
return (retval == _ERC721_RECEIVED);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits an {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId); // internal owner
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { }
uint256[41] private __gap;
}
// File: @openzeppelin/contracts-upgradeable/token/ERC721/IERC721EnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
import "./IERC721Upgradeable.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721EnumerableUpgradeable is IERC721Upgradeable {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
// File: @openzeppelin/contracts-upgradeable/token/ERC721/IERC721MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
import "./IERC721Upgradeable.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721MetadataUpgradeable is IERC721Upgradeable {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
// File: @openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721ReceiverUpgradeable {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);
}
// File: @openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
import "../../introspection/IERC165Upgradeable.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721Upgradeable is IERC165Upgradeable {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
}
// File: @openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../proxy/Initializable.sol";
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal initializer {
__Context_init_unchained();
}
function __Context_init_unchained() internal initializer {
}
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
uint256[50] private __gap;
}
// File: @openzeppelin/contracts-upgradeable/utils/EnumerableMapUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Library for managing an enumerable variant of Solidity's
* https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
* type.
*
* Maps have the following properties:
*
* - Entries are added, removed, and checked for existence in constant time
* (O(1)).
* - Entries are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableMap for EnumerableMap.UintToAddressMap;
*
* // Declare a set state variable
* EnumerableMap.UintToAddressMap private myMap;
* }
* ```
*
* As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are
* supported.
*/
library EnumerableMapUpgradeable {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Map type with
// bytes32 keys and values.
// The Map implementation uses private functions, and user-facing
// implementations (such as Uint256ToAddressMap) are just wrappers around
// the underlying Map.
// This means that we can only create new EnumerableMaps for types that fit
// in bytes32.
struct MapEntry {
bytes32 _key;
bytes32 _value;
}
struct Map {
// Storage of map keys and values
MapEntry[] _entries;
// Position of the entry defined by a key in the `entries` array, plus 1
// because index 0 means a key is not in the map.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) {
// We read and store the key's index to prevent multiple reads from the same storage slot
uint256 keyIndex = map._indexes[key];
if (keyIndex == 0) { // Equivalent to !contains(map, key)
map._entries.push(MapEntry({ _key: key, _value: value }));
// The entry is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
map._indexes[key] = map._entries.length;
return true;
} else {
map._entries[keyIndex - 1]._value = value;
return false;
}
}
/**
* @dev Removes a key-value pair from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function _remove(Map storage map, bytes32 key) private returns (bool) {
// We read and store the key's index to prevent multiple reads from the same storage slot
uint256 keyIndex = map._indexes[key];
if (keyIndex != 0) { // Equivalent to contains(map, key)
// To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one
// in the array, and then remove the last entry (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = keyIndex - 1;
uint256 lastIndex = map._entries.length - 1;
// When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
MapEntry storage lastEntry = map._entries[lastIndex];
// Move the last entry to the index where the entry to delete is
map._entries[toDeleteIndex] = lastEntry;
// Update the index for the moved entry
map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved entry was stored
map._entries.pop();
// Delete the index for the deleted slot
delete map._indexes[key];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function _contains(Map storage map, bytes32 key) private view returns (bool) {
return map._indexes[key] != 0;
}
/**
* @dev Returns the number of key-value pairs in the map. O(1).
*/
function _length(Map storage map) private view returns (uint256) {
return map._entries.length;
}
/**
* @dev Returns the key-value pair stored at position `index` in the map. O(1).
*
* Note that there are no guarantees on the ordering of entries inside the
* array, and it may change when more entries are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) {
require(map._entries.length > index, "EnumerableMap: index out of bounds");
MapEntry storage entry = map._entries[index];
return (entry._key, entry._value);
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) {
uint256 keyIndex = map._indexes[key];
if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key)
return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function _get(Map storage map, bytes32 key) private view returns (bytes32) {
uint256 keyIndex = map._indexes[key];
require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key)
return map._entries[keyIndex - 1]._value; // All indexes are 1-based
}
/**
* @dev Same as {_get}, with a custom error message when `key` is not in the map.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {_tryGet}.
*/
function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) {
uint256 keyIndex = map._indexes[key];
require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key)
return map._entries[keyIndex - 1]._value; // All indexes are 1-based
}
// UintToAddressMap
struct UintToAddressMap {
Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {
return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {
return _remove(map._inner, bytes32(key));
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {
return _contains(map._inner, bytes32(key));
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(UintToAddressMap storage map) internal view returns (uint256) {
return _length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the set. O(1).
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {
(bytes32 key, bytes32 value) = _at(map._inner, index);
return (uint256(key), address(uint160(uint256(value))));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*
* _Available since v3.4._
*/
function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
(bool success, bytes32 value) = _tryGet(map._inner, bytes32(key));
return (success, address(uint160(uint256(value))));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
return address(uint160(uint256(_get(map._inner, bytes32(key)))));
}
/**
* @dev Same as {get}, with a custom error message when `key` is not in the map.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryGet}.
*/
function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {
return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage))));
}
}
// File: @openzeppelin/contracts-upgradeable/utils/EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*/
library EnumerableSetUpgradeable {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
}
// File: @openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev String operations.
*/
library StringsUpgradeable {
/**
* @dev Converts a `uint256` to its ASCII `string` representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
uint256 index = digits - 1;
temp = value;
while (temp != 0) {
buffer[index--] = bytes1(uint8(48 + temp % 10));
temp /= 10;
}
return string(buffer);
}
}
// File: @openzeppelin/contracts/introspection/ERC165.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts may inherit from this and call {_registerInterface} to declare
* their support of an interface.
*/
abstract contract ERC165 is IERC165 {
/*
* bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
*/
bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
/**
* @dev Mapping of interface ids to whether or not it's supported.
*/
mapping(bytes4 => bool) private _supportedInterfaces;
constructor () internal {
// Derived contracts need only register support for their own interfaces,
// we register support for ERC165 itself here
_registerInterface(_INTERFACE_ID_ERC165);
}
/**
* @dev See {IERC165-supportsInterface}.
*
* Time complexity O(1), guaranteed to always use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return _supportedInterfaces[interfaceId];
}
/**
* @dev Registers the contract as an implementer of the interface defined by
* `interfaceId`. Support of the actual ERC165 interface is automatic and
* registering its interface id is not required.
*
* See {IERC165-supportsInterface}.
*
* Requirements:
*
* - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
*/
function _registerInterface(bytes4 interfaceId) internal virtual {
require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
_supportedInterfaces[interfaceId] = true;
}
}
// File: @openzeppelin/contracts/introspection/IERC165.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// File: @openzeppelin/contracts/math/SafeMath.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b > a) return (false, 0);
return (true, a - b);
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a / b);
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a % b);
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) return 0;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: modulo by zero");
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
return a - b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryDiv}.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a % b;
}
}
// File: @openzeppelin/contracts/token/ERC721/ERC721.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
import "../../utils/Context.sol";
import "./IERC721.sol";
import "./IERC721Metadata.sol";
import "./IERC721Enumerable.sol";
import "./IERC721Receiver.sol";
import "../../introspection/ERC165.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";
import "../../utils/EnumerableSet.sol";
import "../../utils/EnumerableMap.sol";
import "../../utils/Strings.sol";
/**
* @title ERC721 Non-Fungible Token Standard basic implementation
* @dev see https://eips.ethereum.org/EIPS/eip-721
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable {
using SafeMath for uint256;
using Address for address;
using EnumerableSet for EnumerableSet.UintSet;
using EnumerableMap for EnumerableMap.UintToAddressMap;
using Strings for uint256;
// Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`
bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;
// Mapping from holder address to their (enumerable) set of owned tokens
mapping (address => EnumerableSet.UintSet) private _holderTokens;
// Enumerable mapping from token ids to their owners
EnumerableMap.UintToAddressMap private _tokenOwners;
// Mapping from token ID to approved address
mapping (uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping (address => mapping (address => bool)) private _operatorApprovals;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Optional mapping for token URIs
mapping (uint256 => string) private _tokenURIs;
// Base URI
string private _baseURI;
/*
* bytes4(keccak256('balanceOf(address)')) == 0x70a08231
* bytes4(keccak256('ownerOf(uint256)')) == 0x6352211e
* bytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3
* bytes4(keccak256('getApproved(uint256)')) == 0x081812fc
* bytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465
* bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9c5
* bytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872dd
* bytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0e
* bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde
*
* => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^
* 0xa22cb465 ^ 0xe985e9c5 ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd
*/
bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;
/*
* bytes4(keccak256('name()')) == 0x06fdde03
* bytes4(keccak256('symbol()')) == 0x95d89b41
* bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd
*
* => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f
*/
bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;
/*
* bytes4(keccak256('totalSupply()')) == 0x18160ddd
* bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) == 0x2f745c59
* bytes4(keccak256('tokenByIndex(uint256)')) == 0x4f6ccce7
*
* => 0x18160ddd ^ 0x2f745c59 ^ 0x4f6ccce7 == 0x780e9d63
*/
bytes4 private constant _INTERFACE_ID_ERC721_ENUMERABLE = 0x780e9d63;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor (string memory name_, string memory symbol_) public {
_name = name_;
_symbol = symbol_;
// register the supported interfaces to conform to ERC721 via ERC165
_registerInterface(_INTERFACE_ID_ERC721);
_registerInterface(_INTERFACE_ID_ERC721_METADATA);
_registerInterface(_INTERFACE_ID_ERC721_ENUMERABLE);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _holderTokens[owner].length();
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
return _tokenOwners.get(tokenId, "ERC721: owner query for nonexistent token");
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory _tokenURI = _tokenURIs[tokenId];
string memory base = baseURI();
// If there is no base URI, return the token URI.
if (bytes(base).length == 0) {
return _tokenURI;
}
// If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
if (bytes(_tokenURI).length > 0) {
return string(abi.encodePacked(base, _tokenURI));
}
// If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI.
return string(abi.encodePacked(base, tokenId.toString()));
}
/**
* @dev Returns the base URI set via {_setBaseURI}. This will be
* automatically added as a prefix in {tokenURI} to each token's URI, or
* to the token ID if no specific URI is set for that token ID.
*/
function baseURI() public view virtual returns (string memory) {
return _baseURI;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
return _holderTokens[owner].at(index);
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
// _tokenOwners are indexed by tokenIds, so .length() returns the number of tokenIds
return _tokenOwners.length();
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
(uint256 tokenId, ) = _tokenOwners.at(index);
return tokenId;
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(_msgSender() == owner || ERC721.isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
require(operator != _msgSender(), "ERC721: approve to caller");
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(address from, address to, uint256 tokenId) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _tokenOwners.contains(tokenId);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || ERC721.isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
d*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual {
_mint(to, tokenId);
require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_holderTokens[to].add(tokenId);
_tokenOwners.set(tokenId, to);
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId); // internal owner
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
// Clear metadata (if any)
if (bytes(_tokenURIs[tokenId]).length != 0) {
delete _tokenURIs[tokenId];
}
_holderTokens[owner].remove(tokenId);
_tokenOwners.remove(tokenId);
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(address from, address to, uint256 tokenId) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); // internal owner
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_holderTokens[from].remove(tokenId);
_holderTokens[to].add(tokenId);
_tokenOwners.set(tokenId, to);
emit Transfer(from, to, tokenId);
}
/**
* @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
_tokenURIs[tokenId] = _tokenURI;
}
/**
* @dev Internal function to set the base URI for all token IDs. It is
* automatically added as a prefix to the value returned in {tokenURI},
* or to the token ID if {tokenURI} is empty.
*/
function _setBaseURI(string memory baseURI_) internal virtual {
_baseURI = baseURI_;
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)
private returns (bool)
{
if (!to.isContract()) {
return true;
}
bytes memory returndata = to.functionCall(abi.encodeWithSelector(
IERC721Receiver(to).onERC721Received.selector,
_msgSender(),
from,
tokenId,
_data
), "ERC721: transfer to non ERC721Receiver implementer");
bytes4 retval = abi.decode(returndata, (bytes4));
return (retval == _ERC721_RECEIVED);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits an {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId); // internal owner
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { }
}
// File: @openzeppelin/contracts/token/ERC721/IERC721.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
import "../../introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
}
// File: @openzeppelin/contracts/token/ERC721/IERC721Enumerable.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
import "./IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
// File: @openzeppelin/contracts/token/ERC721/IERC721Metadata.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
import "./IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
// File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);
}
// File: @openzeppelin/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: value }(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.staticcall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
// File: @openzeppelin/contracts/utils/EnumerableMap.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Library for managing an enumerable variant of Solidity's
* https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]
* type.
*
* Maps have the following properties:
*
* - Entries are added, removed, and checked for existence in constant time
* (O(1)).
* - Entries are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableMap for EnumerableMap.UintToAddressMap;
*
* // Declare a set state variable
* EnumerableMap.UintToAddressMap private myMap;
* }
* ```
*
* As of v3.0.0, only maps of type `uint256 -> address` (`UintToAddressMap`) are
* supported.
*/
library EnumerableMap {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Map type with
// bytes32 keys and values.
// The Map implementation uses private functions, and user-facing
// implementations (such as Uint256ToAddressMap) are just wrappers around
// the underlying Map.
// This means that we can only create new EnumerableMaps for types that fit
// in bytes32.
struct MapEntry {
bytes32 _key;
bytes32 _value;
}
struct Map {
// Storage of map keys and values
MapEntry[] _entries;
// Position of the entry defined by a key in the `entries` array, plus 1
// because index 0 means a key is not in the map.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function _set(Map storage map, bytes32 key, bytes32 value) private returns (bool) {
// We read and store the key's index to prevent multiple reads from the same storage slot
uint256 keyIndex = map._indexes[key];
if (keyIndex == 0) { // Equivalent to !contains(map, key)
map._entries.push(MapEntry({ _key: key, _value: value }));
// The entry is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
map._indexes[key] = map._entries.length;
return true;
} else {
map._entries[keyIndex - 1]._value = value;
return false;
}
}
/**
* @dev Removes a key-value pair from a map. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function _remove(Map storage map, bytes32 key) private returns (bool) {
// We read and store the key's index to prevent multiple reads from the same storage slot
uint256 keyIndex = map._indexes[key];
if (keyIndex != 0) { // Equivalent to contains(map, key)
// To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one
// in the array, and then remove the last entry (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = keyIndex - 1;
uint256 lastIndex = map._entries.length - 1;
// When the entry to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
MapEntry storage lastEntry = map._entries[lastIndex];
// Move the last entry to the index where the entry to delete is
map._entries[toDeleteIndex] = lastEntry;
// Update the index for the moved entry
map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved entry was stored
map._entries.pop();
// Delete the index for the deleted slot
delete map._indexes[key];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function _contains(Map storage map, bytes32 key) private view returns (bool) {
return map._indexes[key] != 0;
}
/**
* @dev Returns the number of key-value pairs in the map. O(1).
*/
function _length(Map storage map) private view returns (uint256) {
return map._entries.length;
}
/**
* @dev Returns the key-value pair stored at position `index` in the map. O(1).
*
* Note that there are no guarantees on the ordering of entries inside the
* array, and it may change when more entries are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Map storage map, uint256 index) private view returns (bytes32, bytes32) {
require(map._entries.length > index, "EnumerableMap: index out of bounds");
MapEntry storage entry = map._entries[index];
return (entry._key, entry._value);
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*/
function _tryGet(Map storage map, bytes32 key) private view returns (bool, bytes32) {
uint256 keyIndex = map._indexes[key];
if (keyIndex == 0) return (false, 0); // Equivalent to contains(map, key)
return (true, map._entries[keyIndex - 1]._value); // All indexes are 1-based
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function _get(Map storage map, bytes32 key) private view returns (bytes32) {
uint256 keyIndex = map._indexes[key];
require(keyIndex != 0, "EnumerableMap: nonexistent key"); // Equivalent to contains(map, key)
return map._entries[keyIndex - 1]._value; // All indexes are 1-based
}
/**
* @dev Same as {_get}, with a custom error message when `key` is not in the map.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {_tryGet}.
*/
function _get(Map storage map, bytes32 key, string memory errorMessage) private view returns (bytes32) {
uint256 keyIndex = map._indexes[key];
require(keyIndex != 0, errorMessage); // Equivalent to contains(map, key)
return map._entries[keyIndex - 1]._value; // All indexes are 1-based
}
// UintToAddressMap
struct UintToAddressMap {
Map _inner;
}
/**
* @dev Adds a key-value pair to a map, or updates the value for an existing
* key. O(1).
*
* Returns true if the key was added to the map, that is if it was not
* already present.
*/
function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {
return _set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the key was removed from the map, that is if it was present.
*/
function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {
return _remove(map._inner, bytes32(key));
}
/**
* @dev Returns true if the key is in the map. O(1).
*/
function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {
return _contains(map._inner, bytes32(key));
}
/**
* @dev Returns the number of elements in the map. O(1).
*/
function length(UintToAddressMap storage map) internal view returns (uint256) {
return _length(map._inner);
}
/**
* @dev Returns the element stored at position `index` in the set. O(1).
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {
(bytes32 key, bytes32 value) = _at(map._inner, index);
return (uint256(key), address(uint160(uint256(value))));
}
/**
* @dev Tries to returns the value associated with `key`. O(1).
* Does not revert if `key` is not in the map.
*
* _Available since v3.4._
*/
function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {
(bool success, bytes32 value) = _tryGet(map._inner, bytes32(key));
return (success, address(uint160(uint256(value))));
}
/**
* @dev Returns the value associated with `key`. O(1).
*
* Requirements:
*
* - `key` must be in the map.
*/
function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {
return address(uint160(uint256(_get(map._inner, bytes32(key)))));
}
/**
* @dev Same as {get}, with a custom error message when `key` is not in the map.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryGet}.
*/
function get(UintToAddressMap storage map, uint256 key, string memory errorMessage) internal view returns (address) {
return address(uint160(uint256(_get(map._inner, bytes32(key), errorMessage))));
}
}
// File: @openzeppelin/contracts/utils/EnumerableSet.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
}
// File: @openzeppelin/contracts/utils/Strings.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev String operations.
*/
library Strings {
/**
* @dev Converts a `uint256` to its ASCII `string` representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
uint256 index = digits - 1;
temp = value;
while (temp != 0) {
buffer[index--] = bytes1(uint8(48 + temp % 10));
temp /= 10;
}
return string(buffer);
}
}
// File: contracts/PaceArtStore.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.5;
pragma abicoder v2;
import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
import "./libraries/LibPart.sol";
import "./royalties/RoyaltiesV2Impl.sol";
contract OwnableDelegateProxy {}
contract ProxyRegistry {
mapping(address => OwnableDelegateProxy) public proxies;
mapping(address => bool) public contracts;
}
/**
* @title ERC721Tradable
* ERC721Tradable - ERC721 contract that whitelists a trading address, and has minting functionality.
*/
contract PaceArtStore is RoyaltiesV2Impl, ERC721Upgradeable, OwnableUpgradeable {
using SafeMath for uint256;
address exchangeAddress;
address proxyRegistryAddress;
uint256 private _currentTokenId = 0;
string private _extendedTokenURI;
function initialize(
string memory _name,
string memory _symbol,
string memory _tokenURI,
address _proxyRegistryAddress,
address _exchangeAddress
) external initializer {
__Ownable_init();
__ERC721_init(_name, _symbol);
proxyRegistryAddress = _proxyRegistryAddress;
_extendedTokenURI = _tokenURI;
exchangeAddress = _exchangeAddress;
transferOwnership(tx.origin);
}
function mintTo(address _to, LibPart.Part memory _royalty) public returns(uint) {
require(
ProxyRegistry(proxyRegistryAddress).contracts(_msgSender()) ||
_msgSender() == owner(),
"ERC721Tradable::sender is not owner or approved!"
);
uint256 newTokenId = _getNextTokenId();
_mint(_to, newTokenId);
_saveRoyalties(newTokenId, _royalty);
_incrementTokenId();
return newTokenId;
}
function singleTransfer(
address _from,
address _to,
uint256 _tokenId
) external returns(uint) {
if (_exists(_tokenId)) {
address owner = ownerOf(_tokenId);
require(owner == _from, "ERC721Tradable::Token ID not belong to user!");
require(isApprovedForAll(owner, _msgSender()), "ERC721Tradable::sender is not approved!");
_transfer(_from, _to, _tokenId);
}
return _tokenId;
}
/**
* @dev calculates the next token ID based on value of _currentTokenId
* @return uint256 for the next token ID
*/
function _getNextTokenId() private view returns (uint256) {
return _currentTokenId.add(1);
}
/**
* @dev increments the value of _currentTokenId
*/
function _incrementTokenId() private {
_currentTokenId++;
}
function baseTokenURI() virtual public view returns (string memory) {
return _extendedTokenURI;
}
function tokenURI(uint256 _tokenId) override public view returns (string memory) {
return string(abi.encodePacked(baseTokenURI(), Strings.toString(_tokenId)));
}
function modifyExtendedURI(string memory extendedTokenURI_) external onlyOwner {
_extendedTokenURI = extendedTokenURI_;
}
/**
* Override isApprovedForAll to whitelist user's OpenSea proxy accounts to enable gas-less listings.
*/
function isApprovedForAll(address owner, address operator)
override
public
view
returns (bool)
{
// Whitelist OpenSea proxy contract for easy trading.
ProxyRegistry proxyRegistry = ProxyRegistry(proxyRegistryAddress);
if (address(proxyRegistry.proxies(owner)) == operator) {
return true;
}
return super.isApprovedForAll(owner, operator);
}
}
// File: contracts/libraries/LibPart.sol
// SPDX-License-Identifier: MIT pragma
pragma solidity 0.7.5;
library LibPart {
bytes32 public constant TYPE_HASH = keccak256("Part(address account,uint96 value)");
struct Part {
address payable account;
uint96 value;
}
function hash(Part memory part) internal pure returns (bytes32){
return keccak256(abi.encode(TYPE_HASH, part.account, part.value));
}
}
// File: contracts/royalties/AbstractRoyalties.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.5;
import "../libraries/LibPart.sol";
abstract contract AbstractRoyalties {
mapping (uint256 => LibPart.Part) public royalties;
function _saveRoyalties(uint256 _id, LibPart.Part memory _royalties) internal {
require(_royalties.account != address(0x0), "Recipient should be present");
require(_royalties.value >= 0, "Royalty value should be positive");
royalties[_id] = _royalties;
_onRoyaltiesSet(_id, _royalties);
}
function _updateAccount(uint256 _id, address _from, address _to) internal {
if (royalties[_id].account == _from) {
royalties[_id].account = payable(address(uint160(_to)));
}
}
function _onRoyaltiesSet(uint256 _id, LibPart.Part memory _royalties) virtual internal;
}
// File: contracts/royalties/RoyaltiesV2.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.5;
pragma abicoder v2;
import "../libraries/LibPart.sol";
interface RoyaltiesV2 {
event RoyaltiesSet(uint256 tokenId, LibPart.Part royalties);
function getPaceArtV2Royalties(uint256 id) external view returns (LibPart.Part memory);
}
// File: contracts/royalties/RoyaltiesV2Impl.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.5;
pragma abicoder v2;
import "./AbstractRoyalties.sol";
import "./RoyaltiesV2.sol";
contract RoyaltiesV2Impl is AbstractRoyalties, RoyaltiesV2 {
function getPaceArtV2Royalties(uint256 id) override external view returns (LibPart.Part memory) {
return royalties[id];
}
function _onRoyaltiesSet(uint256 _id, LibPart.Part memory _royalties) override internal {
emit RoyaltiesSet(_id, _royalties);
}
} | [{"defect": "DelegateCall", "type": "Function_call", "severity": "High", "lines": ["3176"]}, {"defect": "Uninitialized_storage", "type": "Code_specification", "severity": "Low", "lines": ["3374", "1523", "3374", "1523"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["3869", "3860", "3858"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["3861", "3862", "942", "3831", "1980"]}, {"defect": "Balance_manipulation", "type": "Business_logic", "severity": "Medium", "lines": ["2407", "571"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["3877", "42", "626", "57", "2411", "2814", "966", "575", "69", "2935", "1071", "2462", "2725"]}] | [{"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"contracts/royalties/AbstractRoyalties.sol": [7, 8, 9, 10, 11, 12]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"contracts/libraries/LibPart.sol": [12, 13, 14]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"contracts/royalties/RoyaltiesV2Impl.sol": [12, 13, 14]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"contracts/royalties/AbstractRoyalties.sol": [13, 14, 15, 16, 17]}}, {"check": "tautology", "impact": "Medium", "confidence": "High", "lines": {"contracts/royalties/AbstractRoyalties.sol": [9]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 102, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 140, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 488, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 528, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 537, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 546, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 2010, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 2044, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 2330, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 2370, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 2379, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 2388, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 66, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 782, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 801, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 823, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 826, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 858, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 2618, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 2637, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 2659, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 2662, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 2694, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 3998, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 7, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 7, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 87, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 87, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 152, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 152, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 181, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 181, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 401, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 401, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 460, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 460, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 951, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 951, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 985, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 985, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1017, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1017, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1043, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1043, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1177, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1177, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1347, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1347, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1384, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1384, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1655, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1655, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1957, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1957, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1996, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1996, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2055, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2055, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2084, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2084, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2303, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2303, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2786, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2786, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2920, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2920, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2954, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2954, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2986, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2986, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3012, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3012, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3206, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3206, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3235, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3235, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3506, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3506, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3808, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3808, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 24, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 78, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 102, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 107, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 143, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 422, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 427, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 488, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 491, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 494, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 497, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 500, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 503, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 506, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 509, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 512, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 528, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 537, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 546, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 942, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1375, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2010, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2015, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2330, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2333, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2336, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2339, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2342, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2345, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2348, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2351, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2354, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2370, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2379, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 2388, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 3874, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 3875, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 2322, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 3870, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 1200, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 3035, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 202, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 213, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 223, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 238, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 248, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 1520, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 1531, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 1611, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 1622, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 2105, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 2116, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 2126, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 2141, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 2151, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 3371, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 3382, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 3462, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 3473, "severity": 1}, {"rule": "SOLIDITY_TX_ORIGIN", "line": 3890, "severity": 2}, {"rule": "SOLIDITY_VISIBILITY", "line": 1227, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 3062, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1227, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1227, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1228, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1228, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1228, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1228, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1231, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1231, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1231, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 3062, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 3062, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 3063, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 3063, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 3063, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 3063, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 3066, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 3066, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 3066, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 3872, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 3873, "severity": 1}] | [{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"tokenId","type":"uint256"},{"components":[{"internalType":"address payable","name":"account","type":"address"},{"internalType":"uint96","name":"value","type":"uint96"}],"indexed":false,"internalType":"struct LibPart.Part","name":"royalties","type":"tuple"}],"name":"RoyaltiesSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseTokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id","type":"uint256"}],"name":"getPaceArtV2Royalties","outputs":[{"components":[{"internalType":"address payable","name":"account","type":"address"},{"internalType":"uint96","name":"value","type":"uint96"}],"internalType":"struct LibPart.Part","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"string","name":"_tokenURI","type":"string"},{"internalType":"address","name":"_proxyRegistryAddress","type":"address"},{"internalType":"address","name":"_exchangeAddress","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"components":[{"internalType":"address payable","name":"account","type":"address"},{"internalType":"uint96","name":"value","type":"uint96"}],"internalType":"struct LibPart.Part","name":"_royalty","type":"tuple"}],"name":"mintTo","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"extendedTokenURI_","type":"string"}],"name":"modifyExtendedURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"royalties","outputs":[{"internalType":"address payable","name":"account","type":"address"},{"internalType":"uint96","name":"value","type":"uint96"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"singleTransfer","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}] | v0.7.5+commit.eb77ed08 | true | 1,000 | Default | MIT | false | ||||
DappManager | 0x5cd15b0960de93b6ed9df6012163cb88bf45d7bb | Solidity | pragma solidity ^0.4.24;
/**
* @title Module
* @dev Interface for a module.
* A module MUST implement the addModule() method to ensure that a wallet with at least one module
* can never end up in a "frozen" state.
* @author Julien Niset - <[email protected]>
*/
interface Module {
/**
* @dev Inits a module for a wallet by e.g. setting some wallet specific parameters in storage.
* @param _wallet The wallet.
*/
function init(BaseWallet _wallet) external;
/**
* @dev Adds a module to a wallet.
* @param _wallet The target wallet.
* @param _module The modules to authorise.
*/
function addModule(BaseWallet _wallet, Module _module) external;
/**
* @dev Utility method to recover any ERC20 token that was sent to the
* module by mistake.
* @param _token The token to recover.
*/
function recoverToken(address _token) external;
}
/**
* @title BaseModule
* @dev Basic module that contains some methods common to all modules.
* @author Julien Niset - <[email protected]>
*/
contract BaseModule is Module {
// The adddress of the module registry.
ModuleRegistry internal registry;
event ModuleCreated(bytes32 name);
event ModuleInitialised(address wallet);
constructor(ModuleRegistry _registry, bytes32 _name) public {
registry = _registry;
emit ModuleCreated(_name);
}
/**
* @dev Throws if the sender is not the target wallet of the call.
*/
modifier onlyWallet(BaseWallet _wallet) {
require(msg.sender == address(_wallet), "BM: caller must be wallet");
_;
}
/**
* @dev Throws if the sender is not the owner of the target wallet or the module itself.
*/
modifier onlyOwner(BaseWallet _wallet) {
require(msg.sender == address(this) || isOwner(_wallet, msg.sender), "BM: must be an owner for the wallet");
_;
}
/**
* @dev Throws if the sender is not the owner of the target wallet.
*/
modifier strictOnlyOwner(BaseWallet _wallet) {
require(isOwner(_wallet, msg.sender), "BM: msg.sender must be an owner for the wallet");
_;
}
/**
* @dev Inits the module for a wallet by logging an event.
* The method can only be called by the wallet itself.
* @param _wallet The wallet.
*/
function init(BaseWallet _wallet) external onlyWallet(_wallet) {
emit ModuleInitialised(_wallet);
}
/**
* @dev Adds a module to a wallet. First checks that the module is registered.
* @param _wallet The target wallet.
* @param _module The modules to authorise.
*/
function addModule(BaseWallet _wallet, Module _module) external strictOnlyOwner(_wallet) {
require(registry.isRegisteredModule(_module), "BM: module is not registered");
_wallet.authoriseModule(_module, true);
}
/**
* @dev Utility method enbaling anyone to recover ERC20 token sent to the
* module by mistake and transfer them to the Module Registry.
* @param _token The token to recover.
*/
function recoverToken(address _token) external {
uint total = ERC20(_token).balanceOf(address(this));
ERC20(_token).transfer(address(registry), total);
}
/**
* @dev Helper method to check if an address is the owner of a target wallet.
* @param _wallet The target wallet.
* @param _addr The address.
*/
function isOwner(BaseWallet _wallet, address _addr) internal view returns (bool) {
return _wallet.owner() == _addr;
}
}
/**
* @title RelayerModule
* @dev Base module containing logic to execute transactions signed by eth-less accounts and sent by a relayer.
* @author Julien Niset - <[email protected]>
*/
contract RelayerModule is Module {
uint256 constant internal BLOCKBOUND = 10000;
mapping (address => RelayerConfig) public relayer;
struct RelayerConfig {
uint256 nonce;
mapping (bytes32 => bool) executedTx;
}
event TransactionExecuted(address indexed wallet, bool indexed success, bytes32 signedHash);
/**
* @dev Throws if the call did not go through the execute() method.
*/
modifier onlyExecute {
require(msg.sender == address(this), "RM: must be called via execute()");
_;
}
/* ***************** Abstract method ************************* */
/**
* @dev Gets the number of valid signatures that must be provided to execute a
* specific relayed transaction.
* @param _wallet The target wallet.
* @param _data The data of the relayed transaction.
* @return The number of required signatures.
*/
function getRequiredSignatures(BaseWallet _wallet, bytes _data) internal view returns (uint256);
/**
* @dev Validates the signatures provided with a relayed transaction.
* The method MUST throw if one or more signatures are not valid.
* @param _wallet The target wallet.
* @param _data The data of the relayed transaction.
* @param _signHash The signed hash representing the relayed transaction.
* @param _signatures The signatures as a concatenated byte array.
*/
function validateSignatures(BaseWallet _wallet, bytes _data, bytes32 _signHash, bytes _signatures) internal view returns (bool);
/* ************************************************************ */
/**
* @dev Executes a relayed transaction.
* @param _wallet The target wallet.
* @param _data The data for the relayed transaction
* @param _nonce The nonce used to prevent replay attacks.
* @param _signatures The signatures as a concatenated byte array.
* @param _gasPrice The gas price to use for the gas refund.
* @param _gasLimit The gas limit to use for the gas refund.
*/
function execute(
BaseWallet _wallet,
bytes _data,
uint256 _nonce,
bytes _signatures,
uint256 _gasPrice,
uint256 _gasLimit
)
external
returns (bool success)
{
uint startGas = gasleft();
bytes32 signHash = getSignHash(address(this), _wallet, 0, _data, _nonce, _gasPrice, _gasLimit);
require(checkAndUpdateUniqueness(_wallet, _nonce, signHash), "RM: Duplicate request");
require(verifyData(address(_wallet), _data), "RM: the wallet authorized is different then the target of the relayed data");
uint256 requiredSignatures = getRequiredSignatures(_wallet, _data);
if((requiredSignatures * 65) == _signatures.length) {
if(verifyRefund(_wallet, _gasLimit, _gasPrice, requiredSignatures)) {
if(requiredSignatures == 0 || validateSignatures(_wallet, _data, signHash, _signatures)) {
// solium-disable-next-line security/no-call-value
success = address(this).call(_data);
refund(_wallet, startGas - gasleft(), _gasPrice, _gasLimit, requiredSignatures, msg.sender);
}
}
}
emit TransactionExecuted(_wallet, success, signHash);
}
/**
* @dev Gets the current nonce for a wallet.
* @param _wallet The target wallet.
*/
function getNonce(BaseWallet _wallet) external view returns (uint256 nonce) {
return relayer[_wallet].nonce;
}
/**
* @dev Generates the signed hash of a relayed transaction according to ERC 1077.
* @param _from The starting address for the relayed transaction (should be the module)
* @param _to The destination address for the relayed transaction (should be the wallet)
* @param _value The value for the relayed transaction
* @param _data The data for the relayed transaction
* @param _nonce The nonce used to prevent replay attacks.
* @param _gasPrice The gas price to use for the gas refund.
* @param _gasLimit The gas limit to use for the gas refund.
*/
function getSignHash(
address _from,
address _to,
uint256 _value,
bytes _data,
uint256 _nonce,
uint256 _gasPrice,
uint256 _gasLimit
)
internal
pure
returns (bytes32)
{
return keccak256(
abi.encodePacked(
"\x19Ethereum Signed Message:\n32",
keccak256(abi.encodePacked(byte(0x19), byte(0), _from, _to, _value, _data, _nonce, _gasPrice, _gasLimit))
));
}
/**
* @dev Checks if the relayed transaction is unique.
* @param _wallet The target wallet.
* @param _nonce The nonce
* @param _signHash The signed hash of the transaction
*/
function checkAndUpdateUniqueness(BaseWallet _wallet, uint256 _nonce, bytes32 _signHash) internal returns (bool) {
if(relayer[_wallet].executedTx[_signHash] == true) {
return false;
}
relayer[_wallet].executedTx[_signHash] = true;
return true;
}
/**
* @dev Checks that a nonce has the correct format and is valid.
* It must be constructed as nonce = {block number}{timestamp} where each component is 16 bytes.
* @param _wallet The target wallet.
* @param _nonce The nonce
*/
function checkAndUpdateNonce(BaseWallet _wallet, uint256 _nonce) internal returns (bool) {
if(_nonce <= relayer[_wallet].nonce) {
return false;
}
uint256 nonceBlock = (_nonce & 0xffffffffffffffffffffffffffffffff00000000000000000000000000000000) >> 128;
if(nonceBlock > block.number + BLOCKBOUND) {
return false;
}
relayer[_wallet].nonce = _nonce;
return true;
}
/**
* @dev Recovers the signer at a given position from a list of concatenated signatures.
* @param _signedHash The signed hash
* @param _signatures The concatenated signatures.
* @param _index The index of the signature to recover.
*/
function recoverSigner(bytes32 _signedHash, bytes _signatures, uint _index) internal pure returns (address) {
uint8 v;
bytes32 r;
bytes32 s;
// we jump 32 (0x20) as the first slot of bytes contains the length
// we jump 65 (0x41) per signature
// for v we load 32 bytes ending with v (the first 31 come from s) then apply a mask
// solium-disable-next-line security/no-inline-assembly
assembly {
r := mload(add(_signatures, add(0x20,mul(0x41,_index))))
s := mload(add(_signatures, add(0x40,mul(0x41,_index))))
v := and(mload(add(_signatures, add(0x41,mul(0x41,_index)))), 0xff)
}
require(v == 27 || v == 28);
return ecrecover(_signedHash, v, r, s);
}
/**
* @dev Refunds the gas used to the Relayer.
* For security reasons the default behavior is to not refund calls with 0 or 1 signatures.
* @param _wallet The target wallet.
* @param _gasUsed The gas used.
* @param _gasPrice The gas price for the refund.
* @param _gasLimit The gas limit for the refund.
* @param _signatures The number of signatures used in the call.
* @param _relayer The address of the Relayer.
*/
function refund(BaseWallet _wallet, uint _gasUsed, uint _gasPrice, uint _gasLimit, uint _signatures, address _relayer) internal {
uint256 amount = 29292 + _gasUsed; // 21000 (transaction) + 7620 (execution of refund) + 672 to log the event + _gasUsed
// only refund if gas price not null, more than 1 signatures, gas less than gasLimit
if(_gasPrice > 0 && _signatures > 1 && amount <= _gasLimit) {
if(_gasPrice > tx.gasprice) {
amount = amount * tx.gasprice;
}
else {
amount = amount * _gasPrice;
}
_wallet.invoke(_relayer, amount, "");
}
}
/**
* @dev Returns false if the refund is expected to fail.
* @param _wallet The target wallet.
* @param _gasUsed The expected gas used.
* @param _gasPrice The expected gas price for the refund.
*/
function verifyRefund(BaseWallet _wallet, uint _gasUsed, uint _gasPrice, uint _signatures) internal view returns (bool) {
if(_gasPrice > 0
&& _signatures > 1
&& (address(_wallet).balance < _gasUsed * _gasPrice || _wallet.authorised(this) == false)) {
return false;
}
return true;
}
/**
* @dev Checks that the wallet address provided as the first parameter of the relayed data is the same
* as the wallet passed as the input of the execute() method.
@return false if the addresses are different.
*/
function verifyData(address _wallet, bytes _data) private pure returns (bool) {
require(_data.length >= 36, "RM: Invalid dataWallet");
address dataWallet;
// solium-disable-next-line security/no-inline-assembly
assembly {
//_data = {length:32}{sig:4}{_wallet:32}{...}
dataWallet := mload(add(_data, 0x24))
}
return dataWallet == _wallet;
}
/**
* @dev Parses the data to extract the method signature.
*/
function functionPrefix(bytes _data) internal pure returns (bytes4 prefix) {
require(_data.length >= 4, "RM: Invalid functionPrefix");
// solium-disable-next-line security/no-inline-assembly
assembly {
prefix := mload(add(_data, 0x20))
}
}
}
/**
* @title LimitManager
* @dev Module to transfer tokens (ETH or ERC20) based on a security context (daily limit, whitelist, etc).
* @author Julien Niset - <[email protected]>
*/
contract LimitManager is BaseModule {
// large limit when the limit can be considered disabled
uint128 constant internal LIMIT_DISABLED = uint128(-1); // 3.40282366920938463463374607431768211455e+38
using SafeMath for uint256;
struct LimitManagerConfig {
// The global limit
Limit limit;
// whitelist
DailySpent dailySpent;
}
struct Limit {
// the current limit
uint128 current;
// the pending limit if any
uint128 pending;
// when the pending limit becomes the current limit
uint64 changeAfter;
}
struct DailySpent {
// The amount already spent during the current period
uint128 alreadySpent;
// The end of the current period
uint64 periodEnd;
}
// wallet specific storage
mapping (address => LimitManagerConfig) internal limits;
// The default limit
uint256 public defaultLimit;
// *************** Events *************************** //
event LimitChanged(address indexed wallet, uint indexed newLimit, uint64 indexed startAfter);
// *************** Constructor ********************** //
constructor(uint256 _defaultLimit) public {
defaultLimit = _defaultLimit;
}
// *************** External/Public Functions ********************* //
/**
* @dev Inits the module for a wallet by setting the limit to the default value.
* @param _wallet The target wallet.
*/
function init(BaseWallet _wallet) external onlyWallet(_wallet) {
Limit storage limit = limits[_wallet].limit;
if(limit.current == 0 && limit.changeAfter == 0) {
limit.current = uint128(defaultLimit);
}
}
/**
* @dev Changes the global limit.
* The limit is expressed in ETH and the change is pending for the security period.
* @param _wallet The target wallet.
* @param _newLimit The new limit.
* @param _securityPeriod The security period.
*/
function changeLimit(BaseWallet _wallet, uint256 _newLimit, uint256 _securityPeriod) internal {
Limit storage limit = limits[_wallet].limit;
// solium-disable-next-line security/no-block-members
uint128 currentLimit = (limit.changeAfter > 0 && limit.changeAfter < now) ? limit.pending : limit.current;
limit.current = currentLimit;
limit.pending = uint128(_newLimit);
// solium-disable-next-line security/no-block-members
limit.changeAfter = uint64(now.add(_securityPeriod));
// solium-disable-next-line security/no-block-members
emit LimitChanged(_wallet, _newLimit, uint64(now.add(_securityPeriod)));
}
// *************** Internal Functions ********************* //
/**
* @dev Gets the current global limit for a wallet.
* @param _wallet The target wallet.
* @return the current limit expressed in ETH.
*/
function getCurrentLimit(BaseWallet _wallet) public view returns (uint256 _currentLimit) {
Limit storage limit = limits[_wallet].limit;
_currentLimit = uint256(currentLimit(limit.current, limit.pending, limit.changeAfter));
}
/**
* @dev Gets a pending limit for a wallet if any.
* @param _wallet The target wallet.
* @return the pending limit (in ETH) and the time at chich it will become effective.
*/
function getPendingLimit(BaseWallet _wallet) external view returns (uint256 _pendingLimit, uint64 _changeAfter) {
Limit storage limit = limits[_wallet].limit;
// solium-disable-next-line security/no-block-members
return ((now < limit.changeAfter)? (uint256(limit.pending), limit.changeAfter) : (0,0));
}
/**
* @dev Gets the amount of tokens that has not yet been spent during the current period.
* @param _wallet The target wallet.
* @return the amount of tokens (in ETH) that has not been spent yet and the end of the period.
*/
function getDailyUnspent(BaseWallet _wallet) external view returns (uint256 _unspent, uint64 _periodEnd) {
uint256 globalLimit = getCurrentLimit(_wallet);
DailySpent storage expense = limits[_wallet].dailySpent;
// solium-disable-next-line security/no-block-members
if(now > expense.periodEnd) {
_unspent = globalLimit;
_periodEnd = uint64(now + 24 hours);
}
else {
_unspent = globalLimit - expense.alreadySpent;
_periodEnd = expense.periodEnd;
}
}
/**
* @dev Helper method to check if a transfer is within the limit.
* If yes the daily unspent for the current period is updated.
* @param _wallet The target wallet.
* @param _amount The amount for the transfer
*/
function checkAndUpdateDailySpent(BaseWallet _wallet, uint _amount) internal returns (bool) {
Limit storage limit = limits[_wallet].limit;
uint128 current = currentLimit(limit.current, limit.pending, limit.changeAfter);
if(isWithinDailyLimit(_wallet, current, _amount)) {
updateDailySpent(_wallet, current, _amount);
return true;
}
return false;
}
/**
* @dev Helper method to update the daily spent for the current period.
* @param _wallet The target wallet.
* @param _limit The current limit for the wallet.
* @param _amount The amount to add to the daily spent.
*/
function updateDailySpent(BaseWallet _wallet, uint128 _limit, uint _amount) internal {
if(_limit != LIMIT_DISABLED) {
DailySpent storage expense = limits[_wallet].dailySpent;
if (expense.periodEnd < now) {
expense.periodEnd = uint64(now + 24 hours);
expense.alreadySpent = uint128(_amount);
}
else {
expense.alreadySpent += uint128(_amount);
}
}
}
/**
* @dev Checks if a transfer amount is withing the daily limit for a wallet.
* @param _wallet The target wallet.
* @param _limit The current limit for the wallet.
* @param _amount The transfer amount.
* @return true if the transfer amount is withing the daily limit.
*/
function isWithinDailyLimit(BaseWallet _wallet, uint _limit, uint _amount) internal view returns (bool) {
DailySpent storage expense = limits[_wallet].dailySpent;
if(_limit == LIMIT_DISABLED) {
return true;
}
else if (expense.periodEnd < now) {
return (_amount <= _limit);
} else {
return (expense.alreadySpent + _amount <= _limit && expense.alreadySpent + _amount >= expense.alreadySpent);
}
}
/**
* @dev Helper method to get the current limit from a Limit struct.
* @param _current The value of the current parameter
* @param _pending The value of the pending parameter
* @param _changeAfter The value of the changeAfter parameter
*/
function currentLimit(uint128 _current, uint128 _pending, uint64 _changeAfter) internal view returns (uint128) {
if(_changeAfter > 0 && _changeAfter < now) {
return _pending;
}
return _current;
}
}
contract TokenPriceProvider {
using SafeMath for uint256;
// Mock token address for ETH
address constant internal ETH_TOKEN_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
// Address of Kyber's trading contract
address constant internal KYBER_NETWORK_ADDRESS = 0x818E6FECD516Ecc3849DAf6845e3EC868087B755;
mapping(address => uint256) public cachedPrices;
function syncPrice(ERC20 token) public {
uint256 expectedRate;
(expectedRate,) = kyberNetwork().getExpectedRate(token, ERC20(ETH_TOKEN_ADDRESS), 10000);
cachedPrices[token] = expectedRate;
}
//
// Convenience functions
//
function syncPriceForTokenList(ERC20[] tokens) public {
for(uint16 i = 0; i < tokens.length; i++) {
syncPrice(tokens[i]);
}
}
/**
* @dev Converts the value of _amount tokens in ether.
* @param _amount the amount of tokens to convert (in 'token wei' twei)
* @param _token the ERC20 token contract
* @return the ether value (in wei) of _amount tokens with contract _token
*/
function getEtherValue(uint256 _amount, address _token) public view returns (uint256) {
uint256 decimals = ERC20(_token).decimals();
uint256 price = cachedPrices[_token];
return price.mul(_amount).div(10**decimals);
}
//
// Internal
//
function kyberNetwork() internal view returns (KyberNetwork) {
return KyberNetwork(KYBER_NETWORK_ADDRESS);
}
}
contract KyberNetwork {
function getExpectedRate(
ERC20 src,
ERC20 dest,
uint srcQty
)
public
view
returns (uint expectedRate, uint slippageRate);
function trade(
ERC20 src,
uint srcAmount,
ERC20 dest,
address destAddress,
uint maxDestAmount,
uint minConversionRate,
address walletId
)
public
payable
returns(uint);
}
/* The MIT License (MIT)
Copyright (c) 2016 Smart Contract Solutions, Inc.
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. */
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, reverts on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0); // Solidity only automatically asserts 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, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
/**
* @dev Adds two numbers, reverts on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
/**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
/**
* @dev Returns ceil(a / b).
*/
function ceil(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a / b;
if(a % b == 0) {
return c;
}
else {
return c + 1;
}
}
}
/**
* ERC20 contract interface.
*/
contract ERC20 {
function totalSupply() public view returns (uint);
function decimals() 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);
}
/**
* @title Owned
* @dev Basic contract to define an owner.
* @author Julien Niset - <[email protected]>
*/
contract Owned {
// The owner
address public owner;
event OwnerChanged(address indexed _newOwner);
/**
* @dev Throws if the sender is not the owner.
*/
modifier onlyOwner {
require(msg.sender == owner, "Must be owner");
_;
}
constructor() public {
owner = msg.sender;
}
/**
* @dev Lets the owner transfer ownership of the contract to a new owner.
* @param _newOwner The new owner.
*/
function changeOwner(address _newOwner) external onlyOwner {
require(_newOwner != address(0), "Address must not be null");
owner = _newOwner;
emit OwnerChanged(_newOwner);
}
}
/**
* @title ModuleRegistry
* @dev Registry of authorised modules.
* Modules must be registered before they can be authorised on a wallet.
* @author Julien Niset - <[email protected]>
*/
contract ModuleRegistry is Owned {
mapping (address => Info) internal modules;
mapping (address => Info) internal upgraders;
event ModuleRegistered(address indexed module, bytes32 name);
event ModuleDeRegistered(address module);
event UpgraderRegistered(address indexed upgrader, bytes32 name);
event UpgraderDeRegistered(address upgrader);
struct Info {
bool exists;
bytes32 name;
}
/**
* @dev Registers a module.
* @param _module The module.
* @param _name The unique name of the module.
*/
function registerModule(address _module, bytes32 _name) external onlyOwner {
require(!modules[_module].exists, "MR: module already exists");
modules[_module] = Info({exists: true, name: _name});
emit ModuleRegistered(_module, _name);
}
/**
* @dev Deregisters a module.
* @param _module The module.
*/
function deregisterModule(address _module) external onlyOwner {
require(modules[_module].exists, "MR: module does not exists");
delete modules[_module];
emit ModuleDeRegistered(_module);
}
/**
* @dev Registers an upgrader.
* @param _upgrader The upgrader.
* @param _name The unique name of the upgrader.
*/
function registerUpgrader(address _upgrader, bytes32 _name) external onlyOwner {
require(!upgraders[_upgrader].exists, "MR: upgrader already exists");
upgraders[_upgrader] = Info({exists: true, name: _name});
emit UpgraderRegistered(_upgrader, _name);
}
/**
* @dev Deregisters an upgrader.
* @param _upgrader The _upgrader.
*/
function deregisterUpgrader(address _upgrader) external onlyOwner {
require(upgraders[_upgrader].exists, "MR: upgrader does not exists");
delete upgraders[_upgrader];
emit UpgraderDeRegistered(_upgrader);
}
/**
* @dev Utility method enbaling the owner of the registry to claim any ERC20 token that was sent to the
* registry.
* @param _token The token to recover.
*/
function recoverToken(address _token) external onlyOwner {
uint total = ERC20(_token).balanceOf(address(this));
ERC20(_token).transfer(msg.sender, total);
}
/**
* @dev Gets the name of a module from its address.
* @param _module The module address.
* @return the name.
*/
function moduleInfo(address _module) external view returns (bytes32) {
return modules[_module].name;
}
/**
* @dev Gets the name of an upgrader from its address.
* @param _upgrader The upgrader address.
* @return the name.
*/
function upgraderInfo(address _upgrader) external view returns (bytes32) {
return upgraders[_upgrader].name;
}
/**
* @dev Checks if a module is registered.
* @param _module The module address.
* @return true if the module is registered.
*/
function isRegisteredModule(address _module) external view returns (bool) {
return modules[_module].exists;
}
/**
* @dev Checks if a list of modules are registered.
* @param _modules The list of modules address.
* @return true if all the modules are registered.
*/
function isRegisteredModule(address[] _modules) external view returns (bool) {
for(uint i = 0; i < _modules.length; i++) {
if (!modules[_modules[i]].exists) {
return false;
}
}
return true;
}
/**
* @dev Checks if an upgrader is registered.
* @param _upgrader The upgrader address.
* @return true if the upgrader is registered.
*/
function isRegisteredUpgrader(address _upgrader) external view returns (bool) {
return upgraders[_upgrader].exists;
}
}
/**
* @title DappRegistry
* @dev Registry of dapp contracts and methods that have been authorised by Argent.
* Registered methods can be authorised immediately for a dapp key and a wallet while
* the authoirsation of unregistered methods is delayed for 24 hours.
* @author Julien Niset - <[email protected]>
*/
contract DappRegistry is Owned {
// [contract][signature][bool]
mapping (address => mapping (bytes4 => bool)) internal authorised;
event Registered(address indexed _contract, bytes4[] _methods);
event Deregistered(address indexed _contract, bytes4[] _methods);
/**
* @dev Registers a list of methods for a dapp contract.
* @param _contract The dapp contract.
* @param _methods The dapp methods.
*/
function register(address _contract, bytes4[] _methods) external onlyOwner {
for(uint i = 0; i < _methods.length; i++) {
authorised[_contract][_methods[i]] = true;
}
emit Registered(_contract, _methods);
}
/**
* @dev Deregisters a list of methods for a dapp contract.
* @param _contract The dapp contract.
* @param _methods The dapp methods.
*/
function deregister(address _contract, bytes4[] _methods) external onlyOwner {
for(uint i = 0; i < _methods.length; i++) {
authorised[_contract][_methods[i]] = false;
}
emit Deregistered(_contract, _methods);
}
/**
* @dev Checks if a list of methods are registered for a dapp contract.
* @param _contract The dapp contract.
* @param _method The dapp methods.
* @return true if all the methods are registered.
*/
function isRegistered(address _contract, bytes4 _method) external view returns (bool) {
return authorised[_contract][_method];
}
/**
* @dev Checks if a list of methods are registered for a dapp contract.
* @param _contract The dapp contract.
* @param _methods The dapp methods.
* @return true if all the methods are registered.
*/
function isRegistered(address _contract, bytes4[] _methods) external view returns (bool) {
for(uint i = 0; i < _methods.length; i++) {
if (!authorised[_contract][_methods[i]]) {
return false;
}
}
return true;
}
}
/**
* @title Storage
* @dev Base contract for the storage of a wallet.
* @author Julien Niset - <[email protected]>
*/
contract Storage {
/**
* @dev Throws if the caller is not an authorised module.
*/
modifier onlyModule(BaseWallet _wallet) {
require(_wallet.authorised(msg.sender), "TS: must be an authorized module to call this method");
_;
}
}
/**
* @title GuardianStorage
* @dev Contract storing the state of wallets related to guardians and lock.
* The contract only defines basic setters and getters with no logic. Only modules authorised
* for a wallet can modify its state.
* @author Julien Niset - <[email protected]>
* @author Olivier Van Den Biggelaar - <[email protected]>
*/
contract GuardianStorage is Storage {
struct GuardianStorageConfig {
// the list of guardians
address[] guardians;
// the info about guardians
mapping (address => GuardianInfo) info;
// the lock's release timestamp
uint256 lock;
// the module that set the last lock
address locker;
}
struct GuardianInfo {
bool exists;
uint128 index;
}
// wallet specific storage
mapping (address => GuardianStorageConfig) internal configs;
// *************** External Functions ********************* //
/**
* @dev Lets an authorised module add a guardian to a wallet.
* @param _wallet The target wallet.
* @param _guardian The guardian to add.
*/
function addGuardian(BaseWallet _wallet, address _guardian) external onlyModule(_wallet) {
GuardianStorageConfig storage config = configs[_wallet];
config.info[_guardian].exists = true;
config.info[_guardian].index = uint128(config.guardians.push(_guardian) - 1);
}
/**
* @dev Lets an authorised module revoke a guardian from a wallet.
* @param _wallet The target wallet.
* @param _guardian The guardian to revoke.
*/
function revokeGuardian(BaseWallet _wallet, address _guardian) external onlyModule(_wallet) {
GuardianStorageConfig storage config = configs[_wallet];
address lastGuardian = config.guardians[config.guardians.length - 1];
if (_guardian != lastGuardian) {
uint128 targetIndex = config.info[_guardian].index;
config.guardians[targetIndex] = lastGuardian;
config.info[lastGuardian].index = targetIndex;
}
config.guardians.length--;
delete config.info[_guardian];
}
/**
* @dev Returns the number of guardians for a wallet.
* @param _wallet The target wallet.
* @return the number of guardians.
*/
function guardianCount(BaseWallet _wallet) external view returns (uint256) {
return configs[_wallet].guardians.length;
}
/**
* @dev Gets the list of guaridans for a wallet.
* @param _wallet The target wallet.
* @return the list of guardians.
*/
function getGuardians(BaseWallet _wallet) external view returns (address[]) {
GuardianStorageConfig storage config = configs[_wallet];
address[] memory guardians = new address[](config.guardians.length);
for (uint256 i = 0; i < config.guardians.length; i++) {
guardians[i] = config.guardians[i];
}
return guardians;
}
/**
* @dev Checks if an account is a guardian for a wallet.
* @param _wallet The target wallet.
* @param _guardian The account.
* @return true if the account is a guardian for a wallet.
*/
function isGuardian(BaseWallet _wallet, address _guardian) external view returns (bool) {
return configs[_wallet].info[_guardian].exists;
}
/**
* @dev Lets an authorised module set the lock for a wallet.
* @param _wallet The target wallet.
* @param _releaseAfter The epoch time at which the lock should automatically release.
*/
function setLock(BaseWallet _wallet, uint256 _releaseAfter) external onlyModule(_wallet) {
configs[_wallet].lock = _releaseAfter;
if(_releaseAfter != 0 && msg.sender != configs[_wallet].locker) {
configs[_wallet].locker = msg.sender;
}
}
/**
* @dev Checks if the lock is set for a wallet.
* @param _wallet The target wallet.
* @return true if the lock is set for the wallet.
*/
function isLocked(BaseWallet _wallet) external view returns (bool) {
return configs[_wallet].lock > now;
}
/**
* @dev Gets the time at which the lock of a wallet will release.
* @param _wallet The target wallet.
* @return the time at which the lock of a wallet will release, or zero if there is no lock set.
*/
function getLock(BaseWallet _wallet) external view returns (uint256) {
return configs[_wallet].lock;
}
/**
* @dev Gets the address of the last module that modified the lock for a wallet.
* @param _wallet The target wallet.
* @return the address of the last module that modified the lock for a wallet.
*/
function getLocker(BaseWallet _wallet) external view returns (address) {
return configs[_wallet].locker;
}
}
/**
* @title DappStorage
* @dev Contract storing the state of wallets related to authorised dapps.
* The contract only defines basic setters and getters with no logic. Only modules authorised
* for a wallet can modify its state.
* @author Olivier Van Den Biggelaar - <[email protected]>
*/
contract DappStorage is Storage {
// [wallet][dappkey][contract][signature][bool]
mapping (address => mapping (address => mapping (address => mapping (bytes4 => bool)))) internal whitelistedMethods;
// *************** External Functions ********************* //
/**
* @dev (De)authorizes an external contract's methods to be called by a dapp key of the wallet.
* @param _wallet The wallet.
* @param _dapp The address of the signing key.
* @param _contract The contract address.
* @param _signatures The methods' signatures.
* @param _authorized true to whitelist, false to blacklist.
*/
function setMethodAuthorization(
BaseWallet _wallet,
address _dapp,
address _contract,
bytes4[] _signatures,
bool _authorized
)
external
onlyModule(_wallet)
{
for(uint i = 0; i < _signatures.length; i++) {
whitelistedMethods[_wallet][_dapp][_contract][_signatures[i]] = _authorized;
}
}
/**
* @dev Gets the authorization status for an external contract's method.
* @param _wallet The wallet.
* @param _dapp The address of the signing key.
* @param _contract The contract address.
* @param _signature The call signature.
* @return true if the method is whitelisted, false otherwise
*/
function getMethodAuthorization(BaseWallet _wallet, address _dapp, address _contract, bytes4 _signature) external view returns (bool) {
return whitelistedMethods[_wallet][_dapp][_contract][_signature];
}
}
/**
* @title BaseWallet
* @dev Simple modular wallet that authorises modules to call its invoke() method.
* Based on https://gist.github.com/Arachnid/a619d31f6d32757a4328a428286da186 by
* @author Julien Niset - <[email protected]>
*/
contract BaseWallet {
// The implementation of the proxy
address public implementation;
// The owner
address public owner;
// The authorised modules
mapping (address => bool) public authorised;
// The enabled static calls
mapping (bytes4 => address) public enabled;
// The number of modules
uint public modules;
event AuthorisedModule(address indexed module, bool value);
event EnabledStaticCall(address indexed module, bytes4 indexed method);
event Invoked(address indexed module, address indexed target, uint indexed value, bytes data);
event Received(uint indexed value, address indexed sender, bytes data);
event OwnerChanged(address owner);
/**
* @dev Throws if the sender is not an authorised module.
*/
modifier moduleOnly {
require(authorised[msg.sender], "BW: msg.sender not an authorized module");
_;
}
/**
* @dev Inits the wallet by setting the owner and authorising a list of modules.
* @param _owner The owner.
* @param _modules The modules to authorise.
*/
function init(address _owner, address[] _modules) external {
require(owner == address(0) && modules == 0, "BW: wallet already initialised");
require(_modules.length > 0, "BW: construction requires at least 1 module");
owner = _owner;
modules = _modules.length;
for(uint256 i = 0; i < _modules.length; i++) {
require(authorised[_modules[i]] == false, "BW: module is already added");
authorised[_modules[i]] = true;
Module(_modules[i]).init(this);
emit AuthorisedModule(_modules[i], true);
}
}
/**
* @dev Enables/Disables a module.
* @param _module The target module.
* @param _value Set to true to authorise the module.
*/
function authoriseModule(address _module, bool _value) external moduleOnly {
if (authorised[_module] != _value) {
if(_value == true) {
modules += 1;
authorised[_module] = true;
Module(_module).init(this);
}
else {
modules -= 1;
require(modules > 0, "BW: wallet must have at least one module");
delete authorised[_module];
}
emit AuthorisedModule(_module, _value);
}
}
/**
* @dev Enables a static method by specifying the target module to which the call
* must be delegated.
* @param _module The target module.
* @param _method The static method signature.
*/
function enableStaticCall(address _module, bytes4 _method) external moduleOnly {
require(authorised[_module], "BW: must be an authorised module for static call");
enabled[_method] = _module;
emit EnabledStaticCall(_module, _method);
}
/**
* @dev Sets a new owner for the wallet.
* @param _newOwner The new owner.
*/
function setOwner(address _newOwner) external moduleOnly {
require(_newOwner != address(0), "BW: address cannot be null");
owner = _newOwner;
emit OwnerChanged(_newOwner);
}
/**
* @dev Performs a generic transaction.
* @param _target The address for the transaction.
* @param _value The value of the transaction.
* @param _data The data of the transaction.
*/
function invoke(address _target, uint _value, bytes _data) external moduleOnly {
// solium-disable-next-line security/no-call-value
require(_target.call.value(_value)(_data), "BW: call to target failed");
emit Invoked(msg.sender, _target, _value, _data);
}
/**
* @dev This method makes it possible for the wallet to comply to interfaces expecting the wallet to
* implement specific static methods. It delegates the static call to a target contract if the data corresponds
* to an enabled method, or logs the call otherwise.
*/
function() public payable {
if(msg.data.length > 0) {
address module = enabled[msg.sig];
if(module == address(0)) {
emit Received(msg.value, msg.sender, msg.data);
}
else {
require(authorised[module], "BW: must be an authorised module for static call");
// solium-disable-next-line security/no-inline-assembly
assembly {
calldatacopy(0, 0, calldatasize())
let result := staticcall(gas, module, 0, calldatasize(), 0, 0)
returndatacopy(0, 0, returndatasize())
switch result
case 0 {revert(0, returndatasize())}
default {return (0, returndatasize())}
}
}
}
}
}
/**
* @title DappManager
* @dev Module to enable authorised dapps to transfer tokens (ETH or ERC20) on behalf of a wallet.
* @author Olivier Van Den Biggelaar - <[email protected]>
*/
contract DappManager is BaseModule, RelayerModule, LimitManager {
bytes32 constant NAME = "DappManager";
bytes4 constant internal CONFIRM_AUTHORISATION_PREFIX = bytes4(keccak256("confirmAuthorizeCall(address,address,address,bytes4[])"));
bytes4 constant internal CALL_CONTRACT_PREFIX = bytes4(keccak256("callContract(address,address,address,uint256,bytes)"));
// Mock token address for ETH
address constant internal ETH_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
using SafeMath for uint256;
// // The Guardian storage
GuardianStorage public guardianStorage;
// The Dapp limit storage
DappStorage public dappStorage;
// The authorised dapp registry
DappRegistry public dappRegistry;
// The security period
uint256 public securityPeriod;
// the security window
uint256 public securityWindow;
struct DappManagerConfig {
// the time at which a dapp authorisation can be confirmed
mapping (bytes32 => uint256) pending;
}
// the wallet specific storage
mapping (address => DappManagerConfig) internal configs;
// *************** Events *************************** //
event Transfer(address indexed wallet, address indexed token, uint256 indexed amount, address to, bytes data);
event ContractCallAuthorizationRequested(address indexed _wallet, address indexed _dapp, address indexed _contract, bytes4[] _signatures);
event ContractCallAuthorizationCanceled(address indexed _wallet, address indexed _dapp, address indexed _contract, bytes4[] _signatures);
event ContractCallAuthorized(address indexed _wallet, address indexed _dapp, address indexed _contract, bytes4[] _signatures);
event ContractCallDeauthorized(address indexed _wallet, address indexed _dapp, address indexed _contract, bytes4[] _signatures);
// *************** Modifiers *************************** //
/**
* @dev Throws unless called by this contract or by _dapp.
*/
modifier onlyExecuteOrDapp(address _dapp) {
require(msg.sender == address(this) || msg.sender == _dapp, "DM: must be called by dapp or via execute()");
_;
}
/**
* @dev Throws if the wallet is locked.
*/
modifier onlyWhenUnlocked(BaseWallet _wallet) {
// solium-disable-next-line security/no-block-members
require(!guardianStorage.isLocked(_wallet), "DM: wallet must be unlocked");
_;
}
// *************** Constructor ********************** //
constructor(
ModuleRegistry _registry,
DappRegistry _dappRegistry,
DappStorage _dappStorage,
GuardianStorage _guardianStorage,
uint256 _securityPeriod,
uint256 _securityWindow,
uint256 _defaultLimit
)
BaseModule(_registry, NAME)
LimitManager(_defaultLimit)
public
{
dappStorage = _dappStorage;
guardianStorage = _guardianStorage;
dappRegistry = _dappRegistry;
securityPeriod = _securityPeriod;
securityWindow = _securityWindow;
}
// *************** External/Public Functions ********************* //
/**
* @dev lets a dapp call an arbitrary contract from a wallet.
* @param _wallet The target wallet.
* @param _dapp The authorised dapp.
* @param _to The destination address
* @param _amount The amoun6 of ether to transfer
* @param _data The data for the transaction
*/
function callContract(
BaseWallet _wallet,
address _dapp,
address _to,
uint256 _amount,
bytes _data
)
external
onlyExecuteOrDapp(_dapp)
onlyWhenUnlocked(_wallet)
{
require(isAuthorizedCall(_wallet, _dapp, _to, _data), "DM: Contract call not authorized");
require(checkAndUpdateDailySpent(_wallet, _amount), "DM: Dapp limit exceeded");
doCall(_wallet, _to, _amount, _data);
}
/**
* @dev Authorizes an external contract's methods to be called by a dapp key of the wallet.
* @param _wallet The wallet.
* @param _dapp The address of the signing key.
* @param _contract The target contract address.
* @param _signatures The method signatures.
*/
function authorizeCall(
BaseWallet _wallet,
address _dapp,
address _contract,
bytes4[] _signatures
)
external
onlyOwner(_wallet)
onlyWhenUnlocked(_wallet)
{
require(_contract != address(0), "DM: Contract address cannot be null");
if(dappRegistry.isRegistered(_contract, _signatures)) {
// authorise immediately
dappStorage.setMethodAuthorization(_wallet, _dapp, _contract, _signatures, true);
emit ContractCallAuthorized(_wallet, _dapp, _contract, _signatures);
}
else {
bytes32 id = keccak256(abi.encodePacked(address(_wallet), _dapp, _contract, _signatures, true));
configs[_wallet].pending[id] = now + securityPeriod;
emit ContractCallAuthorizationRequested(_wallet, _dapp, _contract, _signatures);
}
}
/**
* @dev Deauthorizes an external contract's methods to be called by a dapp key of the wallet.
* @param _wallet The wallet.
* @param _dapp The address of the signing key.
* @param _contract The target contract address.
* @param _signatures The method signatures.
*/
function deauthorizeCall(
BaseWallet _wallet,
address _dapp,
address _contract,
bytes4[] _signatures
)
external
onlyOwner(_wallet)
onlyWhenUnlocked(_wallet)
{
dappStorage.setMethodAuthorization(_wallet, _dapp, _contract, _signatures, false);
emit ContractCallDeauthorized(_wallet, _dapp, _contract, _signatures);
}
/**
* @dev Confirms the authorisation of an external contract's methods to be called by a dapp key of the wallet.
* @param _wallet The wallet.
* @param _dapp The address of the signing key.
* @param _contract The target contract address.
* @param _signatures The method signatures.
*/
function confirmAuthorizeCall(
BaseWallet _wallet,
address _dapp,
address _contract,
bytes4[] _signatures
)
external
onlyWhenUnlocked(_wallet)
{
bytes32 id = keccak256(abi.encodePacked(address(_wallet), _dapp, _contract, _signatures, true));
DappManagerConfig storage config = configs[_wallet];
require(config.pending[id] > 0, "DM: No pending authorisation for the target dapp");
require(config.pending[id] < now, "DM: Too early to confirm pending authorisation");
require(now < config.pending[id] + securityWindow, "GM: Too late to confirm pending authorisation");
dappStorage.setMethodAuthorization(_wallet, _dapp, _contract, _signatures, true);
delete config.pending[id];
emit ContractCallAuthorized(_wallet, _dapp, _contract, _signatures);
}
/**
* @dev Cancels an authorisation request for an external contract's methods to be called by a dapp key of the wallet.
* @param _wallet The wallet.
* @param _dapp The address of the signing key.
* @param _contract The target contract address.
* @param _signatures The method signatures.
*/
function cancelAuthorizeCall(
BaseWallet _wallet,
address _dapp,
address _contract,
bytes4[] _signatures
)
public
onlyOwner(_wallet)
onlyWhenUnlocked(_wallet)
{
bytes32 id = keccak256(abi.encodePacked(address(_wallet), _dapp, _contract, _signatures, true));
DappManagerConfig storage config = configs[_wallet];
require(config.pending[id] > 0, "DM: No pending authorisation for the target dapp");
delete config.pending[id];
emit ContractCallAuthorizationCanceled(_wallet, _dapp, _contract, _signatures);
}
/**
* @dev Checks if a contract call is authorized for a given signing key.
* @param _wallet The target wallet.
* @param _dapp The address of the signing key.
* @param _to The address of the contract to call
* @param _data The call data
* @return true if the contract call is authorised for the wallet.
*/
function isAuthorizedCall(BaseWallet _wallet, address _dapp, address _to, bytes _data) public view returns (bool _isAuthorized) {
if(_data.length >= 4) {
return dappStorage.getMethodAuthorization(_wallet, _dapp, _to, functionPrefix(_data));
}
// the fallback method must be authorized
return dappStorage.getMethodAuthorization(_wallet, _dapp, _to, "");
}
/**
* @dev Lets the owner of a wallet change its dapp limit.
* The limit is expressed in ETH. Changes to the limit take 24 hours.
* @param _wallet The target wallet.
* @param _newLimit The new limit.
*/
function changeLimit(BaseWallet _wallet, uint256 _newLimit) public onlyOwner(_wallet) onlyWhenUnlocked(_wallet) {
changeLimit(_wallet, _newLimit, securityPeriod);
}
/**
* @dev Convenience method to disable the limit
* The limit is disabled by setting it to an arbitrary large value.
* @param _wallet The target wallet.
*/
function disableLimit(BaseWallet _wallet) external onlyOwner(_wallet) onlyWhenUnlocked(_wallet) {
changeLimit(_wallet, LIMIT_DISABLED, securityPeriod);
}
/**
* @dev Internal method to instruct a wallet to call an extrenal contract.
* @param _wallet The target wallet.
* @param _to The external contract.
* @param _value The amount of ETH for the call
* @param _data The data of the call.
*/
function doCall(BaseWallet _wallet, address _to, uint256 _value, bytes _data) internal {
_wallet.invoke(_to, _value, _data);
emit Transfer(_wallet, ETH_TOKEN, _value, _to, _data);
}
// *************** Implementation of RelayerModule methods ********************* //
// Overrides refund to add the refund in the daily limit.
function refund(BaseWallet _wallet, uint _gasUsed, uint _gasPrice, uint _gasLimit, uint _signatures, address _relayer) internal {
// 21000 (transaction) + 7620 (execution of refund) + 7324 (execution of updateDailySpent) + 672 to log the event + _gasUsed
uint256 amount = 36616 + _gasUsed;
if(_gasPrice > 0 && _signatures > 0 && amount <= _gasLimit) {
if(_gasPrice > tx.gasprice) {
amount = amount * tx.gasprice;
}
else {
amount = amount * _gasPrice;
}
updateDailySpent(_wallet, uint128(getCurrentLimit(_wallet)), amount);
_wallet.invoke(_relayer, amount, "");
}
}
// Overrides verifyRefund to add the refund in the daily limit.
function verifyRefund(BaseWallet _wallet, uint _gasUsed, uint _gasPrice, uint _signatures) internal view returns (bool) {
if(_gasPrice > 0 && _signatures > 0 && (
address(_wallet).balance < _gasUsed * _gasPrice
|| isWithinDailyLimit(_wallet, getCurrentLimit(_wallet), _gasUsed * _gasPrice) == false
|| _wallet.authorised(this) == false
))
{
return false;
}
return true;
}
// Overrides to use the incremental nonce and save some gas
function checkAndUpdateUniqueness(BaseWallet _wallet, uint256 _nonce, bytes32 _signHash) internal returns (bool) {
return checkAndUpdateNonce(_wallet, _nonce);
}
function validateSignatures(BaseWallet _wallet, bytes _data, bytes32 _signHash, bytes _signatures) internal view returns (bool) {
address signer = recoverSigner(_signHash, _signatures, 0);
if(functionPrefix(_data) == CALL_CONTRACT_PREFIX) {
// "RM: Invalid dapp in data"
if(_data.length < 68) {
return false;
}
address dapp;
// solium-disable-next-line security/no-inline-assembly
assembly {
//_data = {length:32}{sig:4}{_wallet:32}{_dapp:32}{...}
dapp := mload(add(_data, 0x44))
}
return dapp == signer; // "DM: dapp and signer must be the same"
} else {
return isOwner(_wallet, signer); // "DM: signer must be owner"
}
}
function getRequiredSignatures(BaseWallet _wallet, bytes _data) internal view returns (uint256) {
bytes4 methodId = functionPrefix(_data);
if (methodId == CONFIRM_AUTHORISATION_PREFIX) {
return 0;
}
return 1;
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["101", "842"]}, {"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["574", "1202"]}, {"defect": "Uninitialized_storage", "type": "Code_specification", "severity": "Low", "lines": ["imitstoragelimit.L450", "imitstoragelimit.L460", "imitstoragelimit.L431", "imitstoragelimit.L491", "imitstoragelimit.L417", "527", "472", "1498", "1471", "1025", "1051", "1014"]}, {"defect": "Frozen_Ether", "type": "Code_specification", "severity": "Medium", "lines": ["600"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["1165", "727", "778", "552", "1116", "903", "985", "600"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["1168", "1305", "1299"]}, {"defect": "Balance_manipulation", "type": "Business_logic", "severity": "Medium", "lines": ["1572", "324"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["75", "1192", "12", "412", "761", "1243", "18"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["308", "311", "1218", "1223", "476", "479", "1560", "1563", "263", "324", "188", "1572", "1428", "1016", "304", "IMIT_DISABLED.L368", "1557"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["1087", "545", "531", "509", "474", "462", "1473", "1474"]}] | [{"check": "arbitrary-send", "impact": "High", "confidence": "Medium", "lines": {"DappManager.sol": [1261]}}, {"check": "controlled-array-length", "impact": "High", "confidence": "Medium", "lines": {"DappManager.sol": [1016]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1279]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [354, 355, 356, 357]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [288, 289, 284, 285, 286, 287]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [341, 342, 343, 344, 345]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1600, 1601, 1597, 1598, 1599]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [324, 325, 326]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [245]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1217]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1572, 1573, 1574, 1575, 1576]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1203]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"DappManager.sol": [1168]}}, {"check": "constant-function-asm", "impact": "Medium", "confidence": "Medium", "lines": {"DappManager.sol": [288, 289, 290, 291, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287]}}, {"check": "constant-function-asm", "impact": "Medium", "confidence": "Medium", "lines": {"DappManager.sol": [337, 338, 339, 340, 341, 342, 343, 344, 345, 346]}}, {"check": "constant-function-asm", "impact": "Medium", "confidence": "Medium", "lines": {"DappManager.sol": [1600, 1601, 1602, 1603, 1604, 1605, 1588, 1589, 1590, 1591, 1592, 1593, 1594, 1595, 1596, 1597, 1598, 1599]}}, {"check": "constant-function-asm", "impact": "Medium", "confidence": "Medium", "lines": {"DappManager.sol": [352, 353, 354, 355, 356, 357, 351]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"DappManager.sol": [684, 685, 686, 687, 688, 689]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"DappManager.sol": [303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"DappManager.sol": [323, 324, 325, 326, 327, 328, 329, 330]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"DappManager.sol": [713, 714, 715, 716, 717, 718, 719, 720, 721]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"DappManager.sol": [244, 245, 246, 247, 248, 249, 250]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"DappManager.sol": [705, 706, 707, 708]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DappManager.sol": [1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1270, 1271, 1272, 1273, 1274, 1275, 1276, 1277, 1278, 1279]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DappManager.sol": [734]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DappManager.sol": [585, 586, 587, 588, 589]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DappManager.sol": [729]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DappManager.sol": [576, 577, 573, 574, 575]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DappManager.sol": [730]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DappManager.sol": [732]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DappManager.sol": [1528, 1526, 1527]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DappManager.sol": [728]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DappManager.sol": [733]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DappManager.sol": [611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DappManager.sol": [608, 609, 602, 603, 604, 605, 606, 607]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DappManager.sol": [1487, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1497, 1498, 1499, 1500, 1501, 1502]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"DappManager.sol": [731]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"DappManager.sol": [544, 545, 546, 547, 548, 549]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [192]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1261]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1200]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1205]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [565]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1526]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [840]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1259]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [891]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1065]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1041]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [430]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1555]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [798]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [459]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [819]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1441]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1489]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [224]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [303]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1390]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1444]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [303]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [323]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1215]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1024]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1555]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [220]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [941]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1414]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [337]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [877]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1074]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1132]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [765]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [470]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [276]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1443]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [798]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [544]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1571]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [928]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [544]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1024]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [490]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [303]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1104]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1050]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1588]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1547]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [916]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1535]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [222]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1462]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1134]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1391]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [829]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [506]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1389]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1215]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [109]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1133]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [204]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [430]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1607]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [89]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [416]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1154]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1571]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1197]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1392]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1065]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1491]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [258]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [219]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1465]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1154]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [175]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [258]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1571]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [173]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [351]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1154]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1413]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [951]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1555]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [323]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1555]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1464]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1588]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [951]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1237]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1571]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1588]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1013]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1547]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1411]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1095]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [99]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [808]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [819]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [244]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [80]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [109]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [928]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1555]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [490]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [859]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1237]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1512]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [177]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1463]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [585]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [178]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [850]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [544]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1512]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [868]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [225]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [337]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1154]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [223]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1547]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [323]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [506]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1588]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1197]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1247]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [526]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1013]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [303]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [526]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1388]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [89]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1259]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1526]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1584]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1412]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [430]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1074]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1490]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1547]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [303]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [176]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [941]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [303]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [506]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1512]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1512]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [221]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [244]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [323]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1442]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1136]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [585]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [449]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1135]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [916]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1259]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1488]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1584]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1086]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [1555]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [526]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"DappManager.sol": [174]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1428]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [514]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [566]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1077]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1032]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [437]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1142]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1016]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [437]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1477]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1451]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1227]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1262]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1429]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1527]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1424]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1400]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1206]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [197]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1536]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1501]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1549]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [545]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [509]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1087]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [462]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [1474]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [474]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [433]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"DappManager.sol": [531]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"DappManager.sol": [262]}}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium", "lines": {"DappManager.sol": [842]}}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium", "lines": {"DappManager.sol": [101]}}] | [{"error": "Integer Underflow.", "line": 1262, "level": "Warning"}, {"error": "Integer Overflow.", "line": 1262, "level": "Warning"}, {"error": "Re-Entrancy Vulnerability.", "line": 1261, "level": "Warning"}, {"error": "Integer Underflow.", "line": 479, "level": "Warning"}, {"error": "Integer Overflow.", "line": 172, "level": "Warning"}, {"error": "Integer Overflow.", "line": 1512, "level": "Warning"}, {"error": "Integer Overflow.", "line": 451, "level": "Warning"}, {"error": "Integer Overflow.", "line": 476, "level": "Warning"}, {"error": "Integer Overflow.", "line": 1487, "level": "Warning"}, {"error": "Integer Overflow.", "line": 418, "level": "Warning"}, {"error": "Integer Overflow.", "line": 184, "level": "Warning"}, {"error": "Integer Overflow.", "line": 462, "level": "Warning"}, {"error": "Integer Overflow.", "line": 472, "level": "Warning"}, {"error": "Callstack Depth Attack Vulnerability.", "line": 192, "level": "Warning"}, {"error": "Integer Overflow.", "line": 930, "level": "Warning"}, {"error": "Integer Overflow.", "line": 953, "level": "Warning"}, {"error": "Integer Overflow.", "line": 918, "level": "Warning"}, {"error": "Integer Overflow.", "line": 951, "level": "Warning"}, {"error": "Integer Overflow.", "line": 1142, "level": "Warning"}, {"error": "Integer Underflow.", "line": 1026, "level": "Warning"}, {"error": "Integer Overflow.", "line": 1066, "level": "Warning"}, {"error": "Integer Overflow.", "line": 1075, "level": "Warning"}, {"error": "Integer Overflow.", "line": 1076, "level": "Warning"}, {"error": "Integer Overflow.", "line": 1077, "level": "Warning"}, {"error": "Integer Overflow.", "line": 1015, "level": "Warning"}, {"error": "Integer Overflow.", "line": 1087, "level": "Warning"}, {"error": "Integer Overflow.", "line": 1096, "level": "Warning"}, {"error": "Integer Overflow.", "line": 1105, "level": "Warning"}, {"error": "Integer Overflow.", "line": 821, "level": "Warning"}, {"error": "Integer Overflow.", "line": 879, "level": "Warning"}, {"error": "Integer Overflow.", "line": 877, "level": "Warning"}, {"error": "Integer Overflow.", "line": 860, "level": "Warning"}, {"error": "Integer Overflow.", "line": 800, "level": "Warning"}, {"error": "Integer Overflow.", "line": 851, "level": "Warning"}, {"error": "Integer Overflow.", "line": 573, "level": "Warning"}] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 557, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 559, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1305, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 234, "severity": 1}, {"rule": "SOLIDITY_ARRAY_LENGTH_MANIPULATION", "line": 1032, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 574, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 878, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 917, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 929, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 952, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 1053, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 1141, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 1202, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 351, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 574, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 878, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 917, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 929, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 952, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 1053, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 1141, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 1202, "severity": 2}, {"rule": "SOLIDITY_LOCKED_MONEY", "line": 600, "severity": 3}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 370, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 554, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 1307, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 276, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 337, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 351, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 1588, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 1270, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 149, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 159, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 159, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 222, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 276, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 337, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 351, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 573, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 1491, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 1512, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 1547, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 1588, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 1588, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 1607, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 284, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 341, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 354, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 1279, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 1597, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1299, "severity": 1}] | [{"constant":true,"inputs":[],"name":"securityWindow","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_wallet","type":"address"}],"name":"init","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_wallet","type":"address"}],"name":"getNonce","outputs":[{"name":"nonce","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"dappStorage","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_wallet","type":"address"},{"name":"_dapp","type":"address"},{"name":"_contract","type":"address"},{"name":"_signatures","type":"bytes4[]"}],"name":"deauthorizeCall","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_wallet","type":"address"}],"name":"getCurrentLimit","outputs":[{"name":"_currentLimit","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_wallet","type":"address"},{"name":"_dapp","type":"address"},{"name":"_contract","type":"address"},{"name":"_signatures","type":"bytes4[]"}],"name":"authorizeCall","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_wallet","type":"address"},{"name":"_module","type":"address"}],"name":"addModule","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_wallet","type":"address"},{"name":"_dapp","type":"address"},{"name":"_to","type":"address"},{"name":"_data","type":"bytes"}],"name":"isAuthorizedCall","outputs":[{"name":"_isAuthorized","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_wallet","type":"address"},{"name":"_dapp","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_data","type":"bytes"}],"name":"callContract","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_wallet","type":"address"}],"name":"getDailyUnspent","outputs":[{"name":"_unspent","type":"uint256"},{"name":"_periodEnd","type":"uint64"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"securityPeriod","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"recoverToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_wallet","type":"address"}],"name":"getPendingLimit","outputs":[{"name":"_pendingLimit","type":"uint256"},{"name":"_changeAfter","type":"uint64"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_wallet","type":"address"}],"name":"disableLimit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_wallet","type":"address"},{"name":"_dapp","type":"address"},{"name":"_contract","type":"address"},{"name":"_signatures","type":"bytes4[]"}],"name":"cancelAuthorizeCall","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_wallet","type":"address"},{"name":"_data","type":"bytes"},{"name":"_nonce","type":"uint256"},{"name":"_signatures","type":"bytes"},{"name":"_gasPrice","type":"uint256"},{"name":"_gasLimit","type":"uint256"}],"name":"execute","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_wallet","type":"address"},{"name":"_newLimit","type":"uint256"}],"name":"changeLimit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"relayer","outputs":[{"name":"nonce","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"guardianStorage","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_wallet","type":"address"},{"name":"_dapp","type":"address"},{"name":"_contract","type":"address"},{"name":"_signatures","type":"bytes4[]"}],"name":"confirmAuthorizeCall","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"dappRegistry","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"defaultLimit","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_registry","type":"address"},{"name":"_dappRegistry","type":"address"},{"name":"_dappStorage","type":"address"},{"name":"_guardianStorage","type":"address"},{"name":"_securityPeriod","type":"uint256"},{"name":"_securityWindow","type":"uint256"},{"name":"_defaultLimit","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"wallet","type":"address"},{"indexed":true,"name":"token","type":"address"},{"indexed":true,"name":"amount","type":"uint256"},{"indexed":false,"name":"to","type":"address"},{"indexed":false,"name":"data","type":"bytes"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_wallet","type":"address"},{"indexed":true,"name":"_dapp","type":"address"},{"indexed":true,"name":"_contract","type":"address"},{"indexed":false,"name":"_signatures","type":"bytes4[]"}],"name":"ContractCallAuthorizationRequested","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_wallet","type":"address"},{"indexed":true,"name":"_dapp","type":"address"},{"indexed":true,"name":"_contract","type":"address"},{"indexed":false,"name":"_signatures","type":"bytes4[]"}],"name":"ContractCallAuthorizationCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_wallet","type":"address"},{"indexed":true,"name":"_dapp","type":"address"},{"indexed":true,"name":"_contract","type":"address"},{"indexed":false,"name":"_signatures","type":"bytes4[]"}],"name":"ContractCallAuthorized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_wallet","type":"address"},{"indexed":true,"name":"_dapp","type":"address"},{"indexed":true,"name":"_contract","type":"address"},{"indexed":false,"name":"_signatures","type":"bytes4[]"}],"name":"ContractCallDeauthorized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"wallet","type":"address"},{"indexed":true,"name":"newLimit","type":"uint256"},{"indexed":true,"name":"startAfter","type":"uint64"}],"name":"LimitChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"wallet","type":"address"},{"indexed":true,"name":"success","type":"bool"},{"indexed":false,"name":"signedHash","type":"bytes32"}],"name":"TransactionExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"name","type":"bytes32"}],"name":"ModuleCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"wallet","type":"address"}],"name":"ModuleInitialised","type":"event"}] | v0.4.24+commit.e67f0147 | true | 999 | 000000000000000000000000c17d432bd8e8850fd7b32b0270f5afac65db01050000000000000000000000003d4a342fecd590f59cc2245d21f0de88063c97f900000000000000000000000079d7b5ca53771137f762813ab017032abb7f1ac100000000000000000000000044da3a8051ba88eab0440db3779cab9d679ae76f0000000000000000000000000000000000000000000000000000000000015180000000000000000000000000000000000000000000000000000000000000a8c00000000000000000000000000000000000000000000000008ac7230489e80000 | Default | false | bzzr://d82c77ec7dff62687d8053f10445e9640b30edc57d2beac5e22fa11aa7c00fc1 |
|||
CONUNToken2 | 0x4dd672e77c795844fe3a464ef8ef0faae617c8fb | Solidity | pragma solidity ^0.4.22;
interface tokenRecipient {
function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external;
}
contract CONUNToken2 {
// Public variables of the token
string public name;
string public symbol;
uint8 public decimals = 18;
uint256 public totalSupply;
// This creates an array with all balances
mapping (address => uint256) public balanceOf;
mapping (address => mapping (address => uint256)) public allowance;
// This generates a public event on the blockchain that will notify clients
event Transfer(address indexed from, address indexed to, uint256 value);
// This generates a public event on the blockchain that will notify clients
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
// This notifies clients about the amount burnt.
event Burn(address indexed from, uint256 value);
/**
* Constructor function
*
* Initializes contract with initial supply tokens to the creator of the contract
*/
constructor(
uint256 initialSupply,
string 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);
// This 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 account
*
* Send `_value` tokens to `_to` on behalf of `_from`
*
* @param _from The address of the sender
* @param _to The address of the recipient
* @param _value The amount to send
*/
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
require(_value <= allowance[_from][msg.sender]); // Check allowance
allowance[_from][msg.sender] -= _value;
_transfer(_from, _to, _value);
return true;
}
/**
* Set allowance for other address
*
* Allow `_spender` to spend no more than `_value` tokens on your behalf
*
* @param _spender The address authorized to spend
* @param _value The max amount they can spend
*/
function approve(address _spender, uint256 _value) public returns (bool success) {
allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* Set allowance for other address and notify
*
* Allow `_spender` to spend no more than `_value` tokens on your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value The max amount they can spend
* @param _extraData Some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/**
* Internal burn, only can be called by this contract
*/
function _burn(address _from, uint256 _value) internal {
balanceOf[_from] -= _value; // Subtract from
totalSupply -= _value; // Update totalSupply
}
/**
* 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
_burn(msg.sender, _value);
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
allowance[_from][msg.sender] -= _value; // Subtract from the sender's allowance
_burn(_from, _value);
emit Burn(_from, _value);
return true;
}
} | [{"defect": "Balance_manipulation", "type": "Business_logic", "severity": "Medium", "lines": ["62"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["130", "38", "158", "59", "57", "129", "89", "55"]}] | [{"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"CONUNToken2.sol": [12]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CONUNToken2.sol": [73, 74, 75, 76]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CONUNToken2.sol": [140, 141, 142, 143, 144, 145]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CONUNToken2.sol": [160, 161, 162, 155, 156, 157, 158, 159]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CONUNToken2.sol": [117, 118, 119, 120, 121, 122, 123]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CONUNToken2.sol": [87, 88, 89, 90, 91, 92]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"CONUNToken2.sol": [1]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CONUNToken2.sol": [140]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CONUNToken2.sol": [117]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CONUNToken2.sol": [87]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CONUNToken2.sol": [102]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CONUNToken2.sol": [3, 4, 5]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CONUNToken2.sol": [73]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CONUNToken2.sol": [87]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CONUNToken2.sol": [155]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CONUNToken2.sol": [102]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CONUNToken2.sol": [117]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CONUNToken2.sol": [155]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CONUNToken2.sol": [87]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CONUNToken2.sol": [73]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CONUNToken2.sol": [117]}}] | [{"error": "Integer Underflow.", "line": 10, "level": "Warning"}, {"error": "Integer Underflow.", "line": 130, "level": "Warning"}, {"error": "Integer Underflow.", "line": 11, "level": "Warning"}, {"error": "Integer Overflow.", "line": 55, "level": "Warning"}, {"error": "Integer Overflow.", "line": 117, "level": "Warning"}, {"error": "Integer Overflow.", "line": 62, "level": "Warning"}] | [{"rule": "SOLIDITY_ERC20_APPROVE", "line": 102, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 35, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 36, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 117, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"uint256"}],"name":"burn","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_value","type":"uint256"}],"name":"burnFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"initialSupply","type":"uint256"},{"name":"tokenName","type":"string"},{"name":"tokenSymbol","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Burn","type":"event"}] | v0.4.25+commit.59dbf8f1 | true | 200 | 000000000000000000000000000000000000000000000000000000012a05f200000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000005434f4e554e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003434f4e0000000000000000000000000000000000000000000000000000000000 | Default | false | bzzr://8bcb60df0bba121017cb23d4533635c5f236e851d02646fdace44cf400191580 |
|||
GIOCoin | 0xdf42056228002bdfb4bac583c7348e7ae24c1565 | Solidity | // File: BasicToken.sol
pragma solidity ^0.4.24;
import "./ERC20Basic.sol";
import "./SafeMath.sol";
/**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/
contract BasicToken is ERC20Basic {
using SafeMath for uint256;
mapping(address => uint256) internal balances;
uint256 internal 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(_value <= balances[msg.sender]);
require(_to != address(0));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}
}
// File: CappedToken.sol
pragma solidity ^0.4.24;
import "./MintableToken.sol";
/**
* @title Capped token
* @dev Mintable token with a token cap.
*/
contract CappedToken is MintableToken {
uint256 public cap;
constructor(uint256 _cap) public {
require(_cap > 0);
cap = _cap;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(
address _to,
uint256 _amount
)
public
returns (bool)
{
require(totalSupply_.add(_amount) <= cap);
return super.mint(_to, _amount);
}
}
// File: CapToken.sol
pragma solidity ^0.4.24;
import "./MintableToken.sol";
import "./CappedToken.sol";
contract GIOCoin is CappedToken {
string public name = "Gio Coin";
string public symbol = "GIO";
uint8 public decimals = 18;
constructor(
uint256 _cap
)
public
CappedToken( _cap ) {
}
}
// File: ERC20.sol
pragma solidity ^0.4.24;
import "./ERC20Basic.sol";
/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
contract ERC20 is ERC20Basic {
function allowance(address _owner, address _spender)
public view returns (uint256);
function transferFrom(address _from, address _to, uint256 _value)
public returns (bool);
function approve(address _spender, uint256 _value) public returns (bool);
event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
// File: ERC20Basic.sol
pragma solidity ^0.4.24;
/**
* @title ERC20Basic
* @dev Simpler version of ERC20 interface
* See https://github.com/ethereum/EIPs/issues/179
*/
contract ERC20Basic {
function totalSupply() public view returns (uint256);
function balanceOf(address _who) public view returns (uint256);
function transfer(address _to, uint256 _value) public returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
}
// File: MintableToken.sol
pragma solidity ^0.4.24;
import "./StandardToken.sol";
import "./Ownable.sol";
/**
* @title Mintable token
* @dev Simple ERC20 Token example, with mintable token creation
* 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
)
public
hasMintPermission
canMint
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() public onlyOwner canMint returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
}
// File: Ownable.sol
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 OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to relinquish control of the contract.
* @notice Renouncing to ownership will leave the contract without an owner.
* It will not be possible to call the functions with the `onlyOwner`
* modifier anymore.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
/**
* @dev Transfers control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
}
// File: SafeMath.sol
pragma solidity ^0.4.24;
/**
* @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;
}
}
// File: StandardToken.sol
pragma solidity ^0.4.24;
import "./BasicToken.sol";
import "./ERC20.sol";
/**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* https://github.com/ethereum/EIPs/issues/20
* Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/
contract StandardToken is ERC20, BasicToken {
mapping (address => mapping (address => uint256)) internal allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(
address _from,
address _to,
uint256 _value
)
public
returns (bool)
{
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
require(_to != address(0));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(
address _owner,
address _spender
)
public
view
returns (uint256)
{
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
{
allowed[msg.sender][_spender] = (
allowed[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(
address _spender,
uint256 _subtractedValue
)
public
returns (bool)
{
uint256 oldValue = allowed[msg.sender][_spender];
if (_subtractedValue >= oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
| [{"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["109", "110", "111"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["276", "287"]}] | [{"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"BasicToken.sol": [17]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SafeMath.sol": [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"SafeMath.sol": [32, 33, 34, 29, 30, 31]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BasicToken.sol": [24, 22, 23], "ERC20Basic.sol": [10]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"StandardToken.sol": [96, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BasicToken.sol": [32, 33, 34, 35, 36, 37, 38, 39, 31], "ERC20Basic.sol": [12]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ERC20.sol": [14, 15], "StandardToken.sol": [32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 25, 26, 27, 28, 29, 30, 31]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BasicToken.sol": [48, 46, 47], "ERC20Basic.sol": [11]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ERC20.sol": [17], "StandardToken.sol": [53, 54, 55, 56, 57]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"StandardToken.sol": [107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ERC20.sol": [11, 12], "StandardToken.sol": [65, 66, 67, 68, 69, 70, 71, 72, 73, 74]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"ERC20.sol": [1]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"SafeMath.sol": [1]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"StandardToken.sol": [1]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"ERC20Basic.sol": [1]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"BasicToken.sol": [1]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"StandardToken.sol": [67]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"StandardToken.sol": [53]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SafeMath.sol": [39]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BasicToken.sol": [31]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SafeMath.sol": [13]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"StandardToken.sol": [66]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SafeMath.sol": [29]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SafeMath.sol": [47]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"StandardToken.sol": [26]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SafeMath.sol": [39]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"StandardToken.sol": [27]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"StandardToken.sol": [53]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"StandardToken.sol": [86]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BasicToken.sol": [31]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SafeMath.sol": [13]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"StandardToken.sol": [108]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BasicToken.sol": [46]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SafeMath.sol": [47]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"StandardToken.sol": [87]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"StandardToken.sol": [109]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"StandardToken.sol": [28]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"SafeMath.sol": [29]}}, {"check": "uninitialized-state", "impact": "High", "confidence": "High", "lines": {"BasicToken.sol": [24, 22, 23]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 284, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 419, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 5, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 60, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 102, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 129, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 157, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 176, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 241, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 310, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 367, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 17, "severity": 1}] | [{"constant":true,"inputs":[],"name":"mintingFinished","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"cap","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"mint","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_subtractedValue","type":"uint256"}],"name":"decreaseApproval","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"finishMinting","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_addedValue","type":"uint256"}],"name":"increaseApproval","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[{"name":"_cap","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[],"name":"MintFinished","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"}],"name":"OwnershipRenounced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"}] | v0.4.24+commit.e67f0147 | true | 200 | 0000000000000000000000000000000000000000204fce5e3e25026110000000 | Default | MIT | false | bzzr://0a8659dc620e06eb23ca31b15f1f184fc89e02c559b6969bb463119504f3d7d3 |
||
JERA | 0x5dd56af2ac9aac1263155fa8b820bfca27de5d7c | Solidity | pragma solidity 0.4.26; /*
@@@
.@@@@@@@
@@@@@@@@@@@@@
.@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@
,@@@@@@@@@@@@@@@@@@@@&
@@@@@@@@@@@@@@@@@@@@@
,@@@@@@@@@@@@@@@@@@@@&
@@@@@@@@@@@@@@@@@@@@@
*@@@@@@@@@@@@@@@@@@@@%
@@@@@@@@@@@@@@@@@@@@@ @
*@@@@@@@@@@@@@@@@@@@@# @@@@@#
@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@
/@@@@@@@@@@@@@@@@@@@@( @@@@@@@@@@@@@@@%
@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@ ,@@@@@@@@@@@@@@@@@@@@%
@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@ ,@@@@@@@@@@@@@@@@@@@@&
@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@. .@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@. @@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@
&@@@@@@@@@@@@@@@@@@@@, %@@@@@@@@@@@@@@@@@@@@,
@@@@@@@@@@@@@@@@& @@@@@@@@@@@@@@@@@@@@@
%@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@.
@@@@@@% @@@@@@@@@@@@@@@@@@@@@
#@ @@@@@@@@@@@@@@@@@@@@@.
@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@
@@@@@@@@@
@@@
░░░░░░░░░░░░░░░░░░░░░░░░░░██╗███████╗██████╗ █████╗░░░░░░░░░░░░░░░░░░░░░░
██████╗██████╗██████╗░░░░░██║██╔════╝██╔══██╗██╔══██╗██████╗██████╗██████╗
╚═════╝╚═════╝╚═════╝░░░░░██║█████╗░░██████╔╝███████║╚═════╝╚═════╝╚═════╝
██████╗██████╗██████╗██╗░░██║██╔══╝░░██╔══██╗██╔══██║██████╗██████╗██████╗
╚═════╝╚═════╝╚═════╝╚█████╔╝███████╗██║░░██║██║░░██║╚═════╝╚═════╝╚═════╝
░░░░░░░░░░░░░░░░░░░░░░╚════╝░╚══════╝╚═╝░░╚═╝╚═╝░░╚═╝░░░░░░░░░░░░░░░░░░░░░
========== 'JERA' Token contract with following features ==========
=> ERC20 Compliance
=> Higher degree of control by owner - safeguard functionality
=> SafeMath implementation
=> Burnable and minting
============================== Stats ===============================
=> Name/Nombre : JERA
=> Symbol/Simbolo : JERA
=> Initial Supply/
Preminado : 4500000
=> Total supply
Maximo de tokens : 15000000
=> Decimals/
Decimales : 18
the rest of the tokens will be created via interaction
with the smart contract
el resto de tokens se crearan via interaccion
con el contrato inteligente
-------------------------------------------------------------------
Copyright (c) 2021 onwards JERA.
Contract designed with ❤ by P&P
-------------------------------------------------------------------
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal constant returns (uint256) {
assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal constant returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
interface ERC20 {
function totalSupply() public view returns(uint supply);
function balanceOf(address _owner) public view returns(uint balance);
function transfer(address _to, uint _value) public returns(bool success);
function transferFrom(address _from, address _to, uint _value) public returns(bool success);
function approve(address _spender, uint _value) public returns(bool success);
function allowance(address _owner, address _spender) public view returns(uint remaining);
function decimals() public view returns(uint digits);
event Approval(address indexed _owner, address indexed _spender, uint _value);
}
// ERC20 Token Smart Contract
contract JERA {
string public constant name = "JERA";
string public constant symbol = "JERA";
uint8 public constant decimals = 18;
uint public _totalSupply = 4500000000000000000000000;
uint256 public RATE = 300000000000000000;
bool public isMinting = true;
string public constant generated_by = "P&P";
using SafeMath for uint256;
address public owner;
modifier onlyOwner() {
if (msg.sender != owner) {
throw;
}
_;
}
mapping(address => uint256) balances;
// Owner of account approves the transfer of an amount to another account
mapping(address => mapping(address=>uint256)) allowed;
// Its a payable function works as a token factory.
function () payable{
createTokens();
}
// Constructor
constructor() public payable {
owner = 0x3396aC4d01a15545eCD6fC8E5CB2e4fD61AF50B1;
balances[owner] = _totalSupply;
}
//allows owner to burn tokens that are not sold in a crowdsale
function burnTokens(uint256 _value) onlyOwner {
require(balances[msg.sender] >= _value && _value > 0 );
_totalSupply = _totalSupply.sub(_value);
balances[msg.sender] = balances[msg.sender].sub(_value);
}
function createTokens() payable {
if(isMinting == true){
require(msg.value > 0);
uint256 tokens = msg.value.div(100000000000000).mul(RATE);
balances[msg.sender] = balances[msg.sender].add(tokens);
_totalSupply = _totalSupply.add(tokens);
owner.transfer(msg.value);
}
else{
throw;
}
}
function endCrowdsale() onlyOwner {
isMinting = false;
}
function changeCrowdsaleRate(uint256 _value) onlyOwner {
RATE = _value;
}
function totalSupply() constant returns(uint256){
return _totalSupply;
}
function balanceOf(address _owner) constant returns(uint256){
return balances[_owner];
}
function transfer(address _to, uint256 _value) returns(bool) {
require(balances[msg.sender] >= _value && _value > 0 );
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
}
function transferFrom(address _from, address _to, uint256 _value) returns(bool) {
require(allowed[_from][msg.sender] >= _value && balances[_from] >= _value && _value > 0);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) returns(bool){
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant returns(uint256){
return allowed[_owner][_spender];
}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | [{"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["129", "130", "134", "128"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["211", "202"]}] | [{"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"JERA.sol": [171]}}, {"check": "deprecated-standards", "impact": "Informational", "confidence": "High", "lines": {"JERA.sol": [141]}}, {"check": "deprecated-standards", "impact": "Informational", "confidence": "High", "lines": {"JERA.sol": [179]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"JERA.sol": [173]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JERA.sol": [224, 220, 221, 222, 223]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JERA.sol": [211, 212, 213, 214, 215, 216, 217, 218]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JERA.sol": [114]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JERA.sol": [226, 227, 228]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JERA.sol": [120]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JERA.sol": [162, 163, 164, 165, 166, 167, 168]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JERA.sol": [110]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JERA.sol": [112]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JERA.sol": [200, 198, 199]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JERA.sol": [152, 153, 151]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JERA.sol": [202, 203, 204, 205, 206, 207, 208]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JERA.sol": [108]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JERA.sol": [116]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JERA.sol": [188, 189, 190]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JERA.sol": [194, 195, 196]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JERA.sol": [118]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"JERA.sol": [184, 185, 186]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"JERA.sol": [1]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"JERA.sol": [189]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"JERA.sol": [165]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"JERA.sol": [220]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"JERA.sol": [220]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"JERA.sol": [188]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"JERA.sol": [198]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"JERA.sol": [211]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"JERA.sol": [162]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"JERA.sol": [132]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"JERA.sol": [202]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"JERA.sol": [211]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"JERA.sol": [226]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"JERA.sol": [134]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"JERA.sol": [202]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"JERA.sol": [226]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"JERA.sol": [131]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"JERA.sol": [211]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"JERA.sol": [173]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"JERA.sol": [132]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"JERA.sol": [131]}}] | [{"error": "Integer Overflow.", "line": 101, "level": "Warning"}] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 157, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 141, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 179, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 82, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 88, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 95, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 100, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 194, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 198, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 226, "severity": 1}, {"rule": "SOLIDITY_DIV_MUL", "line": 173, "severity": 2}, {"rule": "SOLIDITY_REVERT_REQUIRE", "line": 140, "severity": 1}, {"rule": "SOLIDITY_REVERT_REQUIRE", "line": 171, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 136, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 108, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 110, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 112, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 114, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 116, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 118, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 120, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 151, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 162, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 170, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 184, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 188, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 194, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 198, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 202, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 211, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 220, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 226, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 146, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 148, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"endCrowdsale","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"isMinting","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"_totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"uint256"}],"name":"changeCrowdsaleRate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"RATE","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_value","type":"uint256"}],"name":"burnTokens","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"createTokens","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"generated_by","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[],"payable":true,"stateMutability":"payable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_value","type":"uint256"}],"name":"Approval","type":"event"}] | v0.4.26+commit.4563c3fc | true | 200 | Default | None | false | ||||
AlunaBoostPool | 0xb05893dc580265b838e2f70011c17d97e1fce061 | Solidity | // File: contracts/AdditionalMath.sol
pragma solidity 0.6.2;
/*
# Copyright (C) 2017 alianse777
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# https://github.com/alianse777/solidity-standard-library.git
*/
import "@openzeppelin/contracts/math/SafeMath.sol";
library AdditionalMath {
using SafeMath for uint256;
/**
* @dev Compute square root of x
* @param x num to sqrt
* @return sqrt(x)
*/
function sqrt(uint x) internal pure returns (uint){
uint n = x / 2;
uint lstX = 0;
while (n != lstX){
lstX = n;
n = (n + x/n) / 2;
}
return uint(n);
}
}
// File: @openzeppelin/contracts/math/SafeMath.sol
// 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;
}
}
// File: contracts/AlunaBoostPool.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.6.2;
import "@openzeppelin/contracts/access/Ownable.sol";
import "./interfaces/IERC20Burnable.sol";
import "./interfaces/ITreasury.sol";
import "./interfaces/ISwapRouter.sol";
import "./LPTokenWrapper.sol";
import "./AdditionalMath.sol";
import "@openzeppelin/contracts/math/Math.sol";
contract AlunaBoostPool is LPTokenWrapper, Ownable {
using AdditionalMath for uint256;
IERC20 public rewardToken;
IERC20 public boostToken;
ITreasury public treasury;
SwapRouter public swapRouter;
IERC20 public stablecoin;
uint256 public tokenCapAmount;
uint256 public starttime;
uint256 public duration;
uint256 public periodFinish;
uint256 public rewardRate;
uint256 public lastUpdateTime;
uint256 public rewardPerTokenStored;
uint256 public constant SECONDS_IN_A_DAY = 86400;
mapping(address => uint256) public userRewardPerTokenPaid;
mapping(address => uint256) public rewards;
// booster variables
// variables to keep track of totalSupply and balances (after accounting for multiplier)
uint256 public boostedTotalSupply;
uint256 public lastBoostPurchase; // timestamp of lastBoostPurchase
mapping(address => uint256) public boostedBalances;
mapping(address => uint256) public numBoostersBought; // each booster = 5% increase in stake amt
mapping(address => uint256) public nextBoostPurchaseTime; // timestamp for which user is eligible to purchase another booster
uint256 public globalBoosterPrice = 2000e18;
uint256 public boostThreshold = 10;
uint256 public boostScaleFactor = 20;
uint256 public scaleFactor = 100;
event RewardAdded(uint256 reward);
event RewardPaid(address indexed user, uint256 reward);
modifier checkStart() {
require(block.timestamp >= starttime,"not start");
_;
}
modifier updateReward(address account) {
rewardPerTokenStored = rewardPerToken();
lastUpdateTime = lastTimeRewardApplicable();
if (account != address(0)) {
rewards[account] = earned(account);
userRewardPerTokenPaid[account] = rewardPerTokenStored;
}
_;
}
constructor(
uint256 _tokenCapAmount,
IERC20 _stakeToken,
IERC20 _rewardToken,
IERC20 _boostToken,
address _treasury,
SwapRouter _swapRouter,
uint256 _starttime,
uint256 _duration
) public LPTokenWrapper(_stakeToken) {
tokenCapAmount = _tokenCapAmount;
boostToken = _boostToken;
rewardToken = _rewardToken;
treasury = ITreasury(_treasury);
stablecoin = treasury.defaultToken();
swapRouter = _swapRouter;
starttime = _starttime;
lastBoostPurchase = _starttime;
duration = _duration;
boostToken.safeApprove(address(_swapRouter), uint256(-1));
stablecoin.safeApprove(address(treasury), uint256(-1));
}
function lastTimeRewardApplicable() public view returns (uint256) {
return Math.min(block.timestamp, periodFinish);
}
function rewardPerToken() public view returns (uint256) {
if (boostedTotalSupply == 0) {
return rewardPerTokenStored;
}
return
rewardPerTokenStored.add(
lastTimeRewardApplicable()
.sub(lastUpdateTime)
.mul(rewardRate)
.mul(1e18)
.div(boostedTotalSupply)
);
}
function earned(address account) public view returns (uint256) {
return
boostedBalances[account]
.mul(rewardPerToken().sub(userRewardPerTokenPaid[account]))
.div(1e18)
.add(rewards[account]);
}
function getBoosterPrice(address user)
public view returns (uint256 boosterPrice, uint256 newBoostBalance)
{
if (boostedTotalSupply == 0) return (0,0);
// each previously user-purchased booster will increase price in 5%,
// that is, 1 booster means 5% increase, 2 boosters mean 10% and so on
uint256 boostersBought = numBoostersBought[user];
boosterPrice = globalBoosterPrice.mul(boostersBought.mul(5).add(100)).div(100);
// increment boostersBought by 1
boostersBought = boostersBought.add(1);
// if no. of boosters exceed threshold, increase booster price by boostScaleFactor
// for each exceeded booster
if (boostersBought >= boostThreshold) {
boosterPrice = boosterPrice
.mul((boostersBought.sub(boostThreshold)).mul(boostScaleFactor).add(100))
.div(100);
}
// 2.5% decrease for every 2 hour interval since last global boost purchase
boosterPrice = calculateBoostDevaluation(boosterPrice, 975, 1000, (block.timestamp.sub(lastBoostPurchase)).div(2 hours));
// adjust price based on expected increase in boost supply
// each booster will increase balance in an order of 10%
// boostersBought has been incremented by 1 already
newBoostBalance = balanceOf(user)
.mul(boostersBought.mul(10).add(100))
.div(100);
// uint256 boostBalanceIncrease = newBoostBalance.sub(boostedBalances[user]);
boosterPrice = boosterPrice
.mul(balanceOf(user))
.div(boostedTotalSupply);
}
// stake visibility is public as overriding LPTokenWrapper's stake() function
function stake(uint256 amount) public updateReward(msg.sender) override checkStart {
require(amount != 0, "Cannot stake 0");
super.stake(amount);
// check user cap
require(
balanceOf(msg.sender) <= tokenCapAmount || block.timestamp >= starttime.add(SECONDS_IN_A_DAY),
"token cap exceeded"
);
// boosters do not affect new amounts
boostedBalances[msg.sender] = boostedBalances[msg.sender].add(amount);
boostedTotalSupply = boostedTotalSupply.add(amount);
_getReward(msg.sender);
// transfer token last, to follow CEI pattern
stakeToken.safeTransferFrom(msg.sender, address(this), amount);
}
function withdraw(uint256 amount) public updateReward(msg.sender) override checkStart {
require(amount != 0, "Cannot withdraw 0");
super.withdraw(amount);
// reset boosts :(
numBoostersBought[msg.sender] = 0;
// update boosted balance and supply
updateBoostBalanceAndSupply(msg.sender, 0);
// in case _getReward function fails, continue
//(bool success, ) = address(this).call(
// abi.encodeWithSignature(
// "_getReward(address)",
// msg.sender
// )
//);
// to remove compiler warning
//success;
// transfer token last, to follow CEI pattern
stakeToken.safeTransfer(msg.sender, amount);
}
function getReward() external updateReward(msg.sender) checkStart {
_getReward(msg.sender);
}
function exit() external {
withdraw(balanceOf(msg.sender));
}
function setScaleFactorsAndThreshold(
uint256 _boostThreshold,
uint256 _boostScaleFactor,
uint256 _scaleFactor
) external onlyOwner
{
boostThreshold = _boostThreshold;
boostScaleFactor = _boostScaleFactor;
scaleFactor = _scaleFactor;
}
function boost() external updateReward(msg.sender) checkStart {
require(
block.timestamp > nextBoostPurchaseTime[msg.sender],
"early boost purchase"
);
// save current booster price, since transfer is done last
// since getBoosterPrice() returns new boost balance, avoid re-calculation
(uint256 boosterAmount, uint256 newBoostBalance) = getBoosterPrice(msg.sender);
// user's balance and boostedSupply will be changed in this function
applyBoost(msg.sender, newBoostBalance);
_getReward(msg.sender);
boostToken.safeTransferFrom(msg.sender, address(this), boosterAmount);
IERC20Burnable burnableBoostToken = IERC20Burnable(address(boostToken));
// burn 25%
uint256 burnAmount = boosterAmount.div(4);
burnableBoostToken.burn(burnAmount);
boosterAmount = boosterAmount.sub(burnAmount);
// swap to stablecoin
address[] memory routeDetails = new address[](3);
routeDetails[0] = address(boostToken);
routeDetails[1] = swapRouter.WETH();
routeDetails[2] = address(stablecoin);
uint[] memory amounts = swapRouter.swapExactTokensForTokens(
boosterAmount,
0,
routeDetails,
address(this),
block.timestamp + 100
);
// transfer to treasury
// index 2 = final output amt
treasury.deposit(stablecoin, amounts[2]);
}
function notifyRewardAmount(uint256 reward)
external
onlyOwner
updateReward(address(0))
{
rewardRate = reward.div(duration);
lastUpdateTime = starttime;
periodFinish = starttime.add(duration);
emit RewardAdded(reward);
}
function updateBoostBalanceAndSupply(address user, uint256 newBoostBalance) internal {
// subtract existing balance from boostedSupply
boostedTotalSupply = boostedTotalSupply.sub(boostedBalances[user]);
// when applying boosts,
// newBoostBalance has already been calculated in getBoosterPrice()
if (newBoostBalance == 0) {
// each booster adds 10% to current stake amount, that is 1 booster means 10%,
// two boosters mean 20% and so on
newBoostBalance = balanceOf(user).mul(numBoostersBought[user].mul(10).add(100)).div(100);
}
// update user's boosted balance
boostedBalances[user] = newBoostBalance;
// update boostedSupply
boostedTotalSupply = boostedTotalSupply.add(newBoostBalance);
}
function applyBoost(address user, uint256 newBoostBalance) internal {
// increase no. of boosters bought
numBoostersBought[user] = numBoostersBought[user].add(1);
updateBoostBalanceAndSupply(user, newBoostBalance);
// increase next purchase eligibility by an hour
nextBoostPurchaseTime[user] = block.timestamp.add(3600);
// increase global booster price by 1%
globalBoosterPrice = globalBoosterPrice.mul(101).div(100);
lastBoostPurchase = block.timestamp;
}
function _getReward(address user) internal {
uint256 reward = earned(user);
if (reward != 0) {
rewards[user] = 0;
emit RewardPaid(user, reward);
rewardToken.safeTransfer(user, reward);
}
}
/// Imported from: https://forum.openzeppelin.com/t/does-safemath-library-need-a-safe-power-function/871/7
/// Modified so that it takes in 3 arguments for base
/// @return the eventually newly calculated boost price
function calculateBoostDevaluation(uint256 a, uint256 b, uint256 c, uint256 exponent) internal pure returns (uint256) {
if (exponent == 0) {
return a;
}
else if (exponent == 1) {
return a.mul(b).div(c);
}
else if (a == 0 && exponent != 0) {
return 0;
}
else {
uint256 z = a.mul(b).div(c);
for (uint256 i = 1; i < exponent; i++)
z = z.mul(b).div(c);
return z;
}
}
}
// File: @openzeppelin/contracts/access/Ownable.sol
// 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;
}
}
// File: @openzeppelin/contracts/GSN/Context.sol
// 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;
}
}
// File: contracts/interfaces/IERC20Burnable.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.6.2;
interface IERC20Burnable {
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);
function burn(uint256 amount) external;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// File: contracts/interfaces/ITreasury.sol
pragma solidity ^0.6.2;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface ITreasury {
function defaultToken() external view returns (IERC20);
function deposit(IERC20 token, uint256 amount) external;
function withdraw(uint256 amount, address withdrawAddress) external;
}
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// File: contracts/interfaces/ISwapRouter.sol
//SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.6.2;
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/LPTokenWrapper.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.6.2;
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
contract LPTokenWrapper {
using SafeMath for uint256;
using SafeERC20 for IERC20;
uint256 private _totalSupply;
IERC20 public stakeToken;
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 virtual {
_totalSupply = _totalSupply.add(amount);
_balances[msg.sender] = _balances[msg.sender].add(amount);
// safeTransferFrom shifted to last line of overridden method
}
function withdraw(uint256 amount) public virtual {
_totalSupply = _totalSupply.sub(amount);
_balances[msg.sender] = _balances[msg.sender].sub(amount);
// safeTransfer shifted to last line of overridden method
}
}
// File: @openzeppelin/contracts/token/ERC20/SafeERC20.sol
// 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");
}
}
}
// File: @openzeppelin/contracts/utils/Address.sol
// 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) {
// This method relies in extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts/math/Math.sol
// 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);
}
}
// File: contracts/AlunaGov.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.6.2;
import "./interfaces/ITreasury.sol";
import "./interfaces/ISwapRouter.sol";
import "./LPTokenWrapperWithSlash.sol";
import "./AdditionalMath.sol";
contract AlunaGov is LPTokenWrapperWithSlash {
using AdditionalMath for uint256;
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;
}
// 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
uint256 public constant proposalPeriod = 2 days;
uint256 public constant lockPeriod = 3 days;
uint256 public constant minimum = 1337e18; // 1337 ALN
uint256 public proposalCount;
IERC20 public stablecoin;
ITreasury public treasury;
SwapRouter public swapRouter;
mapping(address => uint256) public voteLock; // timestamp that boost stakes are locked after voting
mapping (uint256 => Proposal) public proposals;
constructor(IERC20 _stakeToken, ITreasury _treasury, SwapRouter _swapRouter)
public
LPTokenWrapperWithSlash(_stakeToken)
{
treasury = _treasury;
stablecoin = treasury.defaultToken();
swapRouter = _swapRouter;
stablecoin.safeApprove(address(treasury), uint256(-1));
stakeToken.safeApprove(address(_swapRouter), uint256(-1));
}
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: proposalPeriod.add(block.timestamp),
url: _url,
title: _title
});
voteLock[msg.sender] = lockPeriod.add(block.timestamp);
}
function voteFor(uint256 id) external {
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 = AdditionalMath.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] = lockPeriod.add(block.timestamp);
}
function voteAgainst(uint256 id) external {
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 = AdditionalMath.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] = lockPeriod.add(block.timestamp);
}
function stake(uint256 amount) public override {
super.stake(amount);
}
function withdraw(uint256 amount) public override {
require(voteLock[msg.sender] < block.timestamp, "tokens locked");
super.withdraw(amount);
}
function resolveProposal(uint256 id) external {
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 = AdditionalMath.sqrt(totalSupply());
uint256 quorum = getQuorum(id);
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 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 getQuorum(uint256 id) public view returns (uint256){
// sum votes, multiply by precision, divide by square rooted total supply
require(proposals[id].proposer != address(0), "non-existent proposal");
uint256 _totalSupply;
if (proposals[id].totalSupply == 0) {
_totalSupply = AdditionalMath.sqrt(totalSupply());
} else {
_totalSupply = proposals[id].totalSupply;
}
uint256 _quorum =
(proposals[id].totalForVotes.add(proposals[id].totalAgainstVotes))
.mul(PERCENTAGE_PRECISION)
.div(_totalSupply);
return _quorum;
}
}
// File: contracts/LPTokenWrapperWithSlash.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.6.2;
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
contract LPTokenWrapperWithSlash {
using SafeMath for uint256;
using SafeERC20 for IERC20;
uint256 private _totalSupply;
IERC20 public stakeToken;
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 virtual {
_totalSupply = _totalSupply.add(amount);
_balances[msg.sender] = _balances[msg.sender].add(amount);
stakeToken.safeTransferFrom(msg.sender, address(this), amount);
}
function withdraw(uint256 amount) public virtual {
_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/interfaces/IGovernance.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.6.2;
interface IGovernance {
function getStablecoin() external view returns (address);
}
// File: contracts/interfaces/IUniswapV2Factory.sol
//SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.6.2;
interface IUniswapV2Factory {
function getPair(address tokenA, address tokenB) external view returns (address pair);
function createPair(address tokenA, address tokenB) external returns (address pair);
}
// File: contracts/mocks/BoostToken.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.6.2;
import "@openzeppelin/contracts/math/Math.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol";
contract BoostToken is ERC20, ERC20Burnable {
using SafeERC20 for IERC20;
using Address for address;
using SafeMath for uint;
address public governance;
mapping (address => bool) public minters;
constructor () public ERC20("Boosted Finance", "BOOST") {
governance = msg.sender;
addMinter(governance);
// underlying _mint function has hard limit
mint(governance, 1e23);
}
function mint(address account, uint amount) public {
require(minters[msg.sender], "!minter");
_mint(account, amount);
}
function setGovernance(address _governance) public {
require(msg.sender == governance, "!governance");
governance = _governance;
}
function addMinter(address _minter) public {
require(msg.sender == governance, "!governance");
minters[_minter] = true;
}
function removeMinter(address _minter) public {
require(msg.sender == governance, "!governance");
minters[_minter] = false;
}
function burn(uint256 amount) public override {
_burn(msg.sender, amount);
}
}
// File: @openzeppelin/contracts/token/ERC20/ERC20.sol
// 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 internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
// File: @openzeppelin/contracts/token/ERC20/ERC20Burnable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "../../GSN/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 {
/**
* @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: contracts/mocks/Token.sol
pragma solidity ^0.6.2;
import "@openzeppelin/contracts/token/ERC20/ERC20Burnable.sol";
contract Token is ERC20Burnable {
constructor (string memory _name, string memory _symbol, uint8 _decimals) public ERC20( _name, _symbol) {
_mint(msg.sender , 100000000000000000000000000); // 100 mil tokens
_setupDecimals(_decimals);
}
}
// File: contracts/mocks/WETH.sol
pragma solidity ^0.6.2;
contract WETH9 {
string public name = "Wrapped Ether";
string public symbol = "WETH";
uint8 public decimals = 18;
event Approval(address indexed src, address indexed guy, uint wad);
event Transfer(address indexed src, address indexed dst, uint wad);
event Deposit(address indexed dst, uint wad);
event Withdrawal(address indexed src, uint wad);
mapping (address => uint) public balanceOf;
mapping (address => mapping (address => uint)) public allowance;
constructor () public payable {
deposit();
}
function deposit() public payable {
balanceOf[msg.sender] += msg.value;
emit Deposit(msg.sender, msg.value);
}
function withdraw(uint wad) public {
require(balanceOf[msg.sender] >= wad);
balanceOf[msg.sender] -= wad;
msg.sender.transfer(wad);
emit Withdrawal(msg.sender, wad);
}
function totalSupply() public view returns (uint) {
return address(this).balance;
}
function approve(address guy, uint wad) public returns (bool) {
allowance[msg.sender][guy] = wad;
emit Approval(msg.sender, guy, wad);
return true;
}
function transfer(address dst, uint wad) public returns (bool) {
return transferFrom(msg.sender, dst, wad);
}
function transferFrom(address src, address dst, uint wad)
public
returns (bool)
{
require(balanceOf[src] >= wad);
if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) {
require(allowance[src][msg.sender] >= wad);
allowance[src][msg.sender] -= wad;
}
balanceOf[src] -= wad;
balanceOf[dst] += wad;
emit Transfer(src, dst, wad);
return true;
}
}
// File: contracts/Treasury.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.6.2;
import "@openzeppelin/contracts/math/SafeMath.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./interfaces/ITreasury.sol";
import "./interfaces/ISwapRouter.sol";
contract Treasury is Ownable, ITreasury {
using SafeMath for uint256;
using SafeERC20 for IERC20;
IERC20 public override defaultToken;
SwapRouter public swapRouter;
address public ecoFund;
address public gov;
address internal govSetter;
mapping(address => uint256) public ecoFundAmts;
// 1% = 100
uint256 public constant MAX_FUND_PERCENTAGE = 1500; // 15%
uint256 public constant PERCENTAGE_PRECISION = 10000; // 100%
uint256 public fundPercentage = 500; // 5%
constructor(SwapRouter _swapRouter, IERC20 _defaultToken, address _ecoFund) public {
swapRouter = _swapRouter;
defaultToken = _defaultToken;
ecoFund = _ecoFund;
govSetter = msg.sender;
}
function setGov(address _gov) external {
require(msg.sender == govSetter, "not authorized");
gov = _gov;
govSetter = address(0);
}
function setSwapRouter(SwapRouter _swapRouter) external onlyOwner {
swapRouter = _swapRouter;
}
function setEcoFund(address _ecoFund) external onlyOwner {
ecoFund = _ecoFund;
}
function setFundPercentage(uint256 _fundPercentage) external onlyOwner {
require(_fundPercentage <= MAX_FUND_PERCENTAGE, "exceed max percent");
fundPercentage = _fundPercentage;
}
function balanceOf(IERC20 token) public view returns (uint256) {
return token.balanceOf(address(this)).sub(ecoFundAmts[address(token)]);
}
function deposit(IERC20 token, uint256 amount) external override {
// portion allocated to ecoFund
ecoFundAmts[address(token)] = amount.mul(fundPercentage).div(PERCENTAGE_PRECISION);
token.safeTransferFrom(msg.sender, address(this), amount);
}
// only default token withdrawals allowed
function withdraw(uint256 amount, address withdrawAddress) external override {
require(msg.sender == gov, "caller not gov");
require(balanceOf(defaultToken) >= amount, "insufficient funds");
defaultToken.safeTransfer(withdrawAddress, amount);
}
function convertToDefaultToken(address[] calldata routeDetails, uint256 amount) external {
require(routeDetails[0] != address(defaultToken), "src can't be defaultToken");
require(routeDetails[routeDetails.length - 1] == address(defaultToken), "dest not defaultToken");
IERC20 srcToken = IERC20(routeDetails[0]);
require(balanceOf(srcToken) >= amount, "insufficient funds");
if (srcToken.allowance(address(this), address(swapRouter)) <= amount) {
srcToken.safeApprove(address(swapRouter), uint256(-1));
}
uint[] memory swappedAmounts = swapRouter.swapExactTokensForTokens(
amount,
0,
routeDetails,
address(this),
block.timestamp + 100
);
require(swappedAmounts.length != 0, "Swap failed");
}
function withdrawEcoFund(IERC20 token, uint256 amount) external {
ecoFundAmts[address(token)] = ecoFundAmts[address(token)].sub(amount);
token.safeTransfer(ecoFund, amount);
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["1967"]}, {"defect": "Bad_randomness", "type": "Business_logic", "severity": "Medium", "lines": ["371", "478", "1263", "533", "1287", "1330", "528", "1275", "2109"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["1945", "1943", "1944", "1221", "466", "38"]}, {"defect": "Redefine_variable", "type": "Code_specification", "severity": "Low", "lines": ["1345"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["601", "616", "628"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["1991", "1993", "1996", "1997", "1966", "1960", "1330", "2109", "478"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["324", "488", "1338", "2116", "1301", "1267", "451", "286", "1295", "1268", "391", "1280", "1279"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/Address.sol": [132, 133, 134, 135]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/Address.sol": [33]}}, {"check": "pragma", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/GSN/Context.sol": [3], "@openzeppelin/contracts/access/Ownable.sol": [3], "@openzeppelin/contracts/math/SafeMath.sol": [3], "@openzeppelin/contracts/token/ERC20/IERC20.sol": [3], "@openzeppelin/contracts/token/ERC20/SafeERC20.sol": [3], "@openzeppelin/contracts/utils/Address.sol": [3], "contracts/Treasury.sol": [24], "contracts/interfaces/ISwapRouter.sol": [3], "contracts/interfaces/ITreasury.sol": [1]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [53, 54, 55, 56, 57, 58, 59]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [104, 105, 106]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/math/SafeMath.sol": [32, 33, 34, 29, 30, 31]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/token/ERC20/SafeERC20.sol": [48, 49, 50, 51]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/math/SafeMath.sol": [155, 156, 157, 158]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [114, 115, 116, 117]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/GSN/Context.sol": [20, 21, 22, 23]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/math/SafeMath.sol": [139, 140, 141]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/token/ERC20/SafeERC20.sol": [56, 53, 54, 55]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/Address.sol": [80, 81, 79]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"@openzeppelin/contracts/access/Ownable.sol": [56, 57, 54, 55]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"@openzeppelin/contracts/access/Ownable.sol": [35, 36, 37]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"@openzeppelin/contracts/access/Ownable.sol": [64, 65, 66, 67, 63]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/access/Ownable.sol": [3]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/math/SafeMath.sol": [3]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"contracts/interfaces/ITreasury.sol": [1]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"contracts/interfaces/ISwapRouter.sol": [3]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/Address.sol": [3]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/token/ERC20/SafeERC20.sol": [3]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/token/ERC20/IERC20.sol": [3]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"contracts/Treasury.sol": [24]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/GSN/Context.sol": [3]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/Address.sol": [57]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/Address.sol": [123]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"contracts/Treasury.sol": [74]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"contracts/Treasury.sol": [69]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"contracts/Treasury.sol": [54]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"contracts/Treasury.sol": [60]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"contracts/Treasury.sol": [64]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"contracts/Treasury.sol": [68]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"contracts/Treasury.sol": [58]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"contracts/interfaces/ISwapRouter.sol": [7]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"contracts/Treasury.sol": [72]}}, {"check": "redundant-statements", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/GSN/Context.sol": [15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"contracts/Treasury.sol": [109]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 494, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 625, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1796, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1817, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 2068, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 1700, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 39, "severity": 1}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 439, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 1542, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 2065, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 2071, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 2075, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 2079, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 53, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 572, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 645, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 695, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 716, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 733, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 815, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 905, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 985, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1131, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1464, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1479, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1512, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1567, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1879, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1922, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1939, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 588, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 867, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 871, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1399, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1403, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1602, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1604, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1606, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1608, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1609, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1610, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 29, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 864, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 921, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 1396, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 1524, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 1599, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 2041, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 1008, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 350, "severity": 1}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 925, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 929, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 947, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 952, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 957, "severity": 3}, {"rule": "SOLIDITY_VISIBILITY", "line": 820, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1035, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1244, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 823, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 824, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 825, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 826, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1035, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1035, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1036, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1036, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1036, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1036, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1039, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1039, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1039, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1246, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1247, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1248, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1250, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1250, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1251, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1251, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1252, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1253, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1254, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1256, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1257, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1258, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1258, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1259, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1259, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1260, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1261, "severity": 1}] | [{"inputs":[{"internalType":"uint256","name":"_tokenCapAmount","type":"uint256"},{"internalType":"contract IERC20","name":"_stakeToken","type":"address"},{"internalType":"contract IERC20","name":"_rewardToken","type":"address"},{"internalType":"contract IERC20","name":"_boostToken","type":"address"},{"internalType":"address","name":"_treasury","type":"address"},{"internalType":"contract SwapRouter","name":"_swapRouter","type":"address"},{"internalType":"uint256","name":"_starttime","type":"uint256"},{"internalType":"uint256","name":"_duration","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardPaid","type":"event"},{"inputs":[],"name":"SECONDS_IN_A_DAY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"boost","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"boostScaleFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"boostThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"boostToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"boostedBalances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"boostedTotalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"duration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"earned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getBoosterPrice","outputs":[{"internalType":"uint256","name":"boosterPrice","type":"uint256"},{"internalType":"uint256","name":"newBoostBalance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"globalBoosterPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastBoostPurchase","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastTimeRewardApplicable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastUpdateTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nextBoostPurchaseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"reward","type":"uint256"}],"name":"notifyRewardAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"numBoostersBought","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodFinish","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerTokenStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"scaleFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_boostThreshold","type":"uint256"},{"internalType":"uint256","name":"_boostScaleFactor","type":"uint256"},{"internalType":"uint256","name":"_scaleFactor","type":"uint256"}],"name":"setScaleFactorsAndThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stablecoin","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakeToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"starttime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"swapRouter","outputs":[{"internalType":"contract SwapRouter","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tokenCapAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"treasury","outputs":[{"internalType":"contract ITreasury","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userRewardPerTokenPaid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}] | v0.6.2+commit.bacdbe57 | true | 10,000 | 00000000000000000000000000000000000000000000021e19e0c9bab24000000000000000000000000000008185bc4757572da2a610f887561c32298f1a57480000000000000000000000008185bc4757572da2a610f887561c32298f1a57480000000000000000000000008185bc4757572da2a610f887561c32298f1a57480000000000000000000000003a3235949a22b5c0bb42a42fd225a5fe7d18ef520000000000000000000000007a250d5630b4cf539739df2c5dacb4c659f2488d0000000000000000000000000000000000000000000000000000000060782ac00000000000000000000000000000000000000000000000000000000000530e80 | Default | false | ||||
TheTrapBlock | 0xb87510f5a496faa1583996b9af6a6c59631a6b89 | Solidity | // Sources flattened with hardhat v2.8.3 https://hardhat.org
// File @openzeppelin/contracts/proxy/[email protected]
// OpenZeppelin Contracts v4.4.1 (proxy/Proxy.sol)
pragma solidity ^0.8.0;
/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/
abstract contract Proxy {
/**
* @dev Delegates the current call to `implementation`.
*
* This function does not return to its internall call site, it will return directly to the external caller.
*/
function _delegate(address implementation) internal virtual {
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @dev This is a virtual function that should be overriden so it returns the address to which the fallback function
* and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internall call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
* function in the contract matches the call data.
*/
fallback() external payable virtual {
_fallback();
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
* is empty.
*/
receive() external payable virtual {
_fallback();
}
/**
* @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
* call, or as part of the Solidity `fallback` or `receive` functions.
*
* If overriden should call `super._beforeFallback()`.
*/
function _beforeFallback() internal virtual {}
}
// File @openzeppelin/contracts/utils/[email protected]
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File @openzeppelin/contracts/utils/[email protected]
// 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
}
}
}
// File contracts/TheTrapBlock.sol
pragma solidity ^0.8.4;
contract ERC721ContractWrapper is Proxy {
address internal constant _IMPLEMENTATION_ADDRESS = 0x0AaD9cf1D64301D6a37B1368f073E99DED6BECa5;
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
constructor(
string memory _name,
string memory _symbol,
uint256 _totalSupply
) {
assert(_IMPLEMENTATION_SLOT == bytes32(uint256(keccak256("eip1967.proxy.implementation")) - 1));
StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = _IMPLEMENTATION_ADDRESS;
Address.functionDelegateCall(
_IMPLEMENTATION_ADDRESS,
abi.encodeWithSignature("initialize(string,string,uint256)", _name, _symbol, _totalSupply)
);
}
/**
* @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;
}
}
contract TheTrapBlock is ERC721ContractWrapper {
constructor(
string memory _name,
string memory _symbol,
uint256 _totalSupply
) ERC721ContractWrapper(_name,_symbol,_totalSupply) {}
} | [{"defect": "DelegateCall", "type": "Function_call", "severity": "High", "lines": ["278"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TheTrapBlock.sol": [384, 385, 383]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TheTrapBlock.sol": [26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TheTrapBlock.sol": [125, 126, 127]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TheTrapBlock.sol": [365, 366, 367]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TheTrapBlock.sol": [376, 374, 375]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TheTrapBlock.sol": [392, 393, 394]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"TheTrapBlock.sol": [300, 301, 302, 303]}}, {"check": "pragma", "impact": "Informational", "confidence": "High", "lines": {"TheTrapBlock.sol": [401]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TheTrapBlock.sol": [147, 148, 149, 150, 151, 152]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TheTrapBlock.sol": [201, 202, 203, 204, 205, 206, 207]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TheTrapBlock.sol": [391, 392, 393, 394, 395]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TheTrapBlock.sol": [224, 225, 226, 215, 216, 217, 218, 219, 220, 221, 222, 223]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TheTrapBlock.sol": [234, 235, 236]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TheTrapBlock.sol": [373, 374, 375, 376, 377]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TheTrapBlock.sol": [384, 385, 386, 382, 383]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TheTrapBlock.sol": [182, 183, 184, 185, 186, 187, 188]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TheTrapBlock.sol": [244, 245, 246, 247, 248, 249, 250, 251, 252, 253]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TheTrapBlock.sol": [172, 173, 174]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TheTrapBlock.sol": [425, 426, 427]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"TheTrapBlock.sol": [7]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"TheTrapBlock.sol": [316]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"TheTrapBlock.sol": [96]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"TheTrapBlock.sol": [251]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"TheTrapBlock.sol": [150]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"TheTrapBlock.sol": [224]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"TheTrapBlock.sol": [278]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"TheTrapBlock.sol": [416, 417, 418, 419]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 406, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 364, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 373, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 382, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 391, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 7, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 96, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 316, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 401, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 364, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 373, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 382, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 391, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 119, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 26, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 365, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 374, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 383, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 392, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 147, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 409, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 435, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 70, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 71, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 71, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 147, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 147, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 148, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 148, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 148, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 148, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 150, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 150, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 150, "severity": 1}] | [{"inputs":[{"internalType":"string","name":"_name","type":"string"},{"internalType":"string","name":"_symbol","type":"string"},{"internalType":"uint256","name":"_totalSupply","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}] | v0.8.4+commit.c7e474f2 | true | 200 | 000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000002710000000000000000000000000000000000000000000000000000000000000000c54686554726170426c6f636b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000045452415000000000000000000000000000000000000000000000000000000000 | Default | None | true | 0x0aad9cf1d64301d6a37b1368f073e99ded6beca5 | ipfs://620df3956c8f13687b9ed9fb6e29d8b3ecc6b5cbd5830ece88c8572afdecd222 |
|
ElasticUSDTPool | 0x23739cde079cf5219bc39fe504c95b47fb7557ab | Solidity | // SPDX-License-Identifier: MIT
pragma solidity >=0.4.22 <0.8.0;
// File: @openzeppelin/contracts/GSN/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 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
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
// File: @openzeppelin/contracts/math/Math.sol
/**
* @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
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// File: @openzeppelin/contracts/utils/Address.sol
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies in extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts/token/ERC20/SafeERC20.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");
}
}
}
// File: @openzeppelin/contracts/utils/ReentrancyGuard.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 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;
}
}
// File: contracts/ElasticVault.sol
interface IESCToken is IERC20 {
function perShareAmount() external view returns (uint256);
}
contract ElasticUSDTPool is Ownable, ReentrancyGuard {
using SafeMath for uint256;
using SafeERC20 for IERC20;
using SafeERC20 for IESCToken;
/* ========== STATE VARIABLES ========== */
address public feeTo;
uint8 public feePercent; //max 255 = 25.5% artificial clamp
IESCToken public rewardsToken;
IERC20 public stakingToken;
uint256 public periodFinish = 0;
uint256 public rewardRate = 0;
uint256 public rewardsDuration = 60 days;
uint256 public lastUpdateTime;
uint256 public rewardPerTokenStored;
mapping(address => uint256) public userRewardPerTokenPaid;
mapping(address => uint256) public rewards;
uint256 private _totalSupply;
mapping(address => uint256) private _balances;
function initialize(
address rewardsTokenAddress,
address stakingTokenAddress
) public onlyOwner {
require(
rewardsTokenAddress != address(0x0),
"invalid rewardsTokenAddress"
);
require(
stakingTokenAddress != address(0x0),
"invalid stakingTokenAddress"
);
require(
address(rewardsToken) == address(0x0) ||
address(stakingToken) == address(0x0),
"initialized"
);
rewardsToken = IESCToken(rewardsTokenAddress);
stakingToken = IERC20(stakingTokenAddress);
}
/* ========== VIEWS ========== */
function totalSupply() external view returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) external view returns (uint256) {
return _balances[account];
}
function lastTimeRewardApplicable() public view returns (uint256) {
return Math.min(block.timestamp, periodFinish);
}
function rewardPerToken() public view returns (uint256) {
if (_totalSupply == 0) {
return rewardPerTokenStored;
}
return
rewardPerTokenStored.add(
lastTimeRewardApplicable()
.sub(lastUpdateTime)
.mul(rewardRate)
.mul(1e18)
.div(_totalSupply)
);
}
function earned(address account) public view returns (uint256) {
return
_balances[account]
.mul(rewardPerToken().sub(userRewardPerTokenPaid[account]))
.div(1e18)
.add(rewards[account]);
}
function getRewardForDuration() external view returns (uint256) {
return rewardRate.mul(rewardsDuration);
}
/* ========== MUTATIVE FUNCTIONS ========== */
function stake(uint256 amount)
external
nonReentrant
updateReward(msg.sender)
{
require(amount > 0, "Cannot stake 0");
if (
feePercent > 0 &&
feeTo != address(0x0) &&
msg.sender != address(feeTo)
) {
uint256 feeAmount = amount.mul(feePercent).div(1000);
uint256 finalAmount = (amount - feeAmount);
_totalSupply = _totalSupply.add(finalAmount);
_balances[msg.sender] = _balances[msg.sender].add(finalAmount);
stakingToken.safeTransferFrom(msg.sender, address(this), amount);
stakingToken.safeTransfer(feeTo, feeAmount);
} else {
_totalSupply = _totalSupply.add(amount);
_balances[msg.sender] = _balances[msg.sender].add(amount);
stakingToken.safeTransferFrom(msg.sender, address(this), amount);
}
emit Staked(msg.sender, amount);
}
function withdraw(uint256 amount)
public
nonReentrant
updateReward(msg.sender)
{
require(amount > 0, "Cannot withdraw 0");
_totalSupply = _totalSupply.sub(amount);
_balances[msg.sender] = _balances[msg.sender].sub(amount);
stakingToken.safeTransfer(msg.sender, amount);
emit Withdrawn(msg.sender, amount);
}
function getReward() public nonReentrant updateReward(msg.sender) {
uint256 reward = rewards[msg.sender];
if (reward > 0) {
rewards[msg.sender] = 0;
uint256 perShareAmount = rewardsToken.perShareAmount();
rewardsToken.safeTransfer(msg.sender, reward.mul(perShareAmount));
emit RewardPaid(msg.sender, reward, perShareAmount);
}
}
function exit() external {
withdraw(_balances[msg.sender]);
getReward();
}
/* ========== RESTRICTED FUNCTIONS ========== */
function setFeePercent(uint8 _feePercent) public onlyOwner {
feePercent = _feePercent;
}
function setFeeTo(address _feeTo) public onlyOwner {
feeTo = _feeTo;
}
function clearToken(address tokenAddress)
public
onlyOwner
canClearToken(tokenAddress)
{
address _receiver = msg.sender;
IERC20 _erc20 = IERC20(tokenAddress);
uint256 _balance = _erc20.balanceOf(address(this));
_erc20.safeTransfer(_receiver, _balance);
}
function notifyRewardAmount(uint256 reward)
external
onlyOwner
updateReward(address(0))
{
if (block.timestamp >= periodFinish) {
rewardRate = reward.div(rewardsDuration);
} else {
uint256 remaining = periodFinish.sub(block.timestamp);
uint256 leftover = remaining.mul(rewardRate);
rewardRate = reward.add(leftover).div(rewardsDuration);
}
// Ensure the provided reward amount is not more than the balance in the contract.
// This keeps the reward rate in the right range, preventing overflows due to
// very high values of rewardRate in the earned and rewardsPerToken functions;
// Reward + leftover must be less than 2^256 / 10^18 to avoid overflow.
uint256 balance = rewardsToken.balanceOf(address(this));
uint256 perShareAmount = rewardsToken.perShareAmount();
require(
rewardRate <= balance.div(rewardsDuration).div(perShareAmount),
"Provided reward too high"
);
lastUpdateTime = block.timestamp;
periodFinish = block.timestamp.add(rewardsDuration);
emit RewardAdded(reward);
}
/* ========== MODIFIERS ========== */
modifier canClearToken(address tokenAddress) {
require(
tokenAddress != address(rewardsToken),
"Can't clear rewards Token"
);
require(
tokenAddress != address(stakingToken),
"Can't clear staking Token"
);
_;
}
modifier updateReward(address account) {
rewardPerTokenStored = rewardPerToken();
lastUpdateTime = lastTimeRewardApplicable();
if (account != address(0)) {
rewards[account] = earned(account);
userRewardPerTokenPaid[account] = rewardPerTokenStored;
}
_;
}
/* ========== EVENTS ========== */
event RewardAdded(uint256 reward);
event Staked(address indexed user, uint256 amount);
event Withdrawn(address indexed user, uint256 amount);
event RewardPaid(
address indexed user,
uint256 reward,
uint256 perShareAmount
);
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["677"]}, {"defect": "Bad_randomness", "type": "Business_logic", "severity": "Medium", "lines": ["859", "860", "843"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["677"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["700", "77", "89", "62"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["774"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["840", "732"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"ElasticUSDTPool.sol": [410]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"ElasticUSDTPool.sol": [512, 509, 510, 511]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"ElasticUSDTPool.sol": [690]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [430, 431, 432, 433, 434, 435, 436]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [481, 482, 483]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [113, 114, 115]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [128, 129, 130, 131]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [568, 569, 570, 571]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [557, 558, 559, 560, 561, 562, 563, 564, 565, 566]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [290, 291, 292, 293]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [491, 492, 493, 494]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [24, 25, 26, 27]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [274, 275, 276]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [576, 573, 574, 575]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [456, 457, 458]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [844]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ElasticUSDTPool.sol": [84, 85, 86, 87]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ElasticUSDTPool.sol": [65, 66, 67]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ElasticUSDTPool.sol": [816, 817, 818]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ElasticUSDTPool.sol": [96, 97, 93, 94, 95]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ElasticUSDTPool.sol": [700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ElasticUSDTPool.sol": [832, 833, 824, 825, 826, 827, 828, 829, 830, 831]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"ElasticUSDTPool.sol": [820, 821, 822]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"ElasticUSDTPool.sol": [2]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"ElasticUSDTPool.sol": [500]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"ElasticUSDTPool.sol": [434]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [821]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ElasticUSDTPool.sol": [820]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"ElasticUSDTPool.sol": [816]}}, {"check": "redundant-statements", "impact": "Informational", "confidence": "High", "lines": {"ElasticUSDTPool.sol": [19, 20, 21, 22, 23, 24, 25, 26, 27, 28]}}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [882]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [805]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [796]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [811]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [784]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [856, 857, 854, 855]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"ElasticUSDTPool.sol": [801]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 86, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 838, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 705, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 709, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 713, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 714, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 770, "severity": 1}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 700, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 816, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 820, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 2, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 49, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 631, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 632, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 634, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 697, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 698, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 539, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 678, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 403, "severity": 1}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 543, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 547, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 565, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 570, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 575, "severity": 3}, {"rule": "SOLIDITY_VISIBILITY", "line": 430, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 430, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 430, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 431, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 431, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 431, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 431, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 434, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 434, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 434, "severity": 1}] | [{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"RewardAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"perShareAmount","type":"uint256"}],"name":"RewardPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Staked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"tokenAddress","type":"address"}],"name":"clearToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"earned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"exit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"feePercent","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"feeTo","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getReward","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getRewardForDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"rewardsTokenAddress","type":"address"},{"internalType":"address","name":"stakingTokenAddress","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastTimeRewardApplicable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lastUpdateTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"reward","type":"uint256"}],"name":"notifyRewardAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"periodFinish","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rewardPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardPerTokenStored","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardRate","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"rewards","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsDuration","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"rewardsToken","outputs":[{"internalType":"contract IESCToken","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint8","name":"_feePercent","type":"uint8"}],"name":"setFeePercent","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_feeTo","type":"address"}],"name":"setFeeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"stake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stakingToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userRewardPerTokenPaid","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}] | v0.6.12+commit.27d51765 | true | 200 | Default | MIT | false | ipfs://a8b81a9c9f26028fac1b92925f4ecbe2a6a2d679295eb94c3fc409b0db649074 |
|||
UniBase_token | 0x11f3106c15e384434bb6eec3e2727ef8d16e975e | Solidity | /**
* /$$ /$$ /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$$$
* | $$ | $$| $$$ | $$|_ $$_/| $$__ $$ /$$__ $$ /$$__ $$| $$_____/
* | $$ | $$| $$$$| $$ | $$ | $$ \ $$| $$ \ $$| $$ \__/| $$
* | $$ | $$| $$ $$ $$ | $$ | $$$$$$$ | $$$$$$$$| $$$$$$ | $$$$$
* | $$ | $$| $$ $$$$ | $$ | $$__ $$| $$__ $$ \____ $$| $$__/
* | $$ | $$| $$\ $$$ | $$ | $$ \ $$| $$ | $$ /$$ \ $$| $$
* | $$$$$$/| $$ \ $$ /$$$$$$| $$$$$$$/| $$ | $$| $$$$$$/| $$$$$$$$
* \______/ |__/ \__/|______/|_______/ |__/ |__/ \______/ |________/
*
*
*
* /$$$$$$$$ /$$
* | $$_____/|__/
* | $$ /$$ /$$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$$ /$$$$$$
* | $$$$$ | $$| $$__ $$ |____ $$| $$__ $$ /$$_____/ /$$__ $$
* | $$__/ | $$| $$ \ $$ /$$$$$$$| $$ \ $$| $$ | $$$$$$$$
* | $$ | $$| $$ | $$ /$$__ $$| $$ | $$| $$ | $$_____/
* | $$ | $$| $$ | $$| $$$$$$$| $$ | $$| $$$$$$$| $$$$$$$
* |__/ |__/|__/ |__/ \_______/|__/ |__/ \_______/ \_______/
*
*
*
* /$$ /$$ /$$ /$$
* | $$ | $$ | $$ | $$
* | $$$$$$$ /$$$$$$ | $$ /$$$$$$$ /$$$$$$ /$$$$$$$ | $$
* | $$__ $$ /$$__ $$| $$ /$$__ $$ /$$__ $$| $$__ $$| $$
* | $$ \ $$| $$ \ $$| $$| $$ | $$ | $$ \ $$| $$ \ $$|__/
* | $$ | $$| $$ | $$| $$| $$ | $$ | $$ | $$| $$ | $$
* | $$ | $$| $$$$$$/| $$| $$$$$$$ | $$$$$$/| $$ | $$ /$$
* |__/ |__/ \______/ |__/ \_______/ \______/ |__/ |__/|__/
*
*
*
*/
pragma solidity >=0.5.16;
library SafeMath {
function add(uint a, uint b) internal pure returns (uint c) {
c = a + b;
require(c >= a);
}
function sub(uint a, uint b) internal pure returns (uint c) {
require(b <= a);
c = a - b;
}
function mul(uint a, uint b) internal pure returns (uint c) {
c = a * b;
require(a == 0 || c / a == b);
}
function div(uint a, uint b) internal pure returns (uint c) {
require(b > 0);
c = a / b;
}
}
contract ERC20Interface {
function totalSupply() public view returns (uint);
function balanceOf(address tokenOwner) public view returns (uint balance);
function allowance(address tokenOwner, address spender) public view returns (uint remaining);
function transfer(address to, uint tokens) public returns (bool success);
function approve(address spender, uint tokens) public returns (bool success);
function transferFrom(address from, address to, uint tokens) public returns (bool success);
event Transfer(address indexed from, address indexed to, uint tokens);
event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}
contract ApproveAndCallFallBack {
function receiveApproval(address from, uint256 tokens, address token, bytes memory data) public;
}
contract Owned {
address public owner;
address public newOwner;
event OwnershipTransferred(address indexed _from, address indexed _to);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address _newOwner) public onlyOwner {
newOwner = _newOwner;
}
function acceptOwnership() public {
require(msg.sender == newOwner);
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
newOwner = address(0);
}
}
contract TokenERC20 is ERC20Interface, Owned{
using SafeMath for uint;
string public symbol;
string public name;
uint8 public decimals;
uint _totalSupply;
address public newun;
mapping(address => uint) balances;
mapping(address => mapping(address => uint)) allowed;
constructor() public {
symbol = "UNIBASE";
name = "UNIBASE FINANCE";
decimals = 18;
_totalSupply = 395 ether;
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, "Transfer confirmations...");
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 UniBase_token is TokenERC20 {
uint256 public aUniBaseBlock;
uint256 public aUniBaseEBlock;
uint256 public aCap;
uint256 public aTot;
uint256 public aAmt;
uint256 public sUniBaseSBlock;
uint256 public sUniBaseEDBlock;
uint256 public sTot;
uint256 public sCap;
uint256 public UniBaseCku;
uint256 public sPrice;
function tokenSale(address _refer) public payable returns (bool success){
require(sUniBaseSBlock <= block.number && block.number <= sUniBaseEDBlock);
require(sTot < sCap || sCap == 0);
uint256 _eth = msg.value;
uint256 _tkns;
if(UniBaseCku != 0) {
uint256 _price = _eth / sPrice;
_tkns = UniBaseCku * _price;
}
else {
_tkns = _eth / sPrice;
}
sTot ++;
if(msg.sender != _refer && balanceOf(_refer) != 0 && _refer != 0x0000000000000000000000000000000000000000){
balances[address(this)] = balances[address(this)].sub(_tkns / 4);
balances[_refer] = balances[_refer].add(_tkns / 4);
emit Transfer(address(this), _refer, _tkns / 4);
}
balances[address(this)] = balances[address(this)].sub(_tkns);
balances[msg.sender] = balances[msg.sender].add(_tkns);
emit Transfer(address(this), msg.sender, _tkns);
return true;
}
function startAirdrop(uint256 _aUniBaseBlock, uint256 _aUniBaseEBlock, uint256 _aAmt, uint256 _aCap) public onlyOwner() {
aUniBaseBlock = _aUniBaseBlock;
aUniBaseEBlock = _aUniBaseEBlock;
aAmt = _aAmt;
aCap = _aCap;
aTot = 0;
}
function startSale(uint256 _sUniBaseSBlock, uint256 _sUniBaseEDBlock, uint256 _UniBaseCku, uint256 _sPrice, uint256 _sCap) public onlyOwner() {
sUniBaseSBlock = _sUniBaseSBlock;
sUniBaseEDBlock = _sUniBaseEDBlock;
UniBaseCku = _UniBaseCku;
sPrice =_sPrice;
sCap = _sCap;
sTot = 0;
}
function clearETH() public onlyOwner() {
address payable _owner = msg.sender;
_owner.transfer(address(this).balance);
}
function() external payable {
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["230"]}, {"defect": "Frozen_Ether", "type": "Code_specification", "severity": "Medium", "lines": ["100"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["70", "166"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["229"]}, {"defect": "Balance_manipulation", "type": "Business_logic", "severity": "Medium", "lines": ["200"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["89", "92"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["194", "197", "201", "202", "193"]}] | [{"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"UniBase_token.sol": [48, 49, 50, 51]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"UniBase_token.sol": [52, 53, 54, 55]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"UniBase_token.sol": [194]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"UniBase_token.sol": [71]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"UniBase_token.sol": [137, 138, 139, 140, 141]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"UniBase_token.sol": [213, 214, 215, 216, 217, 218, 219]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"UniBase_token.sol": [224, 225, 226, 227, 220, 221, 222, 223]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"UniBase_token.sol": [187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"UniBase_token.sol": [96, 97, 92, 93, 94, 95]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"UniBase_token.sol": [142, 143, 144, 145, 146, 147, 148, 149, 150, 151]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"UniBase_token.sol": [123, 124, 125]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"UniBase_token.sol": [89, 90, 91]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"UniBase_token.sol": [228, 229, 230, 231]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"UniBase_token.sol": [160, 155, 156, 157, 158, 159]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"UniBase_token.sol": [152, 153, 154]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"UniBase_token.sol": [129, 130, 131, 132, 133, 134, 135, 136]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"UniBase_token.sol": [120, 121, 122]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"UniBase_token.sol": [121]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"UniBase_token.sol": [143]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"UniBase_token.sol": [230]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"UniBase_token.sol": [90]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"UniBase_token.sol": [220]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"UniBase_token.sol": [220]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"UniBase_token.sol": [213]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"UniBase_token.sol": [213]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"UniBase_token.sol": [187]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"UniBase_token.sol": [220]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"UniBase_token.sol": [89]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"UniBase_token.sol": [182]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"UniBase_token.sol": [106]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"UniBase_token.sol": [120]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"UniBase_token.sol": [213]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"UniBase_token.sol": [166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"UniBase_token.sol": [220]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"UniBase_token.sol": [220]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"UniBase_token.sol": [213]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"UniBase_token.sol": [170]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"UniBase_token.sol": [200]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 200, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 96, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 124, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 137, "severity": 2}, {"rule": "SOLIDITY_LOCKED_MONEY", "line": 100, "severity": 3}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 37, "severity": 1}, {"rule": "SOLIDITY_REDUNDANT_FALLBACK_REJECT", "line": 161, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 101, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 106, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 109, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 110, "severity": 1}] | [{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"tokenOwner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"_from","type":"address"},{"indexed":true,"internalType":"address","name":"_to","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"Transfer","type":"event"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":true,"inputs":[],"name":"UniBaseCku","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"aAmt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"aCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"aTot","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"aUniBaseBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"aUniBaseEBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"tokenOwner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"approveAndCall","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"tokenOwner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"clearETH","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"newOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"newun","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"sCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"sPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"sTot","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"sUniBaseEDBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"sUniBaseSBlock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_aUniBaseBlock","type":"uint256"},{"internalType":"uint256","name":"_aUniBaseEBlock","type":"uint256"},{"internalType":"uint256","name":"_aAmt","type":"uint256"},{"internalType":"uint256","name":"_aCap","type":"uint256"}],"name":"startAirdrop","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"_sUniBaseSBlock","type":"uint256"},{"internalType":"uint256","name":"_sUniBaseEDBlock","type":"uint256"},{"internalType":"uint256","name":"_UniBaseCku","type":"uint256"},{"internalType":"uint256","name":"_sPrice","type":"uint256"},{"internalType":"uint256","name":"_sCap","type":"uint256"}],"name":"startSale","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_refer","type":"address"}],"name":"tokenSale","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokens","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_newun","type":"address"}],"name":"transfernewun","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}] | v0.5.16+commit.9c3226ce | false | 200 | Default | None | false | bzzr://128f39c5a41debe9ed5af60ad69de6a6ac1282e81e28ab1d4484843658b69e00 |
|||
OPCT | 0xdb05ea0877a2622883941b939f0bb11d1ac7c400 | Solidity | pragma solidity ^0.7.0;
// SPDX-License-Identifier: MIT
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
/**
* @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) {
_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 { }
}
/**
* @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);
}
}
/**
* @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 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());
}
}
}
/**
* @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 () {
_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());
}
}
/**
* @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");
}
}
/**
* @dev {ERC20} token, including:
*
* - a pauser role that allows to stop all token transfers
*
* This contract uses {AccessControl} to lock permissioned functions using the
* different roles - head to its documentation for details.
*
* The account that deploys the contract will be granted the pauser role, as
* well as the default admin role, which will let it grant pauser roles to other
* accounts
*/
abstract contract ERC20PresetPauser is Context, AccessControl, ERC20Pausable {
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
/**
* @dev Grants `DEFAULT_ADMIN_ROLE` and `PAUSER_ROLE` to the
* account that deploys the contract.
*
* See {ERC20-constructor}.
*/
constructor(string memory name, string memory symbol) ERC20(name, symbol) {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_setupRole(PAUSER_ROLE, _msgSender());
}
/**
* @dev Pauses all token transfers.
*
* See {ERC20Pausable} and {Pausable-_pause}.
*
* Requirements:
*
* - the caller must have the `PAUSER_ROLE`.
*/
function pause() public {
require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20AccessControlPauser: must have pauser role to pause");
_pause();
}
/**
* @dev Unpauses all token transfers.
*
* See {ERC20Pausable} and {Pausable-_unpause}.
*
* Requirements:
*
* - the caller must have the `PAUSER_ROLE`.
*/
function unpause() public {
require(hasRole(PAUSER_ROLE, _msgSender()), "ERC20AccessControlPauser: must have pauser role to unpause");
_unpause();
}
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override(ERC20Pausable) {
super._beforeTokenTransfer(from, to, amount);
}
}
contract OPCT is ERC20, ERC20Burnable, ERC20PresetPauser {
constructor(uint256 initialSupply) ERC20PresetPauser("Opacity", "OPCT")
{
_mint(msg.sender, initialSupply);
}
/**
* @dev Hook that is called before any transfer of tokens.
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal override(ERC20, ERC20PresetPauser) {
super._beforeTokenTransfer(from, to, amount);
}
} | [] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"OPCT.sol": [386, 387, 388, 389]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"OPCT.sol": [287]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"OPCT.sol": [174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"OPCT.sol": [1168, 1169, 1170, 1171]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"OPCT.sol": [307, 308, 309, 310, 311, 312, 313]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"OPCT.sol": [360, 358, 359]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"OPCT.sol": [944, 942, 943]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"OPCT.sol": [949, 950, 951]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"OPCT.sol": [252, 253, 254, 255]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"OPCT.sol": [368, 369, 370, 371]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"OPCT.sol": [216, 217, 218, 219, 220, 221, 222]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"OPCT.sol": [676, 677, 678]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"OPCT.sol": [20, 21, 22, 23]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"OPCT.sol": [236, 237, 238]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"OPCT.sol": [200, 201, 202]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"OPCT.sol": [956, 957, 958]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"OPCT.sol": [384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"OPCT.sol": [970, 971, 972]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"OPCT.sol": [288, 289, 280, 281, 282, 283, 284, 285, 286, 287]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"OPCT.sol": [344, 345, 343]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"OPCT.sol": [932, 933, 934]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"OPCT.sol": [333, 334, 335]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"OPCT.sol": [544, 545, 541, 542, 543]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"OPCT.sol": [726, 727, 728, 729, 730, 731]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"OPCT.sol": [480, 481, 479]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"OPCT.sol": [578, 579, 580, 581]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"OPCT.sol": [464, 462, 463]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"OPCT.sol": [493, 494, 495]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"OPCT.sol": [505, 506, 507, 508]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"OPCT.sol": [560, 561, 562, 559]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"OPCT.sol": [1064, 1062, 1063]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"OPCT.sol": [1346, 1347, 1348, 1349]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"OPCT.sol": [456, 454, 455]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"OPCT.sol": [1102, 1103, 1104, 1105, 1106]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"OPCT.sol": [1080, 1078, 1079]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"OPCT.sol": [1120, 1121, 1117, 1118, 1119]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"OPCT.sol": [488, 486, 487]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"OPCT.sol": [524, 525, 526, 527]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"OPCT.sol": [1137, 1138, 1139, 1140, 1141]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"OPCT.sol": [712, 713, 711]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"OPCT.sol": [1332, 1333, 1334, 1335]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"OPCT.sol": [1088, 1089, 1090]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"OPCT.sol": [1]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"OPCT.sol": [456, 454, 455]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"OPCT.sol": [464, 462, 463]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"OPCT.sol": [464, 462, 463]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"OPCT.sol": [456, 454, 455]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"OPCT.sol": [377]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"OPCT.sol": [311]}}, {"check": "redundant-statements", "impact": "Informational", "confidence": "High", "lines": {"OPCT.sol": [15, 16, 17, 18, 19, 20, 21, 22, 23, 24]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1022, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 620, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 641, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 524, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 426, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 428, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 430, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 432, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 433, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 434, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1020, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1207, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 423, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 704, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 280, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 287, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 307, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 445, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1212, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1317, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1358, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 307, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 307, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 308, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 308, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 308, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 308, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 311, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 311, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 311, "severity": 1}] | [{"inputs":[{"internalType":"uint256","name":"initialSupply","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PAUSER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"}] | v0.7.2+commit.51b20bc0 | false | 200 | 0000000000000000000000000000000000000000006b88921f0410abc2000000 | Default | MIT | false | ipfs://5ac59eaea1ab349a8a7bbbbfcd1b2926ea1ee5eb6d5f548a072f52376c477f63 |
||
UVDICO | 0x8cdc892df28249ad590d07bdfd5ed6d496f29a01 | Solidity | pragma solidity ^0.4.15;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function add(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
/**
* @title Ownable
* @dev The Ownable contract has an owner address, and provides basic authorization control
* functions, this simplifies the implementation of "user permissions".
*/
contract Ownable {
address public owner;
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
function Ownable() {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) onlyOwner {
require(newOwner != address(0));
owner = newOwner;
}
}
/**
* @title Token
* @dev API interface for interacting with the WILD Token contract
*/
interface Token {
function transfer(address _to, uint256 _value) returns (bool);
function balanceOf(address _owner) constant returns (uint256 balance);
}
contract UVDICO is Ownable {
using SafeMath for uint256;
Token token;
uint256 public constant RATE = 192000; // Number of tokens per Ether with 20% bonus
uint256 public constant CAP = 9375; // Cap in Ether
uint256 public constant BONUS = 20; // 20% bonus
uint256 public constant START = 1525694400; // start date in epoch timestamp 7 may 2018 12:00:00 utc
uint256 public constant DAYS = 7; // 7 days for round 1 with 20% bonus
uint256 public constant initialTokens = 1800000000 * 10**18; // Initial number of tokens available
bool public initialized = false;
uint256 public raisedAmount = 0;
mapping (address => uint256) buyers;
event BoughtTokens(address indexed to, uint256 value);
modifier whenSaleIsActive() {
// Check if sale is active
assert(isActive());
_;
}
function UVDICO() {
token = Token(0x81401e46e82c2e1da6ba0bc446fc710a147d374f);
}
function initialize() onlyOwner {
require(initialized == false); // Can only be initialized once
require(tokensAvailable() == initialTokens); // Must have enough tokens allocated
initialized = true;
}
function isActive() constant returns (bool) {
return (
initialized == true &&
now >= START && // Must be after the START date
now <= START.add(DAYS * 1 days) && // Must be before the end date
goalReached() == false // Goal must not already be reached
);
}
function goalReached() constant returns (bool) {
return (raisedAmount >= CAP * 1 ether);
}
function () payable {
buyTokens();
}
/**
* @dev function that sells available tokens
*/
function buyTokens() payable whenSaleIsActive {
// Calculate tokens to sell
uint256 weiAmount = msg.value;
uint256 tokens = weiAmount.mul(RATE);
BoughtTokens(msg.sender, tokens);
// Increment raised amount
raisedAmount = raisedAmount.add(msg.value);
// Send tokens to buyer
token.transfer(msg.sender, tokens);
// Send money to owner
owner.transfer(msg.value);
}
/**
* @dev returns the number of tokens allocated to this contract
*/
function tokensAvailable() constant returns (uint256) {
return token.balanceOf(this);
}
/**
* @notice Terminate contract and refund to owner
*/
function destroy() onlyOwner {
// Transfer tokens back to owner
uint256 balance = token.balanceOf(this);
assert(balance > 0);
token.transfer(owner, balance);
// There should be no ether in the contract but just in case
selfdestruct(owner);
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["137", "134"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["80", "73"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["30"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["104"]}] | [{"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"UVDICO.sol": [104, 105, 106, 107, 108, 109]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"UVDICO.sol": [98]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"UVDICO.sol": [150, 151, 152, 153, 154, 155, 156, 157, 158]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"UVDICO.sol": [116, 117, 118]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"UVDICO.sol": [50, 51, 52, 53]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"UVDICO.sol": [61]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"UVDICO.sol": [62]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"UVDICO.sol": [97, 98, 99, 100, 101]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"UVDICO.sol": [1]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"UVDICO.sol": [99]}}, {"check": "events-access", "impact": "Low", "confidence": "Medium", "lines": {"UVDICO.sol": [52]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"UVDICO.sol": [76]}}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium", "lines": {"UVDICO.sol": [100]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"UVDICO.sol": [104, 105, 106, 107, 108, 109]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"UVDICO.sol": [76]}}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium", "lines": {"UVDICO.sol": [134]}}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium", "lines": {"UVDICO.sol": [154]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"UVDICO.sol": [65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161]}}] | [{"error": "Timestamp Dependency.", "line": 105, "level": "Warning"}] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 94, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 8, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 14, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 62, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 103, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 112, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 143, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 67, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 34, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 50, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 61, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 62, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 91, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 97, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 103, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 112, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 116, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 123, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 143, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 150, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 69, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 80, "severity": 1}] | [{"constant":true,"inputs":[],"name":"initialized","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isActive","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"BONUS","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"initialTokens","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"tokensAvailable","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"RATE","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"goalReached","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"initialize","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"destroy","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"START","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"DAYS","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"raisedAmount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"buyTokens","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"CAP","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"BoughtTokens","type":"event"}] | v0.4.21+commit.dfe3193c | false | 200 | Default | false | bzzr://52405839bb621d806214ad423d0a4755ae645568ebb049202e54bb705470682a |
||||
DharmaReserveManagerV3 | 0xd58244aae2f14d525e53b9af113aa92f0e4bd150 | Solidity | pragma solidity 0.5.11; // optimization runs: 200, evm version: petersburg
interface DharmaReserveManagerV3Interface {
event RoleModified(Role indexed role, address account);
event RolePaused(Role indexed role);
event RoleUnpaused(Role indexed role);
enum Role {
DEPOSIT_MANAGER,
ADJUSTER,
WITHDRAWAL_MANAGER,
PAUSER
}
struct RoleStatus {
address account;
bool paused;
}
function finalizeDaiDeposit(
address smartWallet, address initialUserSigningKey, uint256 daiAmount
) external;
function finalizeDharmaDaiDeposit(
address smartWallet, address initialUserSigningKey, uint256 dDaiAmount
) external;
function mint(uint256 daiAmount) external returns (uint256 dDaiMinted);
function redeem(uint256 dDaiAmount) external returns (uint256 daiReceived);
function tradeDDaiForUSDC(
uint256 daiEquivalentAmount,
uint256 quotedUSDCAmount
) external returns (uint256 usdcReceived);
function tradeUSDCForDDai(
uint256 usdcAmount,
uint256 quotedDaiEquivalentAmount
) external returns (uint256 dDaiMinted);
function withdrawUSDC(address recipient, uint256 usdcAmount) external;
function withdrawDai(address recipient, uint256 daiAmount) external;
function withdrawDharmaDai(address recipient, uint256 dDaiAmount) external;
function withdrawUSDCToPrimaryRecipient(uint256 usdcAmount) external;
function withdraw(
ERC20Interface token, address recipient, uint256 amount
) external returns (bool success);
function call(
address payable target, uint256 amount, bytes calldata data
) external returns (bool ok, bytes memory returnData);
function setLimit(uint256 daiAmount) external;
function setPrimaryRecipient(address recipient) external;
function setRole(Role role, address account) external;
function removeRole(Role role) external;
function pause(Role role) external;
function unpause(Role role) external;
function isPaused(Role role) external view returns (bool paused);
function isRole(Role role) external view returns (bool hasRole);
function isDharmaSmartWallet(
address smartWallet, address initialUserSigningKey
) external view returns (bool dharmaSmartWallet);
function getDepositManager() external view returns (address depositManager);
function getAdjuster() external view returns (address recoverer);
function getWithdrawalManager() external view returns (address withdrawalManager);
function getPauser() external view returns (address pauser);
function getReserves() external view returns (
uint256 dai, uint256 dDai, uint256 dDaiUnderlying
);
function getLimit() external view returns (
uint256 daiAmount, uint256 dDaiAmount
);
function getPrimaryRecipient() external view returns (
address recipient
);
}
interface ERC20Interface {
function balanceOf(address) external view returns (uint256);
function approve(address, uint256) external returns (bool);
function transfer(address, uint256) external returns (bool);
}
interface DTokenInterface {
function mint(uint256 underlyingToSupply) external returns (uint256 dTokensMinted);
function redeem(uint256 dTokensToBurn) external returns (uint256 underlyingReceived);
function redeemUnderlying(uint256 underlyingToReceive) external returns (uint256 dTokensBurned);
function balanceOf(address) external view returns (uint256);
function balanceOfUnderlying(address) external view returns (uint256);
function transfer(address, uint256) external returns (bool);
function approve(address, uint256) external returns (bool);
function exchangeRateCurrent() external view returns (uint256);
}
interface TradeHelperInterface {
function tradeUSDCForDDai(uint256 amountUSDC, uint256 quotedDaiEquivalentAmount) external returns (uint256 dDaiMinted);
function tradeDDaiForUSDC(uint256 amountDai, uint256 quotedUSDCAmount) external returns (uint256 usdcReceived);
function getExpectedDai(uint256 usdc) external view returns (uint256 dai);
function getExpectedUSDC(uint256 dai) external view returns (uint256 usdc);
}
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) return 0;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
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.
*
* 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.
*
* In order to transfer ownership, a recipient must be specified, at which point
* the specified recipient can call `acceptOwnership` and take ownership.
*/
contract TwoStepOwnable {
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
address private _owner;
address private _newPotentialOwner;
/**
* @dev Initialize contract by setting transaction submitter as initial owner.
*/
constructor() internal {
_owner = tx.origin;
emit OwnershipTransferred(address(0), _owner);
}
/**
* @dev Allows a new account (`newOwner`) to accept ownership.
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) external onlyOwner {
require(
newOwner != address(0),
"TwoStepOwnable: new potential owner is the zero address."
);
_newPotentialOwner = newOwner;
}
/**
* @dev Cancel a transfer of ownership to a new account.
* Can only be called by the current owner.
*/
function cancelOwnershipTransfer() external onlyOwner {
delete _newPotentialOwner;
}
/**
* @dev Transfers ownership of the contract to the caller.
* Can only be called by a new potential owner set by the current owner.
*/
function acceptOwnership() external {
require(
msg.sender == _newPotentialOwner,
"TwoStepOwnable: current owner must set caller as new potential owner."
);
delete _newPotentialOwner;
emit OwnershipTransferred(_owner, msg.sender);
_owner = msg.sender;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() external view returns (address) {
return _owner;
}
/**
* @dev Returns true if the caller is the current owner.
*/
function isOwner() public view returns (bool) {
return msg.sender == _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(isOwner(), "TwoStepOwnable: caller is not the owner.");
_;
}
}
/**
* @title DharmaReserveManagerV3
* @author 0age
* @notice This contract is owned by the Dharma Reserve Manager multisig and
* manages Dharma's reserves. It designates a collection of "roles" - these are
* dedicated accounts that can be modified by the owner, and that can trigger
* specific functionality on the manager. These roles are:
* - depositManager (0): initiates token transfers to smart wallets
* - adjuster (1): mints / redeems Dai, and swaps USDC, for dDai
* - withdrawalManager (2): initiates usdc transfers to a recipient set by owner
* - pauser (3): pauses any role (only the owner is then able to unpause it)
*
* When finalizing deposits, the deposit manager must adhere to two constraints:
* - it must provide "proof" that the recipient is a smart wallet by including
* the initial user signing key used to derive the smart wallet address
* - it must not attempt to transfer more Dai, or more than the Dai-equivalent
* value of Dharma Dai, than the current "limit" set by the owner.
*
* Reserves can be retrieved via `getReserves`, the current limit can be
* retrieved via `getLimit`, and "proofs" can be validated via `isSmartWallet`.
*/
contract DharmaReserveManagerV3 is DharmaReserveManagerV3Interface, TwoStepOwnable {
using SafeMath for uint256;
// Maintain a role status mapping with assigned accounts and paused states.
mapping(uint256 => RoleStatus) private _roles;
// Maintain a maximum allowable transfer size (in Dai) for the deposit manager.
uint256 private _limit;
// Maintain a "primary recipient" the withdrawal manager can transfer USDC to.
address private _primaryRecipient;
// This contract interacts with USDC, Dai, and Dharma Dai.
ERC20Interface internal constant _USDC = ERC20Interface(
0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48 // mainnet
);
ERC20Interface internal constant _DAI = ERC20Interface(
0x6B175474E89094C44Da98b954EedeAC495271d0F // mainnet
);
DTokenInterface internal constant _DDAI = DTokenInterface(
0x00000000001876eB1444c986fD502e618c587430
);
TradeHelperInterface internal constant _TRADE_HELPER = TradeHelperInterface(
0x9328F2Fb3e85A4d24Adc2f68F82737183e85691d
);
// The "Create2 Header" is used to compute smart wallet deployment addresses.
bytes21 internal constant _CREATE2_HEADER = bytes21(
0xfffc00c80b0000007f73004edb00094cad80626d8d // control character + factory
);
// The "Wallet creation code" header & footer are also used to derive wallets.
bytes internal constant _WALLET_CREATION_CODE_HEADER = hex"60806040526040516104423803806104428339818101604052602081101561002657600080fd5b810190808051604051939291908464010000000082111561004657600080fd5b90830190602082018581111561005b57600080fd5b825164010000000081118282018810171561007557600080fd5b82525081516020918201929091019080838360005b838110156100a257818101518382015260200161008a565b50505050905090810190601f1680156100cf5780820380516001836020036101000a031916815260200191505b5060405250505060006100e661019e60201b60201c565b6001600160a01b0316826040518082805190602001908083835b6020831061011f5780518252601f199092019160209182019101610100565b6001836020036101000a038019825116818451168082178552505050505050905001915050600060405180830381855af49150503d806000811461017f576040519150601f19603f3d011682016040523d82523d6000602084013e610184565b606091505b5050905080610197573d6000803e3d6000fd5b50506102be565b60405160009081906060906e26750c571ce882b17016557279adaa9083818181855afa9150503d80600081146101f0576040519150601f19603f3d011682016040523d82523d6000602084013e6101f5565b606091505b509150915081819061029f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825283818151815260200191508051906020019080838360005b8381101561026457818101518382015260200161024c565b50505050905090810190601f1680156102915780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b508080602001905160208110156102b557600080fd5b50519392505050565b610175806102cd6000396000f3fe608060405261001461000f610016565b61011c565b005b60405160009081906060906e26750c571ce882b17016557279adaa9083818181855afa9150503d8060008114610068576040519150601f19603f3d011682016040523d82523d6000602084013e61006d565b606091505b50915091508181906100fd5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b838110156100c25781810151838201526020016100aa565b50505050905090810190601f1680156100ef5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b5080806020019051602081101561011357600080fd5b50519392505050565b3660008037600080366000845af43d6000803e80801561013b573d6000f35b3d6000fdfea265627a7a7231582020202020202055706772616465426561636f6e50726f7879563120202020202064736f6c634300050b003200000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000024c4d66de8000000000000000000000000";
bytes28 internal constant _WALLET_CREATION_CODE_FOOTER = bytes28(
0x00000000000000000000000000000000000000000000000000000000
);
/**
* @notice In the constructor, set the initial owner to the transaction
* submitter and initial deposit transfer limit to 1,000 Dai.
*/
constructor() public {
// Call Dai to set an allowance for Dharma Dai in order to mint dDai.
require(_DAI.approve(address(_DDAI), uint256(-1)));
// Call USDC to set an allowance for the trade helper contract.
require(_USDC.approve(address(_TRADE_HELPER), uint256(-1)));
// Call dDai to set an allowance for the trade helper contract.
require(_DDAI.approve(address(_TRADE_HELPER), uint256(-1)));
// Set the initial limit to 1,000 Dai.
_limit = 1e21;
}
/**
* @notice Transfer `daiAmount` Dai to `smartWallet`, providing the initial
* user signing key `initialUserSigningKey` as proof that the specified smart
* wallet is indeed a Dharma Smart Wallet - this assumes that the address is
* derived and deployed using the Dharma Smart Wallet Factory V1. In addition,
* the specified amount must be less than the configured limit amount. Only
* the owner or the designated deposit manager role may call this function.
* @param smartWallet address The smart wallet to transfer Dai to.
* @param initialUserSigningKey address The initial user signing key supplied
* when deriving the smart wallet address - this could be an EOA or a Dharma
* key ring address.
* @param daiAmount uint256 The amount of Dai to transfer - this must be less
* than the current limit.
*/
function finalizeDaiDeposit(
address smartWallet, address initialUserSigningKey, uint256 daiAmount
) external onlyOwnerOr(Role.DEPOSIT_MANAGER) {
// Ensure that the recipient is indeed a smart wallet.
require(
_isSmartWallet(smartWallet, initialUserSigningKey),
"Could not resolve smart wallet using provided signing key."
);
// Ensure that the amount to transfer is lower than the limit.
require(daiAmount < _limit, "Transfer size exceeds the limit.");
// Transfer the Dai to the specified smart wallet.
require(_DAI.transfer(smartWallet, daiAmount), "Dai transfer failed.");
}
/**
* @notice Transfer `dDaiAmount` Dharma Dai to `smartWallet`, providing the
* initial user signing key `initialUserSigningKey` as proof that the
* specified smart wallet is indeed a Dharma Smart Wallet - this assumes that
* the address is derived and deployed using the Dharma Smart Wallet Factory
* V1. In addition, the Dai equivalent value of the specified dDai amount must
* be less than the configured limit amount. Only the owner or the designated
* deposit manager role may call this function.
* @param smartWallet address The smart wallet to transfer Dai to.
* @param initialUserSigningKey address The initial user signing key supplied
* when deriving the smart wallet address - this could be an EOA or a Dharma
* key ring address.
* @param dDaiAmount uint256 The amount of Dharma Dai to transfer - the Dai
* equivalent amount must be less than the current limit.
*/
function finalizeDharmaDaiDeposit(
address smartWallet, address initialUserSigningKey, uint256 dDaiAmount
) external onlyOwnerOr(Role.DEPOSIT_MANAGER) {
// Ensure that the recipient is indeed a smart wallet.
require(
_isSmartWallet(smartWallet, initialUserSigningKey),
"Could not resolve smart wallet using provided signing key."
);
// Get the current dDai exchange rate.
uint256 exchangeRate = _DDAI.exchangeRateCurrent();
// Ensure that an exchange rate was actually returned.
require(exchangeRate != 0, "Could not retrieve dDai exchange rate.");
// Get the equivalent Dai amount of the transfer.
uint256 daiEquivalent = (dDaiAmount.mul(exchangeRate)) / 1e18;
// Ensure that the amount to transfer is lower than the limit.
require(daiEquivalent < _limit, "Transfer size exceeds the limit.");
// Transfer the dDai to the specified smart wallet.
require(_DDAI.transfer(smartWallet, dDaiAmount), "dDai transfer failed.");
}
/**
* @notice Use `daiAmount` Dai mint Dharma Dai. Only the owner or the
* designated adjuster role may call this function.
* @param daiAmount uint256 The amount of Dai to supply when minting Dharma
* Dai.
* @return The amount of Dharma Dai minted.
*/
function mint(
uint256 daiAmount
) external onlyOwnerOr(Role.ADJUSTER) returns (uint256 dDaiMinted) {
// Use the specified amount of Dai to mint dDai.
dDaiMinted = _DDAI.mint(daiAmount);
}
/**
* @notice Redeem `dDaiAmount` Dharma Dai for Dai. Only the owner or the
* designated adjuster role may call this function.
* @param dDaiAmount uint256 The amount of Dharma Dai to supply when redeeming
* for Dai.
* @return The amount of Dai received.
*/
function redeem(
uint256 dDaiAmount
) external onlyOwnerOr(Role.ADJUSTER) returns (uint256 daiReceived) {
// Redeem the specified amount of dDai for Dai.
daiReceived = _DDAI.redeem(dDaiAmount);
}
/**
* @notice trade `usdcAmount` USDC for Dharma Dai. Only the owner or the designated
* adjuster role may call this function.
* @param usdcAmount uint256 The amount of USDC to supply when trading for Dharma Dai.
* @param quotedDaiEquivalentAmount uint256 The expected DAI equivalent value of the
* received dDai - this value is returned from the `getAndExpectedDai` view function
* on the trade helper.
* @return The amount of dDai received.
*/
function tradeUSDCForDDai(
uint256 usdcAmount,
uint256 quotedDaiEquivalentAmount
) external onlyOwnerOr(Role.ADJUSTER) returns (uint256 dDaiMinted) {
dDaiMinted = _TRADE_HELPER.tradeUSDCForDDai(
usdcAmount, quotedDaiEquivalentAmount
);
}
/**
* @notice tradeDDaiForUSDC `daiEquivalentAmount` Dai amount to trade in Dharma Dai
* for USDC. Only the owner or the designated adjuster role may call this function.
* @param daiEquivalentAmount uint256 The Dai equivalent amount to supply in Dharma
* Dai when trading for USDC.
* @param quotedUSDCAmount uint256 The expected USDC received in exchange for
* dDai - this value is returned from the `getExpectedUSDC` view function on the
* trade helper.
* @return The amount of USDC received.
*/
function tradeDDaiForUSDC(
uint256 daiEquivalentAmount,
uint256 quotedUSDCAmount
) external onlyOwnerOr(Role.ADJUSTER) returns (uint256 usdcReceived) {
usdcReceived = _TRADE_HELPER.tradeDDaiForUSDC(
daiEquivalentAmount, quotedUSDCAmount
);
}
/**
* @notice Transfer `usdcAmount` USDC for to the current primary recipient set by the
* owner. Only the owner or the designated withdrawal manager role may call this function.
* @param usdcAmount uint256 The amount of USDC to transfer to the primary recipient.
*/
function withdrawUSDCToPrimaryRecipient(
uint256 usdcAmount
) external onlyOwnerOr(Role.WITHDRAWAL_MANAGER) {
// Get the current primary recipient.
address primaryRecipient = _primaryRecipient;
require(
primaryRecipient != address(0), "No primary recipient currently set."
);
// Transfer the supplied USDC amount to the primary recipient.
bool ok = _USDC.transfer(primaryRecipient, usdcAmount);
require(ok, "USDC transfer failed.");
}
/**
* @notice Transfer `usdcAmount` USDC to `recipient`. Only the owner may call
* this function.
* @param recipient address The account to transfer USDC to.
* @param usdcAmount uint256 The amount of USDC to transfer.
*/
function withdrawUSDC(
address recipient, uint256 usdcAmount
) external onlyOwner {
// Transfer the USDC to the specified recipient.
require(_USDC.transfer(recipient, usdcAmount), "USDC transfer failed.");
}
/**
* @notice Transfer `daiAmount` Dai to `recipient`. Only the owner may call
* this function.
* @param recipient address The account to transfer Dai to.
* @param daiAmount uint256 The amount of Dai to transfer.
*/
function withdrawDai(
address recipient, uint256 daiAmount
) external onlyOwner {
// Transfer the Dai to the specified recipient.
require(_DAI.transfer(recipient, daiAmount), "Dai transfer failed.");
}
/**
* @notice Transfer `dDaiAmount` Dharma Dai to `recipient`. Only the owner may
* call this function.
* @param recipient address The account to transfer Dharma Dai to.
* @param dDaiAmount uint256 The amount of Dharma Dai to transfer.
*/
function withdrawDharmaDai(
address recipient, uint256 dDaiAmount
) external onlyOwner {
// Transfer the dDai to the specified recipient.
require(_DDAI.transfer(recipient, dDaiAmount), "dDai transfer failed.");
}
/**
* @notice Transfer `amount` of ERC20 token `token` to `recipient`. Only the
* owner may call this function.
* @param token ERC20Interface The ERC20 token to transfer.
* @param recipient address The account to transfer the tokens to.
* @param amount uint256 The amount of tokens to transfer.
* @return A boolean to indicate if the transfer was successful - note that
* unsuccessful ERC20 transfers will usually revert.
*/
function withdraw(
ERC20Interface token, address recipient, uint256 amount
) external onlyOwner returns (bool success) {
// Transfer the token to the specified recipient.
success = token.transfer(recipient, amount);
}
/**
* @notice Call account `target`, supplying value `amount` and data `data`.
* Only the owner may call this function.
* @param target address The account to call.
* @param amount uint256 The amount of ether to include as an endowment.
* @param data bytes The data to include along with the call.
* @return A boolean to indicate if the call was successful, as well as the
* returned data or revert reason.
*/
function call(
address payable target, uint256 amount, bytes calldata data
) external onlyOwner returns (bool ok, bytes memory returnData) {
// Call the specified target and supply the specified data.
(ok, returnData) = target.call.value(amount)(data);
}
/**
* @notice Set `daiAmount` as the new limit on the size of finalized deposits.
* Only the owner may call this function.
* @param daiAmount uint256 The new limit on the size of finalized deposits.
*/
function setLimit(uint256 daiAmount) external onlyOwner {
// Set the new limit.
_limit = daiAmount;
}
/**
* @notice Set `recipient` as the new primary recipient for USDC withdrawals.
* Only the owner may call this function.
* @param recipient address The new primary recipient.
*/
function setPrimaryRecipient(address recipient) external onlyOwner {
// Set the new primary recipient.
_primaryRecipient = recipient;
}
/**
* @notice Pause a currently unpaused role and emit a `RolePaused` event. Only
* the owner or the designated pauser may call this function. Also, bear in
* mind that only the owner may unpause a role once paused.
* @param role The role to pause. Permitted roles are deposit manager (0),
* adjuster (1), and pauser (2).
*/
function pause(Role role) external onlyOwnerOr(Role.PAUSER) {
RoleStatus storage storedRoleStatus = _roles[uint256(role)];
require(!storedRoleStatus.paused, "Role in question is already paused.");
storedRoleStatus.paused = true;
emit RolePaused(role);
}
/**
* @notice Unpause a currently paused role and emit a `RoleUnpaused` event.
* Only the owner may call this function.
* @param role The role to pause. Permitted roles are deposit manager (0),
* adjuster (1), and pauser (2).
*/
function unpause(Role role) external onlyOwner {
RoleStatus storage storedRoleStatus = _roles[uint256(role)];
require(storedRoleStatus.paused, "Role in question is already unpaused.");
storedRoleStatus.paused = false;
emit RoleUnpaused(role);
}
/**
* @notice Set a new account on a given role and emit a `RoleModified` event
* if the role holder has changed. Only the owner may call this function.
* @param role The role that the account will be set for. Permitted roles are
* deposit manager (0), adjuster (1), and pauser (2).
* @param account The account to set as the designated role bearer.
*/
function setRole(Role role, address account) external onlyOwner {
require(account != address(0), "Must supply an account.");
_setRole(role, account);
}
/**
* @notice Remove any current role bearer for a given role and emit a
* `RoleModified` event if a role holder was previously set. Only the owner
* may call this function.
* @param role The role that the account will be removed from. Permitted roles
* are deposit manager (0), adjuster (1), and pauser (2).
*/
function removeRole(Role role) external onlyOwner {
_setRole(role, address(0));
}
/**
* @notice External view function to check whether or not the functionality
* associated with a given role is currently paused or not. The owner or the
* pauser may pause any given role (including the pauser itself), but only the
* owner may unpause functionality. Additionally, the owner may call paused
* functions directly.
* @param role The role to check the pause status on. Permitted roles are
* deposit manager (0), adjuster (1), and pauser (2).
* @return A boolean to indicate if the functionality associated with the role
* in question is currently paused.
*/
function isPaused(Role role) external view returns (bool paused) {
paused = _isPaused(role);
}
/**
* @notice External view function to check whether the caller is the current
* role holder.
* @param role The role to check for. Permitted roles are deposit manager (0),
* adjuster (1), and pauser (2).
* @return A boolean indicating if the caller has the specified role.
*/
function isRole(Role role) external view returns (bool hasRole) {
hasRole = _isRole(role);
}
/**
* @notice External view function to check whether a "proof" that a given
* smart wallet is actually a Dharma Smart Wallet, based on the initial user
* signing key, is valid or not. This proof only works when the Dharma Smart
* Wallet in question is derived using V1 of the Dharma Smart Wallet Factory.
* @param smartWallet address The smart wallet to check.
* @param initialUserSigningKey address The initial user signing key supplied
* when deriving the smart wallet address - this could be an EOA or a Dharma
* key ring address.
* @return A boolean indicating if the specified smart wallet account is
* indeed a smart wallet based on the specified initial user signing key.
*/
function isDharmaSmartWallet(
address smartWallet, address initialUserSigningKey
) external view returns (bool dharmaSmartWallet) {
dharmaSmartWallet = _isSmartWallet(smartWallet, initialUserSigningKey);
}
/**
* @notice External view function to check the account currently holding the
* deposit manager role. The deposit manager can process standard deposit
* finalization via `finalizeDaiDeposit` and `finalizeDharmaDaiDeposit`, but
* must prove that the recipient is a Dharma Smart Wallet and adhere to the
* current deposit size limit.
* @return The address of the current deposit manager, or the null address if
* none is set.
*/
function getDepositManager() external view returns (address depositManager) {
depositManager = _roles[uint256(Role.DEPOSIT_MANAGER)].account;
}
/**
* @notice External view function to check the account currently holding the
* adjuster role. The adjuster can exchange Dai in reserves for Dharma Dai and
* vice-versa via minting or redeeming.
* @return The address of the current adjuster, or the null address if none is
* set.
*/
function getAdjuster() external view returns (address adjuster) {
adjuster = _roles[uint256(Role.ADJUSTER)].account;
}
/**
* @notice External view function to check the account currently holding the
* withdrawal manager role. The withdrawal manager can transfer USDC to the
* "primary recipient" address set by the owner.
* @return The address of the current withdrawal manager, or the null address
* if none is set.
*/
function getWithdrawalManager() external view returns (address withdrawalManager) {
withdrawalManager = _roles[uint256(Role.WITHDRAWAL_MANAGER)].account;
}
/**
* @notice External view function to check the account currently holding the
* pauser role. The pauser can pause any role from taking its standard action,
* though the owner will still be able to call the associated function in the
* interim and is the only entity able to unpause the given role once paused.
* @return The address of the current pauser, or the null address if none is
* set.
*/
function getPauser() external view returns (address pauser) {
pauser = _roles[uint256(Role.PAUSER)].account;
}
/**
* @notice External view function to check the current reserves held by this
* contract.
* @return The Dai and Dharma Dai reserves held by this contract, as well as
* the Dai-equivalent value of the Dharma Dai reserves.
*/
function getReserves() external view returns (
uint256 dai, uint256 dDai, uint256 dDaiUnderlying
) {
dai = _DAI.balanceOf(address(this));
dDai = _DDAI.balanceOf(address(this));
dDaiUnderlying = _DDAI.balanceOfUnderlying(address(this));
}
/**
* @notice External view function to check the current limit on deposit amount
* enforced for the deposit manager when finalizing deposits, expressed in Dai
* and in Dharma Dai.
* @return The Dai and Dharma Dai limit on deposit finalization amount.
*/
function getLimit() external view returns (
uint256 daiAmount, uint256 dDaiAmount
) {
daiAmount = _limit;
dDaiAmount = (daiAmount.mul(1e18)).div(_DDAI.exchangeRateCurrent());
}
/**
* @notice External view function to check the address of the current
* primary recipient.
* @return The primary recipient.
*/
function getPrimaryRecipient() external view returns (
address recipient
) {
recipient = _primaryRecipient;
}
/**
* @notice Internal function to set a new account on a given role and emit a
* `RoleModified` event if the role holder has changed.
* @param role The role that the account will be set for. Permitted roles are
* deposit manager (0), adjuster (1), and pauser (2).
* @param account The account to set as the designated role bearer.
*/
function _setRole(Role role, address account) internal {
RoleStatus storage storedRoleStatus = _roles[uint256(role)];
if (account != storedRoleStatus.account) {
storedRoleStatus.account = account;
emit RoleModified(role, account);
}
}
/**
* @notice Internal view function to check whether the caller is the current
* role holder.
* @param role The role to check for. Permitted roles are deposit manager (0),
* adjuster (1), and pauser (2).
* @return A boolean indicating if the caller has the specified role.
*/
function _isRole(Role role) internal view returns (bool hasRole) {
hasRole = msg.sender == _roles[uint256(role)].account;
}
/**
* @notice Internal view function to check whether the given role is paused or
* not.
* @param role The role to check for. Permitted roles are deposit manager (0),
* adjuster (1), and pauser (2).
* @return A boolean indicating if the specified role is paused or not.
*/
function _isPaused(Role role) internal view returns (bool paused) {
paused = _roles[uint256(role)].paused;
}
/**
* @notice Internal view function to enforce that the given initial user signing
* key resolves to the given smart wallet when deployed through the Dharma Smart
* Wallet Factory V1.
* @param smartWallet address The smart wallet.
* @param initialUserSigningKey address The initial user signing key.
*/
function _isSmartWallet(
address smartWallet, address initialUserSigningKey
) internal pure returns (bool) {
// Derive the keccak256 hash of the smart wallet initialization code.
bytes32 initCodeHash = keccak256(
abi.encodePacked(
_WALLET_CREATION_CODE_HEADER,
initialUserSigningKey,
_WALLET_CREATION_CODE_FOOTER
)
);
// Attempt to derive a smart wallet address that matches the one provided.
address target;
for (uint256 nonce = 0; nonce < 10; nonce++) {
target = address( // derive the target deployment address.
uint160( // downcast to match the address type.
uint256( // cast to uint to truncate upper digits.
keccak256( // compute CREATE2 hash using all inputs.
abi.encodePacked( // pack all inputs to the hash together.
_CREATE2_HEADER, // pass in control character + factory address.
nonce, // pass in current nonce as the salt.
initCodeHash // pass in hash of contract creation code.
)
)
)
)
);
// Exit early if the provided smart wallet matches derived target address.
if (target == smartWallet) {
return true;
}
// Otherwise, increment the nonce and derive a new salt.
nonce++;
}
// Explicity recognize no target was found matching provided smart wallet.
return false;
}
/**
* @notice Modifier that throws if called by any account other than the owner
* or the supplied role, or if the caller is not the owner and the role in
* question is paused.
* @param role The role to require unless the caller is the owner. Permitted
* roles are deposit manager (0), adjuster (1), and pauser (2).
*/
modifier onlyOwnerOr(Role role) {
if (!isOwner()) {
require(_isRole(role), "Caller does not have a required role.");
require(!_isPaused(role), "Role in question is currently paused.");
}
_;
}
} | [{"defect": "Uninitialized_storage", "type": "Code_specification", "severity": "Low", "lines": ["580", "746", "567"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["211", "218", "186", "173", "194"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["375"]}] | [{"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"DharmaReserveManagerV3.sol": [1]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"DharmaReserveManagerV3.sol": [536]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"DharmaReserveManagerV3.sol": [546]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"DharmaReserveManagerV3.sol": [556]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"DharmaReserveManagerV3.sol": [536]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"DharmaReserveManagerV3.sol": [291]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"DharmaReserveManagerV3.sol": [277, 278, 279]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"DharmaReserveManagerV3.sol": [292, 293, 294]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"DharmaReserveManagerV3.sol": [288, 286, 287]}}] | [{"error": "Callstack Depth Attack Vulnerability.", "line": 536, "level": "Warning"}] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 270, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 274, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 278, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 282, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 161, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 163, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 260, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 263, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 266, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 257, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 87, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 91, "severity": 1}, {"rule": "SOLIDITY_TX_ORIGIN", "line": 169, "severity": 2}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 536, "severity": 3}, {"rule": "SOLIDITY_VISIBILITY", "line": 55, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 532, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 56, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 56, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 56, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 57, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 57, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 533, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 533, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 533, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 534, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 534, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 536, "severity": 1}] | [{"constant":true,"inputs":[],"name":"getReserves","outputs":[{"internalType":"uint256","name":"dai","type":"uint256"},{"internalType":"uint256","name":"dDai","type":"uint256"},{"internalType":"uint256","name":"dDaiUnderlying","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getPrimaryRecipient","outputs":[{"internalType":"address","name":"recipient","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"cancelOwnershipTransfer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"daiAmount","type":"uint256"}],"name":"setLimit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"enum DharmaReserveManagerV3Interface.Role","name":"role","type":"uint8"}],"name":"unpause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getDepositManager","outputs":[{"internalType":"address","name":"depositManager","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"smartWallet","type":"address"},{"internalType":"address","name":"initialUserSigningKey","type":"address"},{"internalType":"uint256","name":"daiAmount","type":"uint256"}],"name":"finalizeDaiDeposit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"usdcAmount","type":"uint256"}],"name":"withdrawUSDC","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"recipient","type":"address"}],"name":"setPrimaryRecipient","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"daiAmount","type":"uint256"}],"name":"withdrawDai","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"usdcAmount","type":"uint256"},{"internalType":"uint256","name":"quotedDaiEquivalentAmount","type":"uint256"}],"name":"tradeUSDCForDDai","outputs":[{"internalType":"uint256","name":"dDaiMinted","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"smartWallet","type":"address"},{"internalType":"address","name":"initialUserSigningKey","type":"address"}],"name":"isDharmaSmartWallet","outputs":[{"internalType":"bool","name":"dharmaSmartWallet","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address payable","name":"target","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"call","outputs":[{"internalType":"bool","name":"ok","type":"bool"},{"internalType":"bytes","name":"returnData","type":"bytes"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getPauser","outputs":[{"internalType":"address","name":"pauser","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getAdjuster","outputs":[{"internalType":"address","name":"adjuster","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"daiAmount","type":"uint256"}],"name":"mint","outputs":[{"internalType":"uint256","name":"dDaiMinted","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"dDaiAmount","type":"uint256"}],"name":"withdrawDharmaDai","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getLimit","outputs":[{"internalType":"uint256","name":"daiAmount","type":"uint256"},{"internalType":"uint256","name":"dDaiAmount","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"enum DharmaReserveManagerV3Interface.Role","name":"role","type":"uint8"}],"name":"isRole","outputs":[{"internalType":"bool","name":"hasRole","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"enum DharmaReserveManagerV3Interface.Role","name":"role","type":"uint8"}],"name":"isPaused","outputs":[{"internalType":"bool","name":"paused","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getWithdrawalManager","outputs":[{"internalType":"address","name":"withdrawalManager","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"usdcAmount","type":"uint256"}],"name":"withdrawUSDCToPrimaryRecipient","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"smartWallet","type":"address"},{"internalType":"address","name":"initialUserSigningKey","type":"address"},{"internalType":"uint256","name":"dDaiAmount","type":"uint256"}],"name":"finalizeDharmaDaiDeposit","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"daiEquivalentAmount","type":"uint256"},{"internalType":"uint256","name":"quotedUSDCAmount","type":"uint256"}],"name":"tradeDDaiForUSDC","outputs":[{"internalType":"uint256","name":"usdcReceived","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"contract ERC20Interface","name":"token","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"enum DharmaReserveManagerV3Interface.Role","name":"role","type":"uint8"}],"name":"removeRole","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"dDaiAmount","type":"uint256"}],"name":"redeem","outputs":[{"internalType":"uint256","name":"daiReceived","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"enum DharmaReserveManagerV3Interface.Role","name":"role","type":"uint8"}],"name":"pause","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"enum DharmaReserveManagerV3Interface.Role","name":"role","type":"uint8"},{"internalType":"address","name":"account","type":"address"}],"name":"setRole","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"enum DharmaReserveManagerV3Interface.Role","name":"role","type":"uint8"},{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"RoleModified","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"enum DharmaReserveManagerV3Interface.Role","name":"role","type":"uint8"}],"name":"RolePaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"enum DharmaReserveManagerV3Interface.Role","name":"role","type":"uint8"}],"name":"RoleUnpaused","type":"event"}] | v0.5.11+commit.c082d0b4 | true | 200 | Default | MIT | false | bzzr://ea2173fd9ed14872d519dd9151dd9afcd3fb1b8ae8b2b26672d5387930f8fca5 |
|||
HarvestAP | 0xab662863ce609f4cf32601601ba64653e04c5917 | Solidity | // File: @openzeppelin/contracts/GSN/Context.sol
pragma solidity >=0.6.0 <0.8.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with GSN meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
// File: @openzeppelin/contracts/token/ERC20/IERC20.sol
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// File: @openzeppelin/contracts/math/SafeMath.sol
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
// File: @openzeppelin/contracts/token/ERC20/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 returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5,05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is
* called.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view returns (uint8) {
return _decimals;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
/**
* @dev Moves tokens `amount` from `sender` to `recipient`.
*
* This is internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(address sender, address recipient, uint256 amount) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `to` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance");
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(address owner, address spender, uint256 amount) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Sets {decimals} to a value other than the default one of 18.
*
* WARNING: This function should only be called from the constructor. Most
* applications that interact with token contracts will not expect
* {decimals} to ever change, and may work incorrectly if it does.
*/
function _setupDecimals(uint8 decimals_) internal {
_decimals = decimals_;
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be to transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { }
}
// File: @openzeppelin/contracts/access/Ownable.sol
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
// File: contracts/HarvestAP.sol
pragma solidity ^0.7.3;
interface APRedemptionI {
function sweep() external returns (uint256);
function redeem(uint256 toRedeem_) external returns (uint256);
function redeemTo(uint256 toRedeem_, address recipient_) external returns (uint256);
}
/// Should be deployed by the harvest AP.
contract APRedemption is APRedemptionI {
using SafeMath for uint256;
// we know FARM is correctly implemented, so no need for SafeERC20
IERC20 immutable public farm;
HarvestAP public ap;
// Arg is the address of the FARM token to be distributed
// - Future versions must set AP in the constructor
constructor(address farm_) {
farm = IERC20(farm_);
ap = HarvestAP(msg.sender);
}
function farmBalance() internal view returns (uint256) {
return farm.balanceOf(address(this));
}
// Can be used to preflight redemption amount
function calcRedemption(uint256 toRedeem) public view returns (uint256) {
return toRedeem.mul(farmBalance()).div(ap.totalSupply());
}
// redeem tokens and transfer farm to recipient
function redeemTo(uint256 toRedeem_, address recipient_) public override returns (uint256) {
// this calculation must be done before redeeming
uint256 farmAmnt_ = calcRedemption(toRedeem_);
// redemption balance is enforced in the HarvestAP logic.
// No need for additional checks here
ap.redeem(msg.sender, toRedeem_);
farm.transfer(recipient_, farmAmnt_);
}
// shortcut for redeem to self
function redeem(uint256 toRedeem_) external override returns (uint256) {
return redeemTo(toRedeem_, msg.sender);
}
// Allow the AP to sweep farm from the redemption contract
function sweep() external override returns (uint256) {
require(msg.sender == address(ap), "APRedemption/sweep - only AP Token may call");
farm.transfer(address(ap), farmBalance());
}
}
contract HarvestAP is ERC20, Ownable {
APRedemptionI public redemption;
IERC20 immutable public farm;
// Arguments are:
// owner_ - who can mint
// farm_ - the FARM token that is distributed by the redemption
constructor (address owner_, address farm_)
ERC20("Harvest Action Points", "AP")
Ownable()
{
transferOwnership(owner_);
farm = IERC20(farm_);
redemption = APRedemptionI(new APRedemption(farm_));
}
// In case we ever want to change redemption logic
function setRedemption(address redemption_) external onlyOwner {
// sweep farm tokens to new address
redemption.sweep();
farm.transfer(redemption_, farm.balanceOf(address(this)));
// set new address
redemption = APRedemptionI(redemption_);
}
// Make new AP
function mint(address account_, uint256 amount_) external onlyOwner {
_mint(account_, amount_);
}
// Redeem function simply burns tokens.
// It is gated to the redemption contract.
// We do this so we can skip `approve` steps during redemption
function redeem(address account_, uint256 amount_) external {
require(
msg.sender == address(redemption),
"HarvestAP/redeem - This function may only be called by APRedemption"
);
require(balanceOf(account_) >= amount_, "HarvestAP/redeem - Insufficient balance");
_burn(account_, amount_);
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["721", "685"]}, {"defect": "Transaction_order_dependency", "type": "Business_logic", "severity": "Medium", "lines": ["696"]}, {"defect": "Missing_return_statement", "type": "Code_specification", "severity": "Low", "lines": ["678", "694"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["601", "616", "628"]}] | [{"check": "pragma", "impact": "Informational", "confidence": "High", "lines": {"HarvestAP.sol": [641]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"HarvestAP.sol": [259, 260, 261, 262]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"HarvestAP.sol": [552, 550, 551]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"HarvestAP.sol": [20, 21, 22, 23]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"HarvestAP.sol": [243, 244, 245]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HarvestAP.sol": [416, 417, 418, 419, 415]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HarvestAP.sol": [624, 625, 626, 623]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HarvestAP.sol": [352, 353, 354]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HarvestAP.sol": [452, 453, 454, 455]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HarvestAP.sol": [336, 337, 335]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HarvestAP.sol": [378, 379, 380, 381]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HarvestAP.sol": [604, 605, 606]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HarvestAP.sol": [433, 434, 435, 436]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HarvestAP.sol": [328, 329, 327]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HarvestAP.sol": [360, 361, 359]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HarvestAP.sol": [400, 397, 398, 399]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"HarvestAP.sol": [386, 387, 388]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"HarvestAP.sol": [28]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"HarvestAP.sol": [573]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"HarvestAP.sol": [641]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"HarvestAP.sol": [267]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"HarvestAP.sol": [3]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"HarvestAP.sol": [107]}}, {"check": "redundant-statements", "impact": "Informational", "confidence": "High", "lines": {"HarvestAP.sol": [15, 16, 17, 18, 19, 20, 21, 22, 23, 24]}}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium", "lines": {"HarvestAP.sol": [724]}}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium", "lines": {"HarvestAP.sol": [721]}}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium", "lines": {"HarvestAP.sol": [696]}}, {"check": "unchecked-transfer", "impact": "High", "confidence": "Medium", "lines": {"HarvestAP.sol": [685]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"HarvestAP.sol": [720]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 494, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 515, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 625, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 397, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 28, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 28, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 107, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 107, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 267, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 267, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 573, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 573, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 641, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 299, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 301, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 303, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 305, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 306, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 307, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 588, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 297, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 655, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 658, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 658, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 659, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 663, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 665, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 665, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 703, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 703, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 708, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 708, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 709, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 709, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 710, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 712, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 714, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 714, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 714, "severity": 1}] | [{"inputs":[{"internalType":"address","name":"owner_","type":"address"},{"internalType":"address","name":"farm_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"farm","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"redemption","outputs":[{"internalType":"contract APRedemptionI","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"redemption_","type":"address"}],"name":"setRedemption","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}] | v0.7.3+commit.9bfce1f6 | true | 150 | 000000000000000000000000f00dd244228f51547f0563e60bca65a30fbf5f7f000000000000000000000000a0246c9032bc3a600820415ae600c6388619a14d | Default | MIT | false | ipfs://a77e72028d1ac13f5f70da8cc813a90a1deb51afffde0b44deb47dbe078ba74d |
||
VIVO | 0x5199ac365c4d81a3f33b2eb268c7ca982fc7c6f4 | Solidity | // File: contracts/VIVO.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/// @title: Vivo: My eye and around.
/// @author: manifold.xyz
import "./ERC721Creator.sol";
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// //
// [size=9px][font=monospace] "φ "", ░ ≥╔φσ, , ,╓░░φ░;░╠░░"Γ «φ╚φ▒░ φφφφφ░«╠φ░ //
// ░ ]░' ≈"-,«=φ░ ⁿ ░░░░ⁿ╙╚░^╚░░░░░░≥, '«╠φ╩░,φ╚░φ╠░░╠▒φ //
// " "", """ `« ,"╙ ,φφφφφ░░ⁿ╔ε»²░"≈≥╚φ░░╔φφ░░░"╔╠φ //
// `≥≥,╚, " «" `.φ╠╢╣╬╣╣╣▓▓▓╣▒░φ"▒,""░^"░░≥«╙╚5░░≈ //
// `ⁿ [░ⁿ≥, . ' "╙╚╫▒╚╚╠╬╠╬╝╠╚▒╠φ░░, ,≥»"`░,╓φ░░δφ //
// ░╠░φ≥░≥=` - -αφ, , -.φ░≥╙╚╚╙= -,╓φ░╙╠φ▒╣φ░, ░░░"[;╙╙φ░ //
// ⁿ -φ╚░",ⁿ`= , "`╓ " ░=" ╔φ "φδ░╠░ φ╙▒"'. ░ε░ ░└.φφ░ //
// «░ ," ] [ `ε ░╓░░╔╣▒╠σ,σ#▒╣▒░░-~⌐ ,╓ ⁿ>≥ "░ //
// ,φ░░ -∩ " ,φ░φ░ " ` 7 ░╙╙≤╚╠║▒╚╠╩╬╠╠╙▐▒φ",«╔╚ε ≤,"` ". //
// -φ≥░` .,ⁿ» =δ@╙#ε╙" ` " ; «φ "^╚φ"≈╙"`░7φε "⌐» ` `- //
// ░≈═,, ⁿ╓#≈@▒░.▄-]║▒ ' = , ,"',`░φ╚, "░ ]' //
// ░╙╝╚▒#φ╬▒▄,,,░╚φ░╠▒╠╬Q,, "≥░φ≈╠╠╠▒╩╚"φ╠φµ «φ . , //
// ▒╚ ▒é~.,..,, '"¡╙▒░Σ╚φφ≈▒>- ` "░ⁿ╙╚╚╙",░≥╚║╣▒╚╚▒▒▄▓Æ» ⁿ= //
// ░░ .-""-≤φφ╠▒▒▓▒▒φ║║░"≥%.░ "φ\ ,σφ░╬╚ -░5░░╚╬╣▒ ╣╣╩░░░╚╚▒φ╔ `-ⁿ //
// ▐ ''[«"░╠╠╠╠╠╣╣▓╣▒▒░]░▐▐ ▐φ1 ,≥"╙╙╠░ ≥«».«σ╝╩╔▓╠░░""░φ░╠╠╠▒α"░ //
// ╠ ░░φ╠φ╠╠╠║╣╩╩╝╬╬⌐,`]╚ ]╚εε .░ⁿ φ░ ░░φφ╓╔░╔╣╬▒ ".░░░░╚╠╠╬▒ ; //
// ▒ !░░╚╠╠╬╠░╩╩╚φ╣▒δ ▐ ░╠] »"" ╠░╩▒▄ ]╠░░░ⁿ╔╣╣▒φ, ░░░░░╠╠╠╠ //
// ⌐ ╓Qµ░░╚╠╠╣╣▓▓▓▓╩╬Θ ░ ░║░ε ⁿ φ╠░░░░╚░ " """"@╠╠╩ ╙╙≥ '"░]╠░╠╠╠⌐` //
// ▒φε╙░░░░╚╠╠╠╠╠╬▒▒╣▒φ▄░░ ▒╚▒╚ ',░ ╔░░ ░╦╓µ▄▄▄Q╓,╔╠╠╠╚⌐ "≥"-░░╠╠╩ //
// φ≤«φε└╩╢φφ░░░░░╚╚╚╠╠▒╓░║▒╙▀▒ ▒φ▌▐░░░░. φ░░░░ⁿ░╚╚╚╙╙╠╩╚╚╠╣╣▒░ε ., ╚╠φ▒░╚░╙ //
// ╣╣╣╬▓╗εⁿ░░░░░░░░░░░░░░╔▓▓▓▒║' ≥░║░▒░░░'.φ╩φ░╙»≤╚▒▒▒@@╗▄╓╓╔φ▒░╚╚φ,░- «╠╠╠╠▒φ░ε " //
// ╚║▒φφε╓,'░░=≥░░░░░░φφ▓█▓█▓▓▒░~`Γ`║▒ε"`╓#╠╠╠╩░"╔░╙╙╚≥░╙░╙╙╚╝╝╣▒░╚φ╠⌂ ░≈░╙╢╬╠▒ε ░ //
// ╬╫▓▓▓▓▒║▒▒▄▄░░░ⁿ";╔╣╣▓███╬▓▓░ -╡'╠▒╞φ╠╠╚╚╚≥=` ╚░░φφ░==»╓,,,,'"░░╚╙░`.░]░╚╠╩╠╠φ [ //
// ░╬╣▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█▓███▒╠╣╣▓▓╗▓φ╠╠╠╠░░░░░ ░░░φ░"""`=└╙╙╙= `«░╚╔ :░»░░╓╔╠╠░ ⁿ //
// :░╚╚░╚╣▓▓▓▓▓▓▓▓▓▓▄╠▒╬╠╣▓▒░░╚╚╠╠╬░░╚░░░░░ -φδ╠▒░φ░░░░ⁿ≤░░░░ -»"≥░░≥░'"░░φ╚╚╠⌐, //
// [/font][/size] //
// //
// //
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
contract VIVO is ERC721Creator {
constructor() ERC721Creator("Vivo: My eye and around.", "VIVO") {}
}
// File: contracts/ERC721Creator.sol
// 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;
}
}
// File: @openzeppelin/contracts/proxy/Proxy.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/Proxy.sol)
pragma solidity ^0.8.0;
/**
* @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM
* instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to
* be specified by overriding the virtual {_implementation} function.
*
* Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a
* different contract through the {_delegate} function.
*
* The success and return data of the delegated call will be returned back to the caller of the proxy.
*/
abstract contract Proxy {
/**
* @dev Delegates the current call to `implementation`.
*
* This function does not return to its internall call site, it will return directly to the external caller.
*/
function _delegate(address implementation) internal virtual {
assembly {
// Copy msg.data. We take full control of memory in this inline assembly
// block because it will not return to Solidity code. We overwrite the
// Solidity scratch pad at memory position 0.
calldatacopy(0, 0, calldatasize())
// Call the implementation.
// out and outsize are 0 because we don't know the size yet.
let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)
// Copy the returned data.
returndatacopy(0, 0, returndatasize())
switch result
// delegatecall returns 0 on error.
case 0 {
revert(0, returndatasize())
}
default {
return(0, returndatasize())
}
}
}
/**
* @dev This is a virtual function that should be overriden so it returns the address to which the fallback function
* and {_fallback} should delegate.
*/
function _implementation() internal view virtual returns (address);
/**
* @dev Delegates the current call to the address returned by `_implementation()`.
*
* This function does not return to its internall call site, it will return directly to the external caller.
*/
function _fallback() internal virtual {
_beforeFallback();
_delegate(_implementation());
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other
* function in the contract matches the call data.
*/
fallback() external payable virtual {
_fallback();
}
/**
* @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data
* is empty.
*/
receive() external payable virtual {
_fallback();
}
/**
* @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`
* call, or as part of the Solidity `fallback` or `receive` functions.
*
* If overriden should call `super._beforeFallback()`.
*/
function _beforeFallback() internal virtual {}
}
// File: @openzeppelin/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts/utils/StorageSlot.sol
// 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
}
}
}
| [{"defect": "DelegateCall", "type": "Function_call", "severity": "High", "lines": ["379"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [64, 62, 63]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [72, 73, 71]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [80, 81, 82]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [53, 54, 55]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [79, 80, 81, 82, 83]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [64, 65, 61, 62, 63]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [70, 71, 72, 73, 74]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [52, 53, 54, 55, 56]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/StorageSlot.sol": [4]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 72, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 74, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 467, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 476, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 485, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 494, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 8, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 60, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 106, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 197, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 419, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 467, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 476, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 485, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 494, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 220, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 125, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 468, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 477, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 486, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 495, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 50, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 70, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 248, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 169, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 170, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 170, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 248, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 248, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 249, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 249, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 249, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 249, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 251, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 251, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 251, "severity": 1}] | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}] | v0.8.7+commit.e28d00a7 | true | 300 | Default | true | 0xe4e4003afe3765aca8149a82fc064c0b125b9e5a | ||||
Chainema | 0xfb5c1935f419227a283b9f9f551530fd8053126a | Solidity | pragma solidity ^0.4.18;
// ----------------------------------------------------------------------------
// 'Chainema' token contract
//
// Deployed to : 0x7c8Dca263Ca1A7DBFDf29E063dFA0D59c1C50DfF
// Symbol : CNM
// Name : Chainema
// Total supply: 1000000000
// 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 Chainema 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 Chainema() public {
symbol = "CNM";
name = "Chainema";
decimals = 18;
_totalSupply = 1000000000000000000000000000;
balances[0x7c8Dca263Ca1A7DBFDf29E063dFA0D59c1C50DfF] = _totalSupply;
Transfer(address(0), 0x7c8Dca263Ca1A7DBFDf29E063dFA0D59c1C50DfF, _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);
}
} | [{"defect": "Frozen_Ether", "type": "Code_specification", "severity": "Medium", "lines": ["102"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["63"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["89", "86"]}] | [{"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Chainema.sol": [64]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Chainema.sol": [46]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Chainema.sol": [50]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Chainema.sol": [51]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Chainema.sol": [47]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Chainema.sol": [89, 90, 91, 92, 93, 94]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Chainema.sol": [201, 202, 203, 204, 205, 206]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Chainema.sol": [212, 213, 214]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Chainema.sol": [34, 35, 36, 37]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Chainema.sol": [88, 86, 87]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Chainema.sol": [49]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Chainema.sol": [48]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Chainema.sol": [220, 221, 222]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"Chainema.sol": [32, 33, 30, 31]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Chainema.sol": [1]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "locked-ether", "impact": "Medium", "confidence": "High", "lines": {"Chainema.sol": [212, 213, 214]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"Chainema.sol": [87]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Chainema.sol": [86]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"Chainema.sol": [106]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"Chainema.sol": [119]}}] | [{"error": "Integer Underflow.", "line": 104, "level": "Warning"}, {"error": "Integer Underflow.", "line": 103, "level": "Warning"}, {"error": "Integer Underflow.", "line": 129, "level": "Warning"}, {"error": "Integer Overflow.", "line": 201, "level": "Warning"}] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 120, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 121, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 93, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 129, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 46, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 47, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 48, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 128, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 136, "severity": 1}, {"rule": "SOLIDITY_DEPRECATED_CONSTRUCTIONS", "line": 191, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 162, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_REDUNDANT_FALLBACK_REJECT", "line": 212, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 212, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 64, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 201, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 108, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 109, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"tokens","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"from","type":"address"},{"name":"to","type":"address"},{"name":"tokens","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"_totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"tokenOwner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeSub","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"name":"to","type":"address"},{"name":"tokens","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeDiv","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"tokens","type":"uint256"},{"name":"data","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeMul","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[],"name":"newOwner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"tokenAddress","type":"address"},{"name":"tokens","type":"uint256"}],"name":"transferAnyERC20Token","outputs":[{"name":"success","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"tokenOwner","type":"address"},{"name":"spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"a","type":"uint256"},{"name":"b","type":"uint256"}],"name":"safeAdd","outputs":[{"name":"c","type":"uint256"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"tokens","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"tokenOwner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"tokens","type":"uint256"}],"name":"Approval","type":"event"}] | v0.4.18+commit.9cf6e910 | false | 200 | Default | false | bzzr://8bf554d511548f02617a38ce8eb6f0663556fdc0b9ef04df817421362898ce25 |
||||
EthergyBridge | 0x492d1033fdb2eba7aeb79c9547b111e99acfe7a9 | Solidity | // SPDX-License-Identifier: MIT
pragma solidity ^0.6.7;
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);
function burn(address from, uint256 amount) external returns (bool);
}
interface IXDaiBridge {
function relayTokens(address _receiver, uint256 _amount) external;
}
interface IOmniBridge {
function relayTokens(address token, address _receiver, uint256 _value) external;
}
interface IWETH9 {
function deposit() external payable;
}
contract EthergyBridge{
address public xdaiBridge = 0x4aa42145Aa6Ebf72e164C9bBC74fbD3788045016;
address public omniBridge = 0x88ad09518695c6c3712AC10a214bE5109a655671;
address public dai = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
address public weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address public dao; // target address on xDai net - should be minion address
event BridgeXDai(address target, uint amount);
event BridgeWETH(address target, uint amount);
event WrapETH(uint amount);
constructor(address _dao) public
{
dao = _dao;
}
function bridgeXDai() external {
uint256 balance = IERC20(dai).balanceOf(address(this));
require(balance > 0, "No sufficent DAI on the smart contract");
IERC20(dai).approve(xdaiBridge, balance);
IXDaiBridge(xdaiBridge).relayTokens(dao, balance);
emit BridgeXDai(dao, balance);
}
function bridgeWETH() external {
uint256 balance = IERC20(weth).balanceOf(address(this));
require(balance > 0, "No sufficent WETH on the smart contract");
IERC20(weth).approve(omniBridge, balance);
IOmniBridge(omniBridge).relayTokens(weth, dao, balance);
emit BridgeWETH(dao, balance);
}
function wrapEth() external {
uint256 balance = address(this).balance;
require(balance > 0, "No sufficent ETH on the smart contract");
IWETH9(weth).deposit{value: balance}();
emit WrapETH(balance);
}
} | [] | [{"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"EthergyBridge.sol": [41]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"EthergyBridge.sol": [42]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"EthergyBridge.sol": [43]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"EthergyBridge.sol": [44]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"EthergyBridge.sol": [3]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"EthergyBridge.sol": [53]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"EthergyBridge.sol": [79]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"EthergyBridge.sol": [71]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"EthergyBridge.sol": [62]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"EthergyBridge.sol": [59]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"EthergyBridge.sol": [68]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 41, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 42, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 43, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 44, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 3, "severity": 1}] | [{"inputs":[{"internalType":"address","name":"_dao","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"BridgeWETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"BridgeXDai","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WrapETH","type":"event"},{"inputs":[],"name":"bridgeWETH","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"bridgeXDai","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"dai","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"dao","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"omniBridge","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"weth","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"wrapEth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"xdaiBridge","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}] | v0.6.7+commit.b8d736ae | true | 200 | 0000000000000000000000006beb3e6820f724e909a4bed8407a443ca5580cd1 | Default | None | false | ipfs://ad8430999788025406a1b0402d5bf03c11d81ee4d81283be0b387b0d13d91aa7 |
||
Test | 0x59becf2cfb5c38fdb67edf778b07e2bace3bdab2 | Solidity | pragma solidity ^0.5.0;
contract Test {
uint8 constant N = 16;
struct Bet {
uint256 blockNumber;
uint256 amount;
bytes16 bet;
uint128 id;
address payable gambler;
}
struct Payout {
uint256 amount;
bytes32 blockHash;
uint128 id;
address payable gambler;
}
Bet[] betArray;
address payable private owner;
event Result (
uint256 amount,
bytes32 blockHash,
uint128 indexed id,
address payable indexed gambler
);
uint256 constant MIN_BET = 0.01 ether;
uint256 constant MAX_BET = 100 ether;
uint256 constant PRECISION = 1 ether;
constructor() public payable {
owner = msg.sender;
}
function() external payable { }
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function placeBet(bytes16 bet, uint128 id) external payable {
require(msg.value >= MIN_BET, "Bet amount should be greater or equal than minimal amount");
require(msg.value <= MAX_BET, "Bet amount should be lesser or equal than maximal amount");
require(id != 0, "Id should not be 0");
betArray.push(Bet(block.number, msg.value, bet, id, msg.sender));
}
function settleBets() external {
if (betArray.length == 0)
return;
Payout[] memory payouts = new Payout[](betArray.length);
Bet[] memory missedBets = new Bet[](betArray.length);
uint256 totalPayout;
uint i = betArray.length;
do {
i--;
if(betArray[i].blockNumber >= block.number)
missedBets[i] = betArray[i];
else {
bytes32 blockHash = blockhash(betArray[i].blockNumber);
uint256 coefficient = PRECISION;
uint8 markedCount;
uint8 matchesCount;
uint256 divider = 1;
for (uint8 j = 0; j < N; j++) {
if (betArray[i].bet[j] == 0xFF)
continue;
markedCount++;
byte field;
if (j % 2 == 0)
field = blockHash[24 + j / 2] >> 4;
else
field = blockHash[24 + j / 2] & 0x0F;
if (betArray[i].bet[j] < 0x10) {
if (field == betArray[i].bet[j])
matchesCount++;
else
divider *= 15 + N;
continue;
}
if (betArray[i].bet[j] == 0x10) {
if (field > 0x09 && field < 0x10) {
matchesCount++;
divider *= 6;
} else
divider *= 10 + N;
continue;
}
if (betArray[i].bet[j] == 0x11) {
if (field < 0x0A) {
matchesCount++;
divider *= 10;
} else
divider *= 6 + N;
continue;
}
if (betArray[i].bet[j] == 0x12) {
if (field < 0x0A && field & 0x01 == 0x01) {
matchesCount++;
divider *= 5;
} else
divider *= 11 + N;
continue;
}
if (betArray[i].bet[j] == 0x13) {
if (field < 0x0A && field & 0x01 == 0x0) {
matchesCount++;
divider *= 5;
} else
divider *= 11 + N;
continue;
}
}
if (matchesCount == 0)
coefficient = 0;
else {
uint256 missedCount = markedCount - matchesCount;
divider *= missedCount ** missedCount;
coefficient = coefficient * 16**uint256(markedCount) / divider;
}
uint payoutAmount = betArray[i].amount * coefficient / PRECISION;
if (payoutAmount == 0 && matchesCount > 0)
payoutAmount = matchesCount;
payouts[i] = Payout(payoutAmount, blockHash, betArray[i].id, betArray[i].gambler);
totalPayout += payoutAmount;
}
betArray.pop();
} while (i > 0);
i = missedBets.length;
do {
i--;
if (missedBets[i].id != 0)
betArray.push(missedBets[i]);
} while (i > 0);
uint balance = address(this).balance;
for (i = 0; i < payouts.length; i++) {
if (payouts[i].id > 0) {
if (totalPayout > balance)
emit Result(balance * payouts[i].amount * PRECISION / totalPayout / PRECISION, payouts[i].blockHash, payouts[i].id, payouts[i].gambler);
else
emit Result(payouts[i].amount, payouts[i].blockHash, payouts[i].id, payouts[i].gambler);
}
}
for (i = 0; i < payouts.length; i++) {
if (payouts[i].amount > 0) {
if (totalPayout > balance)
payouts[i].gambler.transfer(balance * payouts[i].amount * PRECISION / totalPayout / PRECISION);
else
payouts[i].gambler.transfer(payouts[i].amount);
}
}
}
function withdraw() external onlyOwner {
owner.transfer(address(this).balance);
}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["168"]}] | [{"check": "controlled-array-length", "impact": "High", "confidence": "Medium", "lines": {"Test.sol": [138]}}, {"check": "controlled-array-length", "impact": "High", "confidence": "Medium", "lines": {"Test.sol": [53]}}, {"check": "controlled-array-length", "impact": "High", "confidence": "Medium", "lines": {"Test.sol": [145]}}, {"check": "costly-loop", "impact": "Informational", "confidence": "Medium", "lines": {"Test.sol": [138]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"Test.sol": [132]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"Test.sol": [1]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"Test.sol": [115]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"Test.sol": [133]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"Test.sol": [75]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"Test.sol": [90]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"Test.sol": [114]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"Test.sol": [107]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"Test.sol": [57]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"Test.sol": [98]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"Test.sol": [106]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"Test.sol": [84]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"Test.sol": [160]}}, {"check": "calls-loop", "impact": "Low", "confidence": "Medium", "lines": {"Test.sol": [162]}}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium", "lines": {"Test.sol": [72]}}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium", "lines": {"Test.sol": [62]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 75, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 82, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 83, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 90, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 91, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 91, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 98, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 99, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 106, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 107, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 107, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 107, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 114, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 115, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 115, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 74, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 149, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 157, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 149, "severity": 2}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 157, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 24, "severity": 1}, {"rule": "SOLIDITY_TRANSFER_IN_LOOP", "line": 157, "severity": 2}, {"rule": "SOLIDITY_VISIBILITY", "line": 5, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 22, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 33, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 34, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 35, "severity": 1}] | [{"constant":false,"inputs":[],"name":"withdraw","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"bet","type":"bytes16"},{"name":"id","type":"uint128"}],"name":"placeBet","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[],"name":"settleBets","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":true,"stateMutability":"payable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"blockHash","type":"bytes32"},{"indexed":true,"name":"id","type":"uint128"},{"indexed":true,"name":"gambler","type":"address"}],"name":"Result","type":"event"}] | v0.5.1+commit.c8a2cb62 | true | 200 | Default | false | bzzr://968db9419b02c571c82a28f093ee26e90d4785f094bd5b4b6a2ee7598463a30b |
||||
MintGatewayProxy | 0xed7d080aa1d2a4d468c615a5d481125bb56bf1bf | Solidity | /**
Deployed by Ren Project, https://renproject.io
Commit hash: 1e106b3
Repository: https://github.com/renproject/gateway-sol
Issues: https://github.com/renproject/gateway-sol/issues
Licenses
@openzeppelin/contracts: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/LICENSE
gateway-sol: https://github.com/renproject/gateway-sol/blob/master/LICENSE
*/
pragma solidity ^0.5.16;
contract Initializable {
bool private initialized;
bool private initializing;
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;
}
}
function isConstructor() private view returns (bool) {
address self = address(this);
uint256 cs;
assembly { cs := extcodesize(self) }
return cs == 0;
}
uint256[50] private ______gap;
}
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
library ECDSA {
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
if (signature.length != 65) {
revert("ECDSA: signature length is invalid");
}
bytes32 r;
bytes32 s;
uint8 v;
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
revert("ECDSA: signature.s is in the wrong range");
}
if (v != 27 && v != 28) {
revert("ECDSA: signature.v is in the wrong range");
}
return ecrecover(hash, v, r, s);
}
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
}
contract Proxy {
function () payable external {
_fallback();
}
function _implementation() internal view returns (address);
function _delegate(address implementation) internal {
assembly {
calldatacopy(0, 0, calldatasize)
let result := delegatecall(gas, implementation, 0, calldatasize, 0, 0)
returndatacopy(0, 0, returndatasize)
switch result
case 0 { revert(0, returndatasize) }
default { return(0, returndatasize) }
}
}
function _willFallback() internal {
}
function _fallback() internal {
_willFallback();
_delegate(_implementation());
}
}
library OpenZeppelinUpgradesAddress {
function isContract(address account) internal view returns (bool) {
uint256 size;
assembly { size := extcodesize(account) }
return size > 0;
}
}
contract BaseUpgradeabilityProxy is Proxy {
event Upgraded(address indexed implementation);
bytes32 internal constant IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
function _implementation() internal view returns (address impl) {
bytes32 slot = IMPLEMENTATION_SLOT;
assembly {
impl := sload(slot)
}
}
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
function _setImplementation(address newImplementation) internal {
require(OpenZeppelinUpgradesAddress.isContract(newImplementation), "Cannot set a proxy implementation to a non-contract address");
bytes32 slot = IMPLEMENTATION_SLOT;
assembly {
sstore(slot, newImplementation)
}
}
}
contract UpgradeabilityProxy is BaseUpgradeabilityProxy {
constructor(address _logic, bytes memory _data) public payable {
assert(IMPLEMENTATION_SLOT == bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1));
_setImplementation(_logic);
if(_data.length > 0) {
(bool success,) = _logic.delegatecall(_data);
require(success);
}
}
}
contract BaseAdminUpgradeabilityProxy is BaseUpgradeabilityProxy {
event AdminChanged(address previousAdmin, address newAdmin);
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
modifier ifAdmin() {
if (msg.sender == _admin()) {
_;
} else {
_fallback();
}
}
function admin() external ifAdmin returns (address) {
return _admin();
}
function implementation() external ifAdmin returns (address) {
return _implementation();
}
function changeAdmin(address newAdmin) external ifAdmin {
require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address");
emit AdminChanged(_admin(), newAdmin);
_setAdmin(newAdmin);
}
function upgradeTo(address newImplementation) external ifAdmin {
_upgradeTo(newImplementation);
}
function upgradeToAndCall(address newImplementation, bytes calldata data) payable external ifAdmin {
_upgradeTo(newImplementation);
(bool success,) = newImplementation.delegatecall(data);
require(success);
}
function _admin() internal view returns (address adm) {
bytes32 slot = ADMIN_SLOT;
assembly {
adm := sload(slot)
}
}
function _setAdmin(address newAdmin) internal {
bytes32 slot = ADMIN_SLOT;
assembly {
sstore(slot, newAdmin)
}
}
function _willFallback() internal {
require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin");
super._willFallback();
}
}
contract InitializableUpgradeabilityProxy is BaseUpgradeabilityProxy {
function initialize(address _logic, bytes memory _data) public payable {
require(_implementation() == address(0));
assert(IMPLEMENTATION_SLOT == bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1));
_setImplementation(_logic);
if(_data.length > 0) {
(bool success,) = _logic.delegatecall(_data);
require(success);
}
}
}
contract InitializableAdminUpgradeabilityProxy is BaseAdminUpgradeabilityProxy, InitializableUpgradeabilityProxy {
function initialize(address _logic, address _admin, bytes memory _data) public payable {
require(_implementation() == address(0));
InitializableUpgradeabilityProxy.initialize(_logic, _data);
assert(ADMIN_SLOT == bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1));
_setAdmin(_admin);
}
}
contract Context is Initializable {
constructor () internal { }
function _msgSender() internal view returns (address payable) {
return msg.sender;
}
function _msgData() internal view returns (bytes memory) {
this;
return msg.data;
}
}
contract Ownable is Initializable, Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function initialize(address sender) public initializer {
_owner = sender;
emit OwnershipTransferred(address(0), _owner);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(isOwner(), "Ownable: caller is not the owner");
_;
}
function isOwner() public view returns (bool) {
return _msgSender() == _owner;
}
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public onlyOwner {
_transferOwnership(newOwner);
}
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
uint256[50] private ______gap;
}
contract Claimable is Initializable, Ownable {
address public pendingOwner;
function initialize(address _nextOwner) public initializer {
Ownable.initialize(_nextOwner);
}
modifier onlyPendingOwner() {
require(
_msgSender() == pendingOwner,
"Claimable: caller is not the pending owner"
);
_;
}
function transferOwnership(address newOwner) public onlyOwner {
require(
newOwner != owner() && newOwner != pendingOwner,
"Claimable: invalid new owner"
);
pendingOwner = newOwner;
}
function claimOwnership() public onlyPendingOwner {
_transferOwnership(pendingOwner);
delete pendingOwner;
}
}
library String {
function fromUint(uint256 _i) internal pure returns (string memory) {
if (_i == 0) {
return "0";
}
uint256 j = _i;
uint256 len;
while (j != 0) {
len++;
j /= 10;
}
bytes memory bstr = new bytes(len);
uint256 k = len - 1;
while (_i != 0) {
bstr[k--] = bytes1(uint8(48 + (_i % 10)));
_i /= 10;
}
return string(bstr);
}
function fromBytes32(bytes32 _value) internal pure returns (string memory) {
bytes memory alphabet = "0123456789abcdef";
bytes memory str = new bytes(32 * 2 + 2);
str[0] = "0";
str[1] = "x";
for (uint256 i = 0; i < 32; i++) {
str[2 + i * 2] = alphabet[uint256(uint8(_value[i] >> 4))];
str[3 + i * 2] = alphabet[uint256(uint8(_value[i] & 0x0f))];
}
return string(str);
}
function fromAddress(address _addr) internal pure returns (string memory) {
bytes32 value = bytes32(uint256(_addr));
bytes memory alphabet = "0123456789abcdef";
bytes memory str = new bytes(20 * 2 + 2);
str[0] = "0";
str[1] = "x";
for (uint256 i = 0; i < 20; i++) {
str[2 + i * 2] = alphabet[uint256(uint8(value[i + 12] >> 4))];
str[3 + i * 2] = alphabet[uint256(uint8(value[i + 12] & 0x0f))];
}
return string(str);
}
function add8(
string memory a,
string memory b,
string memory c,
string memory d,
string memory e,
string memory f,
string memory g,
string memory h
) internal pure returns (string memory) {
return string(abi.encodePacked(a, b, c, d, e, f, g, h));
}
}
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 ERC20 is Initializable, Context, IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 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, uint256 amount) internal {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance");
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint(address account, 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);
}
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);
}
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");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, _msgSender(), _allowances[account][_msgSender()].sub(amount, "ERC20: burn amount exceeds allowance"));
}
uint256[50] private ______gap;
}
contract ERC20Detailed is Initializable, IERC20 {
string private _name;
string private _symbol;
uint8 private _decimals;
function initialize(string memory name, string memory symbol, uint8 decimals) public initializer {
_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;
}
uint256[50] private ______gap;
}
library Address {
function isContract(address account) internal view returns (bool) {
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
function toPayable(address account) internal pure returns (address payable) {
return address(uint160(account));
}
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");
}
}
library SafeERC20 {
using SafeMath for uint256;
using Address for address;
function safeTransfer(IERC20 token, address to, uint256 value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
function safeApprove(IERC20 token, address spender, uint256 value) internal {
require((value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).add(value);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function callOptionalReturn(IERC20 token, bytes memory data) private {
require(address(token).isContract(), "SafeERC20: call to non-contract");
(bool success, bytes memory returndata) = address(token).call(data);
require(success, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
contract CanReclaimTokens is Claimable {
using SafeERC20 for ERC20;
mapping(address => bool) private recoverableTokensBlacklist;
function initialize(address _nextOwner) public initializer {
Claimable.initialize(_nextOwner);
}
function blacklistRecoverableToken(address _token) public onlyOwner {
recoverableTokensBlacklist[_token] = true;
}
function recoverTokens(address _token) external onlyOwner {
require(
!recoverableTokensBlacklist[_token],
"CanReclaimTokens: token is not recoverable"
);
if (_token == address(0x0)) {
msg.sender.transfer(address(this).balance);
} else {
ERC20(_token).safeTransfer(
msg.sender,
ERC20(_token).balanceOf(address(this))
);
}
}
}
contract ERC20WithRate is Initializable, Ownable, ERC20 {
using SafeMath for uint256;
uint256 public constant _rateScale = 1e18;
uint256 internal _rate;
event LogRateChanged(uint256 indexed _rate);
function initialize(address _nextOwner, uint256 _initialRate)
public
initializer
{
Ownable.initialize(_nextOwner);
_setRate(_initialRate);
}
function setExchangeRate(uint256 _nextRate) public onlyOwner {
_setRate(_nextRate);
}
function exchangeRateCurrent() public view returns (uint256) {
require(_rate != 0, "ERC20WithRate: rate has not been initialized");
return _rate;
}
function _setRate(uint256 _nextRate) internal {
require(_nextRate > 0, "ERC20WithRate: rate must be greater than zero");
_rate = _nextRate;
}
function balanceOfUnderlying(address _account)
public
view
returns (uint256)
{
return toUnderlying(balanceOf(_account));
}
function toUnderlying(uint256 _amount) public view returns (uint256) {
return _amount.mul(_rate).div(_rateScale);
}
function fromUnderlying(uint256 _amountUnderlying)
public
view
returns (uint256)
{
return _amountUnderlying.mul(_rateScale).div(_rate);
}
}
contract ERC20WithPermit is Initializable, ERC20, ERC20Detailed {
using SafeMath for uint256;
mapping(address => uint256) public nonces;
string public version;
bytes32 public DOMAIN_SEPARATOR;
bytes32
public constant PERMIT_TYPEHASH = 0xea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb;
function initialize(
uint256 _chainId,
string memory _version,
string memory _name,
string memory _symbol,
uint8 _decimals
) public initializer {
ERC20Detailed.initialize(_name, _symbol, _decimals);
version = _version;
DOMAIN_SEPARATOR = keccak256(
abi.encode(
keccak256(
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
),
keccak256(bytes(name())),
keccak256(bytes(version)),
_chainId,
address(this)
)
);
}
function permit(
address holder,
address spender,
uint256 nonce,
uint256 expiry,
bool allowed,
uint8 v,
bytes32 r,
bytes32 s
) external {
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
DOMAIN_SEPARATOR,
keccak256(
abi.encode(
PERMIT_TYPEHASH,
holder,
spender,
nonce,
expiry,
allowed
)
)
)
);
require(holder != address(0), "ERC20WithRate: address must not be 0x0");
require(
holder == ecrecover(digest, v, r, s),
"ERC20WithRate: invalid signature"
);
require(
expiry == 0 || now <= expiry,
"ERC20WithRate: permit has expired"
);
require(nonce == nonces[holder]++, "ERC20WithRate: invalid nonce");
uint256 amount = allowed ? uint256(-1) : 0;
_approve(holder, spender, amount);
}
}
contract RenERC20LogicV1 is
Initializable,
ERC20,
ERC20Detailed,
ERC20WithRate,
ERC20WithPermit,
Claimable,
CanReclaimTokens
{
function initialize(
uint256 _chainId,
address _nextOwner,
uint256 _initialRate,
string memory _version,
string memory _name,
string memory _symbol,
uint8 _decimals
) public initializer {
ERC20Detailed.initialize(_name, _symbol, _decimals);
ERC20WithRate.initialize(_nextOwner, _initialRate);
ERC20WithPermit.initialize(
_chainId,
_version,
_name,
_symbol,
_decimals
);
Claimable.initialize(_nextOwner);
CanReclaimTokens.initialize(_nextOwner);
}
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
}
function burn(address _from, uint256 _amount) public onlyOwner {
_burn(_from, _amount);
}
function transfer(address recipient, uint256 amount) public returns (bool) {
require(
recipient != address(this),
"RenERC20: can't transfer to token address"
);
return super.transfer(recipient, amount);
}
function transferFrom(
address sender,
address recipient,
uint256 amount
) public returns (bool) {
require(
recipient != address(this),
"RenERC20: can't transfer to token address"
);
return super.transferFrom(sender, recipient, amount);
}
}
contract RenERC20Proxy is InitializableAdminUpgradeabilityProxy {
}
interface IMintGateway {
function mint(
bytes32 _pHash,
uint256 _amount,
bytes32 _nHash,
bytes calldata _sig
) external returns (uint256);
function mintFee() external view returns (uint256);
}
interface IBurnGateway {
function burn(bytes calldata _to, uint256 _amountScaled)
external
returns (uint256);
function burnFee() external view returns (uint256);
}
interface IGateway {
function mint(
bytes32 _pHash,
uint256 _amount,
bytes32 _nHash,
bytes calldata _sig
) external returns (uint256);
function mintFee() external view returns (uint256);
function burn(bytes calldata _to, uint256 _amountScaled)
external
returns (uint256);
function burnFee() external view returns (uint256);
}
contract GatewayStateV1 {
uint256 constant BIPS_DENOMINATOR = 10000;
uint256 public minimumBurnAmount;
RenERC20LogicV1 public token;
address public mintAuthority;
address public feeRecipient;
uint16 public mintFee;
uint16 public burnFee;
mapping(bytes32 => bool) public status;
uint256 public nextN = 0;
}
contract GatewayStateV2 {
struct Burn {
uint256 _blocknumber;
bytes _to;
uint256 _amount;
string _chain;
bytes _payload;
}
mapping(uint256 => Burn) internal burns;
bytes32 public selectorHash;
}
contract MintGatewayLogicV1 is
Initializable,
Claimable,
CanReclaimTokens,
IGateway,
GatewayStateV1,
GatewayStateV2
{
using SafeMath for uint256;
event LogMintAuthorityUpdated(address indexed _newMintAuthority);
event LogMint(
address indexed _to,
uint256 _amount,
uint256 indexed _n,
bytes32 indexed _nHash
);
event LogBurn(
bytes _to,
uint256 _amount,
uint256 indexed _n,
bytes indexed _indexedTo
);
modifier onlyOwnerOrMintAuthority() {
require(
msg.sender == mintAuthority || msg.sender == owner(),
"MintGateway: caller is not the owner or mint authority"
);
_;
}
function initialize(
RenERC20LogicV1 _token,
address _feeRecipient,
address _mintAuthority,
uint16 _mintFee,
uint16 _burnFee,
uint256 _minimumBurnAmount
) public initializer {
Claimable.initialize(msg.sender);
CanReclaimTokens.initialize(msg.sender);
minimumBurnAmount = _minimumBurnAmount;
token = _token;
mintFee = _mintFee;
burnFee = _burnFee;
updateMintAuthority(_mintAuthority);
updateFeeRecipient(_feeRecipient);
}
function updateSelectorHash(bytes32 _selectorHash) public onlyOwner {
selectorHash = _selectorHash;
}
function claimTokenOwnership() public {
token.claimOwnership();
}
function transferTokenOwnership(MintGatewayLogicV1 _nextTokenOwner)
public
onlyOwner
{
token.transferOwnership(address(_nextTokenOwner));
_nextTokenOwner.claimTokenOwnership();
}
function updateMintAuthority(address _nextMintAuthority)
public
onlyOwnerOrMintAuthority
{
require(
_nextMintAuthority != address(0),
"MintGateway: mintAuthority cannot be set to address zero"
);
mintAuthority = _nextMintAuthority;
emit LogMintAuthorityUpdated(mintAuthority);
}
function updateMinimumBurnAmount(uint256 _minimumBurnAmount)
public
onlyOwner
{
minimumBurnAmount = _minimumBurnAmount;
}
function updateFeeRecipient(address _nextFeeRecipient) public onlyOwner {
require(
_nextFeeRecipient != address(0x0),
"MintGateway: fee recipient cannot be 0x0"
);
feeRecipient = _nextFeeRecipient;
}
function updateMintFee(uint16 _nextMintFee) public onlyOwner {
mintFee = _nextMintFee;
}
function updateBurnFee(uint16 _nextBurnFee) public onlyOwner {
burnFee = _nextBurnFee;
}
function mint(
bytes32 _pHash,
uint256 _amountUnderlying,
bytes32 _nHash,
bytes memory _sig
) public returns (uint256) {
bytes32 sigHash = hashForSignature(
_pHash,
_amountUnderlying,
msg.sender,
_nHash
);
require(
status[sigHash] == false,
"MintGateway: nonce hash already spent"
);
if (!verifySignature(sigHash, _sig)) {
revert(
String.add8(
"MintGateway: invalid signature. pHash: ",
String.fromBytes32(_pHash),
", amount: ",
String.fromUint(_amountUnderlying),
", msg.sender: ",
String.fromAddress(msg.sender),
", _nHash: ",
String.fromBytes32(_nHash)
)
);
}
status[sigHash] = true;
uint256 amountScaled = token.fromUnderlying(_amountUnderlying);
uint256 absoluteFeeScaled = amountScaled.mul(mintFee).div(
BIPS_DENOMINATOR
);
uint256 receivedAmountScaled = amountScaled.sub(
absoluteFeeScaled,
"MintGateway: fee exceeds amount"
);
token.mint(msg.sender, receivedAmountScaled);
token.mint(feeRecipient, absoluteFeeScaled);
uint256 receivedAmountUnderlying = token.toUnderlying(
receivedAmountScaled
);
emit LogMint(msg.sender, receivedAmountUnderlying, nextN, _nHash);
nextN += 1;
return receivedAmountScaled;
}
function burn(bytes memory _to, uint256 _amount) public returns (uint256) {
require(_to.length != 0, "MintGateway: to address is empty");
uint256 fee = _amount.mul(burnFee).div(BIPS_DENOMINATOR);
uint256 amountAfterFee = _amount.sub(
fee,
"MintGateway: fee exceeds amount"
);
uint256 amountAfterFeeUnderlying = token.toUnderlying(amountAfterFee);
token.burn(msg.sender, _amount);
token.mint(feeRecipient, fee);
require(
amountAfterFeeUnderlying > minimumBurnAmount,
"MintGateway: amount is less than the minimum burn amount"
);
emit LogBurn(_to, amountAfterFeeUnderlying, nextN, _to);
bytes memory payload;
GatewayStateV2.burns[nextN] = Burn({
_blocknumber: block.number,
_to: _to,
_amount: amountAfterFeeUnderlying,
_chain: "",
_payload: payload
});
nextN += 1;
return amountAfterFeeUnderlying;
}
function getBurn(uint256 _n)
public
view
returns (
uint256 _blocknumber,
bytes memory _to,
uint256 _amount,
string memory _chain,
bytes memory _payload
)
{
Burn memory burnStruct = GatewayStateV2.burns[_n];
require(burnStruct._to.length > 0, "MintGateway: burn not found");
return (
burnStruct._blocknumber,
burnStruct._to,
burnStruct._amount,
burnStruct._chain,
burnStruct._payload
);
}
function verifySignature(bytes32 _sigHash, bytes memory _sig)
public
view
returns (bool)
{
return mintAuthority == ECDSA.recover(_sigHash, _sig);
}
function hashForSignature(
bytes32 _pHash,
uint256 _amount,
address _to,
bytes32 _nHash
) public view returns (bytes32) {
return
keccak256(abi.encode(_pHash, _amount, selectorHash, _to, _nHash));
}
}
contract MintGatewayProxy is InitializableAdminUpgradeabilityProxy {
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["803", "936", "1093", "435", "361", "387", "771", "348", "657", "855"]}, {"defect": "DelegateCall", "type": "Function_call", "severity": "High", "lines": ["272", "320", "355"]}, {"defect": "Frozen_Ether", "type": "Code_specification", "severity": "Medium", "lines": ["175", "361", "348"]}, {"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["1006", "1401", "1093", "936"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["684", "432", "1075", "1062", "1056", "1068", "1065", "1049", "1053", "1071", "1050", "1088", "1090", "654", "57", "334", "1342", "1294", "242", "258", "471", "478", "326", "50"]}, {"defect": "Redefine_variable", "type": "Code_specification", "severity": "Low", "lines": ["684", "432", "654"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["812", "946", "1134", "438", "363", "393", "776", "350", "663", "871", "1164", "399", "450", "415", "421", "410", "458", "1169"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["1298", "1351", "931"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["926"]}] | [{"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [696]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [328, 329, 327]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [336, 337, 338]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 186, 187, 188, 189, 190, 191]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [228]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [260, 261, 262]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [52]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [243, 244, 245]}}, {"check": "assembly", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [140, 141, 142, 143, 144]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1256, 1257, 1254, 1255]}}, {"check": "controlled-delegatecall", "impact": "High", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [355]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [706, 707, 708, 709, 710, 711, 712]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [649, 650, 651, 652]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [738, 739, 740, 741]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [168, 169, 170, 171, 172]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [736, 727, 728, 729, 730, 731, 732, 733, 734, 735]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [120, 121, 118, 119]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [723, 724, 725]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [384, 381, 382, 383]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [701, 702, 703]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [113, 114, 115]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [744, 745, 746, 743]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [680, 681, 682]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [675, 676, 677]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [976, 977, 978]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [834, 835, 836, 837, 838, 839, 840]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [458, 459, 460, 461]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [416, 417, 418, 415]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351, 1352, 1353, 1354]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1227, 1228, 1229]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [824, 825, 826, 827]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [421, 422, 423]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [608, 609, 606, 607]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [820, 821, 822]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1169, 1170, 1171, 1172, 1173, 1174, 1175]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, 1150]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, 1298, 1299, 1300, 1301, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271, 1272, 1273, 1274, 1275, 1276, 1277, 1278, 1279]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [600, 601, 602, 603]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1197, 1198, 1199, 1200, 1201, 1202]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1220, 1221, 1222]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [780, 781, 782]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [363, 364, 365, 366, 367, 368]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [568, 566, 567]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [587, 588, 589, 590]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1155, 1156, 1157]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365, 1366, 1367, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, 1376, 1377]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [970, 971, 972]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [846, 847, 848, 849, 850, 851, 852]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [584, 582, 583]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1164, 1165, 1166]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"MintGatewayProxy.sol": [680, 681, 682]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"MintGatewayProxy.sol": [660]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"MintGatewayProxy.sol": [658]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"MintGatewayProxy.sol": [675, 676, 677]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"MintGatewayProxy.sol": [659]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"MintGatewayProxy.sol": [658]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"MintGatewayProxy.sol": [325, 326, 327, 328, 329, 330]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"MintGatewayProxy.sol": [659]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"MintGatewayProxy.sol": [660]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"MintGatewayProxy.sol": [672, 670, 671]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [761]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [320]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [355]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [710]}}, {"check": "low-level-calls", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [272]}}, {"check": "events-access", "impact": "Low", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [455]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [1147]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [1228]}}, {"check": "events-maths", "impact": "Low", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [1201]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [272]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [355]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [320]}}, {"check": "incorrect-modifier", "impact": "Low", "confidence": "High", "lines": {"MintGatewayProxy.sol": [288, 289, 290, 291, 292, 293, 287]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1180]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [654]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [350]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [812]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [820]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1169]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1136]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [951]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [501]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [467]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [953]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [807]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1139]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1197]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [865]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1245]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1242]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [950]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1391]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [684]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [970]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1394]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [842]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1392]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [873]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [846]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1313]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1155]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [350]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [806]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1140]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [432]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [875]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [363]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [786]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [874]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [952]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [949]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [776]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [970]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [780]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1393]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [947]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1313]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [976]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [487]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [876]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [57]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1138]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1135]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1137]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1207]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [363]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [438]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [948]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [872]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1381]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [834]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [976]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1227]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [812]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1220]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [363]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1381]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1356]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1243]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1244]}}, {"check": "redundant-statements", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [384, 385, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [1298]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [1351]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [1341]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [1297]}}, {"check": "shadowing-state", "impact": "High", "confidence": "High", "lines": {"MintGatewayProxy.sol": [57]}}, {"check": "shadowing-state", "impact": "High", "confidence": "High", "lines": {"MintGatewayProxy.sol": [57]}}, {"check": "shadowing-state", "impact": "High", "confidence": "High", "lines": {"MintGatewayProxy.sol": [57]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [928, 929, 926, 927]}}, {"check": "uninitialized-local", "impact": "Medium", "confidence": "Medium", "lines": {"MintGatewayProxy.sol": [1342]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1170, 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271, 1272, 1273, 1274, 1275, 1276, 1277, 1278, 1279, 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365, 1366, 1367, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [1093, 1094, 1095, 1096, 1097, 1098, 1099, 1100, 1101, 1102, 1103, 1104, 1105, 1106, 1107, 1108, 1109, 1110, 1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1170, 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 1189, 1190, 1191, 1192, 1193, 1194, 1195, 1196, 1197, 1198, 1199, 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1230, 1231, 1232, 1233, 1234, 1235, 1236, 1237, 1238, 1239, 1240, 1241, 1242, 1243, 1244, 1245, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, 1265, 1266, 1267, 1268, 1269, 1270, 1271, 1272, 1273, 1274, 1275, 1276, 1277, 1278, 1279, 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, 1316, 1317, 1318, 1319, 1320, 1321, 1322, 1323, 1324, 1325, 1326, 1327, 1328, 1329, 1330, 1331, 1332, 1333, 1334, 1335, 1336, 1337, 1338, 1339, 1340, 1341, 1342, 1343, 1344, 1345, 1346, 1347, 1348, 1349, 1350, 1351, 1352, 1353, 1354, 1355, 1356, 1357, 1358, 1359, 1360, 1361, 1362, 1363, 1364, 1365, 1366, 1367, 1368, 1369, 1370, 1371, 1372, 1373, 1374, 1375, 1376, 1377, 1378, 1379, 1380, 1381, 1382, 1383, 1384, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 1395, 1396, 1397, 1398, 1399]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"MintGatewayProxy.sol": [936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, 1000, 1001, 1002, 1003, 1004]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 495, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 510, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 417, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 792, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1210, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 587, "severity": 2}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 241, "severity": 1}, {"rule": "SOLIDITY_FUNCTIONS_RETURNS_TYPE_AND_NO_RETURN", "line": 325, "severity": 1}, {"rule": "SOLIDITY_LOCKED_MONEY", "line": 175, "severity": 3}, {"rule": "SOLIDITY_LOCKED_MONEY", "line": 266, "severity": 3}, {"rule": "SOLIDITY_LOCKED_MONEY", "line": 278, "severity": 3}, {"rule": "SOLIDITY_LOCKED_MONEY", "line": 348, "severity": 3}, {"rule": "SOLIDITY_LOCKED_MONEY", "line": 361, "severity": 3}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 820, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 15, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 21, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 24, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 57, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 388, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 432, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 559, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 561, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 563, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 654, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 658, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 659, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 660, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 684, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 774, "severity": 1}, {"rule": "SOLIDITY_REVERT_REQUIRE", "line": 128, "severity": 1}, {"rule": "SOLIDITY_REVERT_REQUIRE", "line": 155, "severity": 1}, {"rule": "SOLIDITY_REVERT_REQUIRE", "line": 159, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 557, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 716, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 804, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 856, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 1101, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_PURE", "line": 126, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 44, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 219, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 241, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 325, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 689, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 1359, "severity": 1}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 320, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 720, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 724, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 735, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 740, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 745, "severity": 3}, {"rule": "SOLIDITY_UNCHECKED_CALL", "line": 761, "severity": 3}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 140, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 186, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 243, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 260, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 327, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 336, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 696, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 706, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 706, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 706, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 707, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 707, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 707, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 707, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 710, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 710, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 710, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 711, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1049, "severity": 1}] | [{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":false,"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"changeAdmin","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_logic","type":"address"},{"internalType":"address","name":"_admin","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"initialize","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_logic","type":"address"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"initialize","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"payable":true,"stateMutability":"payable","type":"function"}] | v0.5.16+commit.9c3226ce | true | 200 | Default | true | 0x4a144820a415bdfa0030937608743cae1d392029 | ||||
BebPos | 0xb970ff3a0ec1cb51a437a7a5061c65c4970dfd36 | Solidity | pragma solidity^0.4.20;
//实例化代币
interface tokenTransfer {
function transfer(address receiver, uint amount);
function transferFrom(address _from, address _to, uint256 _value);
function balanceOf(address receiver) returns(uint256);
}
contract Ownable {
address public owner;
bool lock = false;
/**
* 初台化构造函数
*/
function Ownable () public {
owner = msg.sender;
}
/**
* 判断当前合约调用者是否是合约的所有者
*/
modifier onlyOwner {
require (msg.sender == owner);
_;
}
/**
* 合约的所有者指派一个新的管理员
* @param newOwner address 新的管理员帐户地址
*/
function transferOwnership(address newOwner) onlyOwner public {
if (newOwner != address(0)) {
owner = newOwner;
}
}
}
contract BebPos is Ownable{
//会员数据结构
struct BebUser {
address customerAddr;//会员address
uint256 amount; //存款金额
uint256 bebtime;//存款时间
//uint256 interest;//利息
}
uint256 Bebamount;//BEB未发行数量
uint256 bebTotalAmount;//BEB总量
uint256 sumAmount = 0;//会员的总量
uint256 OneMinuteBEB;//初始化1分钟产生BEB数量
tokenTransfer public bebTokenTransfer; //代币
uint8 decimals = 18;
uint256 OneMinute=1 minutes; //1分钟
//会员 结构
mapping(address=>BebUser)public BebUsers;
address[] BebUserArray;//存款的地址数组
//事件
event messageBetsGame(address sender,bool isScuccess,string message);
//BEB的合约地址
function BebPos(address _tokenAddress,uint256 _Bebamount,uint256 _bebTotalAmount,uint256 _OneMinuteBEB){
bebTokenTransfer = tokenTransfer(_tokenAddress);
Bebamount=_Bebamount*10**18;//初始设定为发行数量
bebTotalAmount=_bebTotalAmount*10**18;//初始设定BEB总量
OneMinuteBEB=_OneMinuteBEB*10**18;//初始化1分钟产生BEB数量
BebUserArray.push(_tokenAddress);
}
//存入 BEB
function freeze(uint256 _value,address _addr) public{
//判断会员存款金额是否等于0
if(BebUsers[msg.sender].amount == 0){
//判断未发行数量是否大于20个BEB
if(Bebamount > OneMinuteBEB){
bebTokenTransfer.transferFrom(_addr,address(address(this)),_value);//存入BEB
BebUsers[_addr].customerAddr=_addr;
BebUsers[_addr].amount=_value;
BebUsers[_addr].bebtime=now;
sumAmount+=_value;//总存款增加
//加入存款数组地址
//addToAddress(msg.sender);//加入存款数组地址
messageBetsGame(msg.sender, true,"转入成功");
return;
}
else{
messageBetsGame(msg.sender, true,"转入失败,BEB总量已经全部发行完毕");
return;
}
}else{
messageBetsGame(msg.sender, true,"转入失败,请先取出合约中的余额");
return;
}
}
//取款
function unfreeze(address referral) public {
address _address = msg.sender;
BebUser storage user = BebUsers[_address];
require(user.amount > 0);
//
uint256 _time=user.bebtime;//存款时间
uint256 _amuont=user.amount;//个人存款金额
uint256 AA=(now-_time)/OneMinute*OneMinuteBEB;//现在时间-存款时间/60秒*每分钟生产20BEB
uint256 BB=bebTotalAmount-Bebamount;//计算出已流通数量
uint256 CC=_amuont*AA/BB;//存款*AA/已流通数量
//判断未发行数量是否大于20BEB
if(Bebamount > OneMinuteBEB){
Bebamount-=CC;
//user.interest+=CC;//向账户增加利息
user.bebtime=now;//重置存款时间为现在
}
//判断未发行数量是否大于20个BEB
if(Bebamount > OneMinuteBEB){
Bebamount-=CC;//从发行总量当中减少
sumAmount-=_amuont;
bebTokenTransfer.transfer(msg.sender,CC+user.amount);//转账给会员 + 会员本金+当前利息
//更新数据
BebUsers[_address].amount=0;//会员存款0
BebUsers[_address].bebtime=0;//会员存款时间0
//BebUsers[_address].interest=0;//利息归0
messageBetsGame(_address, true,"本金和利息成功取款");
return;
}
else{
Bebamount-=CC;//从发行总量当中减少
sumAmount-=_amuont;
bebTokenTransfer.transfer(msg.sender,_amuont);//转账给会员 + 会员本金
//更新数据
BebUsers[_address].amount=0;//会员存款0
BebUsers[_address].bebtime=0;//会员存款时间0
//BebUsers[_address].interest=0;//利息归0
messageBetsGame(_address, true,"BEB总量已经发行完毕,取回本金");
return;
}
}
function getTokenBalance() public view returns(uint256){
return bebTokenTransfer.balanceOf(address(this));
}
function getSumAmount() public view returns(uint256){
return sumAmount;
}
function getBebAmount() public view returns(uint256){
return Bebamount;
}
function getBebAmountzl() public view returns(uint256){
uint256 _sumAmount=bebTotalAmount-Bebamount;
return _sumAmount;
}
function myfrozentokens() public view returns (uint){
return sumAmount;
}
function totalSupply() public view returns (uint){
return Bebamount;
}
function earningrate() public view returns (uint){
return bebTotalAmount;
}
function myBalance(address _form) public view returns (uint){
address _address = _form;
BebUser storage user = BebUsers[_address];
return (user.amount);
}
function checkinterests(address _form) public view returns(uint) {
address _address = _form;
BebUser storage user = BebUsers[_address];
assert(user.amount > 0);
uint256 A=(now-user.bebtime)/OneMinute*OneMinuteBEB;
uint256 B=bebTotalAmount-Bebamount;
uint256 C=user.amount*A/B;
return C;
}
function getLength() public view returns(uint256){
return (BebUserArray.length);
}
function getUserProfit(address _form) public view returns(address,uint256,uint256,uint256){
address _address = _form;
BebUser storage user = BebUsers[_address];
assert(user.amount > 0);
uint256 A=(now-user.bebtime)/OneMinute*OneMinuteBEB;
uint256 B=bebTotalAmount-Bebamount;
uint256 C=user.amount*A/B;
return (_address,user.bebtime,user.amount,C);
}
function()payable{
}
} | [{"defect": "Uninitialized_storage", "type": "Code_specification", "severity": "Low", "lines": ["182", "98", "169", "163"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["54", "11"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["29"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["108", "114", "115", "125", "126", "64", "66", "65", "79", "103", "104", "105", "146", "185", "184", "186", "173", "172", "171"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["67", "150", "140", "147", "158", "178"]}] | [{"check": "controlled-array-length", "impact": "High", "confidence": "Medium", "lines": {"BebPos.sol": [67]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [55]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [54]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [11]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"BebPos.sol": [184]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"BebPos.sol": [103]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"BebPos.sol": [171]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [6]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [189, 190, 191]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [161, 162, 163, 164, 165]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [180, 181, 182, 183, 184, 185, 186, 187, 188]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [5]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [4]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [128, 129, 130, 131, 132, 133, 134, 135, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [33, 34, 35, 36, 37]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [167, 168, 169, 170, 171, 172, 173, 174, 175]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [157, 158, 159]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [145, 146, 147, 148]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [139, 140, 141]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [153, 154, 155]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [177, 178, 179]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [149, 150, 151]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [136, 137, 138]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"BebPos.sol": [144, 142, 143]}}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High", "lines": {"BebPos.sol": [5]}}, {"check": "erc20-interface", "impact": "Medium", "confidence": "High", "lines": {"BebPos.sol": [4]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"BebPos.sol": [1]}}, {"check": "locked-ether", "impact": "Medium", "confidence": "High", "lines": {"BebPos.sol": [189, 190, 191]}}, {"check": "events-access", "impact": "Low", "confidence": "Medium", "lines": {"BebPos.sol": [35]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BebPos.sol": [49]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BebPos.sol": [58]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BebPos.sol": [161]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BebPos.sol": [167]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BebPos.sol": [57]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BebPos.sol": [70]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BebPos.sol": [180]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BebPos.sol": [70]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BebPos.sol": [55]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BebPos.sol": [52]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BebPos.sol": [60]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"BebPos.sol": [3, 4, 5, 6, 7]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"BebPos.sol": [79]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"BebPos.sol": [121]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"BebPos.sol": [132]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"BebPos.sol": [82]}}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium", "lines": {"BebPos.sol": [119]}}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium", "lines": {"BebPos.sol": [78]}}, {"check": "reentrancy-no-eth", "impact": "Medium", "confidence": "Medium", "lines": {"BebPos.sol": [130]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"BebPos.sol": [113]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"BebPos.sol": [74]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"BebPos.sol": [40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"BebPos.sol": [40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193]}}] | [{"error": "Integer Underflow.", "line": 103, "level": "Warning"}, {"error": "Integer Underflow.", "line": 146, "level": "Warning"}, {"error": "Integer Underflow.", "line": 104, "level": "Warning"}, {"error": "Integer Overflow.", "line": 77, "level": "Warning"}, {"error": "Integer Overflow.", "line": 79, "level": "Warning"}, {"error": "Integer Overflow.", "line": 101, "level": "Warning"}, {"error": "Integer Overflow.", "line": 102, "level": "Warning"}, {"error": "Integer Overflow.", "line": 78, "level": "Warning"}] | [{"rule": "SOLIDITY_DIV_MUL", "line": 103, "severity": 2}, {"rule": "SOLIDITY_DIV_MUL", "line": 171, "severity": 2}, {"rule": "SOLIDITY_DIV_MUL", "line": 184, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 4, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 5, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 6, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 62, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 189, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 11, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 49, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 50, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 51, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 52, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 54, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 55, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 58, "severity": 1}] | [{"constant":false,"inputs":[{"name":"_value","type":"uint256"},{"name":"_addr","type":"address"}],"name":"freeze","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getBebAmountzl","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"bebTokenTransfer","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"myfrozentokens","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"referral","type":"address"}],"name":"unfreeze","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"_form","type":"address"}],"name":"getUserProfit","outputs":[{"name":"","type":"address"},{"name":"","type":"uint256"},{"name":"","type":"uint256"},{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"BebUsers","outputs":[{"name":"customerAddr","type":"address"},{"name":"amount","type":"uint256"},{"name":"bebtime","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_form","type":"address"}],"name":"myBalance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getTokenBalance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"_form","type":"address"}],"name":"checkinterests","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"earningrate","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getLength","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getSumAmount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"getBebAmount","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_tokenAddress","type":"address"},{"name":"_Bebamount","type":"uint256"},{"name":"_bebTotalAmount","type":"uint256"},{"name":"_OneMinuteBEB","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"sender","type":"address"},{"indexed":false,"name":"isScuccess","type":"bool"},{"indexed":false,"name":"message","type":"string"}],"name":"messageBetsGame","type":"event"}] | v0.4.24+commit.e67f0147 | false | 200 | 00000000000000000000000060fc8444349fee867fd9c0638a2f9a02b352aca700000000000000000000000000000000000000000000000000000000008954400000000000000000000000000000000000000000000000000000000035a4e9000000000000000000000000000000000000000000000000000000000000000014 | Default | MIT | false | bzzr://82479ed91d696f28e8312f791f64432e9c99252d40ad9f89fe1be7836e481ba1 |
||
MenloWalletTimelock | 0xfcac7d185315442aeee4b61475747ab23fa1b7f1 | Solidity | pragma solidity ^0.4.13;
contract Ownable {
address public owner;
event OwnershipRenounced(address indexed previousOwner);
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() public {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
/**
* @dev Allows the current owner to relinquish control of the contract.
* @notice Renouncing to ownership will leave the contract without an owner.
* It will not be possible to call the functions with the `onlyOwner`
* modifier anymore.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipRenounced(owner);
owner = address(0);
}
/**
* @dev Allows the current owner to transfer control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function transferOwnership(address _newOwner) public onlyOwner {
_transferOwnership(_newOwner);
}
/**
* @dev Transfers control of the contract to a newOwner.
* @param _newOwner The address to transfer ownership to.
*/
function _transferOwnership(address _newOwner) internal {
require(_newOwner != address(0));
emit OwnershipTransferred(owner, _newOwner);
owner = _newOwner;
}
}
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);
}
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
);
}
library SafeERC20 {
function safeTransfer(
ERC20Basic _token,
address _to,
uint256 _value
)
internal
{
require(_token.transfer(_to, _value));
}
function safeTransferFrom(
ERC20 _token,
address _from,
address _to,
uint256 _value
)
internal
{
require(_token.transferFrom(_from, _to, _value));
}
function safeApprove(
ERC20 _token,
address _spender,
uint256 _value
)
internal
{
require(_token.approve(_spender, _value));
}
}
contract TokenTimelock {
using SafeERC20 for ERC20Basic;
// ERC20 basic token contract being held
ERC20Basic public token;
// beneficiary of tokens after they are released
address public beneficiary;
// timestamp when token release is enabled
uint256 public releaseTime;
constructor(
ERC20Basic _token,
address _beneficiary,
uint256 _releaseTime
)
public
{
// solium-disable-next-line security/no-block-members
require(_releaseTime > block.timestamp);
token = _token;
beneficiary = _beneficiary;
releaseTime = _releaseTime;
}
/**
* @notice Transfers tokens held by timelock to beneficiary.
*/
function release() public {
// solium-disable-next-line security/no-block-members
require(block.timestamp >= releaseTime);
uint256 amount = token.balanceOf(address(this));
require(amount > 0);
token.safeTransfer(beneficiary, amount);
}
}
contract MenloWalletTimelock is TokenTimelock, Ownable {
constructor(address _beneficiary, uint256 _releaseTime)
TokenTimelock(ERC20Basic(0), _beneficiary, _releaseTime) public {}
function setToken(ERC20Basic _token) public onlyOwner {
token = _token;
}
} | [{"defect": "Erroneous_constructor_name", "type": "Access_control", "severity": "Medium", "lines": ["67"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["30", "41"]}, {"defect": "Dependency_of_timestamp", "type": "Business_logic", "severity": "Medium", "lines": ["135", "146"]}] | [{"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"MenloWalletTimelock.sol": [104, 105, 106, 107, 108, 109, 110, 111, 112]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"MenloWalletTimelock.sol": [96, 97, 98, 99, 100, 101, 102, 93, 94, 95]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [160, 161, 159]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [72, 71]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [36, 37, 38, 39]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [45, 46, 47]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [61]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [144, 145, 146, 147, 148, 149, 150, 151, 152]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [62]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [74]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [63]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [68, 69]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [1]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"MenloWalletTimelock.sol": [137]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [96]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [106]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [95]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [86]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [159]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [85]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [107]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [84]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [97]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [45]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [94]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MenloWalletTimelock.sol": [105]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"MenloWalletTimelock.sol": [146]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"MenloWalletTimelock.sol": [135]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 38, "severity": 1}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 159, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}] | [{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"setToken","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"beneficiary","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"release","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"releaseTime","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"token","outputs":[{"name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"_beneficiary","type":"address"},{"name":"_releaseTime","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"}],"name":"OwnershipRenounced","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"previousOwner","type":"address"},{"indexed":true,"name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"}] | v0.4.24+commit.e67f0147 | true | 200 | 00000000000000000000000003666ed7f918a34ea7415ac2785e1aa4a2bc26c0000000000000000000000000000000000000000000000000000000005c14d0a0 | Default | false | bzzr://373920c59fc96d44edf6590d04817a794625bc7d2389b6ce15d1754358f64a7a |
|||
XmasDAO | 0xeb7bd3c2c01fd3c26886edf7e604e2e94cac2604 | Solidity | // Telegram: https://t.me/XmasDAO
// Website: https://xmasdao.org
// Twitter: https://twitter.com/Xmas_DAO
// 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 XmasDAO is Context, IERC20, Ownable {
using SafeMath for uint256;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private bots;
mapping (address => uint) private cooldown;
uint256 private constant MAX = ~uint256(0);
uint256 private constant _tTotal = 1 * 10**9 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
uint256 private _feeAddr1;
uint256 private _feeAddr2;
uint256 private _feeAddr3;
address payable private _feeAddrWallet1;
address payable private _feeAddrWallet2;
address payable private _feeAddrWallet3;
string private constant _name = "Xmas DAO";
string private constant _symbol = "XMAS";
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(0xd10a812571fe9E0Ff5976809dD99E5fc866e9fa0);
_feeAddrWallet2 = payable(0x97d3e6faECDa5a2a234341Ea0EFBa0e4baE5C56B);
_feeAddrWallet3 = payable(0x65d9a3c629969a3d5191dEaDBABC2Ff64f35eBbC);
_rOwned[address(this)] = _rTotal.div(2);
_rOwned[0x628eDe7669c5e4E3743fA3589af4fD23764c17cb] = _rTotal.div(2);
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_feeAddrWallet1] = true;
_isExcludedFromFee[_feeAddrWallet2] = true;
_isExcludedFromFee[_feeAddrWallet3] = true;
emit Transfer(address(0),address(this),_tTotal.div(2));
emit Transfer(address(0),0x628eDe7669c5e4E3743fA3589af4fD23764c17cb,_tTotal.div(2));
}
function name() public pure returns (string memory) {
return _name;
}
function symbol() public pure returns (string memory) {
return _symbol;
}
function decimals() public pure returns (uint8) {
return _decimals;
}
function totalSupply() public pure override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function setCooldownEnabled(bool onoff) external onlyOwner() {
cooldownEnabled = onoff;
}
function tokenFromReflection(uint256 rAmount) private view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address from, address to, uint256 amount) private {
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
_feeAddr1 = 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 (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(4));
_feeAddrWallet3.transfer(amount.div(4));
}
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 = 1 * 10**9 * 10**9;
tradingOpen = true;
IERC20(uniswapV2Pair).approve(address(uniswapV2Router), type(uint).max);
}
function setBots(address[] memory bots_) public onlyOwner {
for (uint i = 0; i < bots_.length; i++) {
bots[bots_[i]] = true;
}
}
function delBot(address notbot) public onlyOwner {
bots[notbot] = false;
}
function _tokenTransfer(address sender, address recipient, uint256 amount) private {
_transferStandard(sender, recipient, amount);
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeTeam(tTeam);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeTeam(uint256 tTeam) private {
uint256 currentRate = _getRate();
uint256 rTeam = tTeam.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rTeam);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
receive() external payable {}
function manualswap() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualsend() external {
require(_msgSender() == _feeAddrWallet1);
uint256 contractETHBalance = address(this).balance;
sendETHToFee(contractETHBalance);
}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tTeam) = _getTValues(tAmount, _feeAddr1, _feeAddr2);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tTeam, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tTeam);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 TeamFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tTeam = tAmount.mul(TeamFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tTeam);
return (tTransferAmount, tFee, tTeam);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 tTeam, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTeam = tTeam.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee).sub(rTeam);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
} | [] | [{"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"XmasDAO.sol": [65]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"XmasDAO.sol": [129]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"XmasDAO.sol": [201, 202, 203, 204, 205]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"XmasDAO.sol": [83, 84, 85, 86]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"XmasDAO.sol": [297, 298, 299]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"XmasDAO.sol": [179, 180, 181]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"XmasDAO.sol": [291, 292, 293, 294, 295]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"XmasDAO.sol": [176, 177, 175]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"XmasDAO.sol": [171, 172, 173]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"XmasDAO.sol": [168, 169, 167]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"XmasDAO.sol": [192, 193, 194]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"XmasDAO.sol": [196, 197, 198, 199]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"XmasDAO.sol": [187, 188, 189, 190]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"XmasDAO.sol": [74, 75, 76]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"XmasDAO.sol": [74, 75, 76]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"XmasDAO.sol": [134]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"XmasDAO.sol": [123]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"XmasDAO.sol": [103]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"XmasDAO.sol": [136]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"XmasDAO.sol": [135]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"XmasDAO.sol": [220]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"XmasDAO.sol": [284]}}, {"check": "reentrancy-benign", "impact": "Low", "confidence": "Medium", "lines": {"XmasDAO.sol": [322]}}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium", "lines": {"XmasDAO.sol": [287]}}, {"check": "reentrancy-eth", "impact": "High", "confidence": "Medium", "lines": {"XmasDAO.sol": [321]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"XmasDAO.sol": [254]}}, {"check": "reentrancy-events", "impact": "Low", "confidence": "Medium", "lines": {"XmasDAO.sol": [203]}}, {"check": "reentrancy-unlimited-gas", "impact": "Informational", "confidence": "Medium", "lines": {"XmasDAO.sol": [203]}}, {"check": "reentrancy-unlimited-gas", "impact": "Informational", "confidence": "Medium", "lines": {"XmasDAO.sol": [254]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"XmasDAO.sol": [350]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"XmasDAO.sol": [132]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"XmasDAO.sol": [341]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"XmasDAO.sol": [341]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"XmasDAO.sol": [306]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"XmasDAO.sol": [350]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"XmasDAO.sol": [306]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"XmasDAO.sol": [131]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"XmasDAO.sol": [132]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"XmasDAO.sol": [306]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"XmasDAO.sol": [350]}}, {"check": "similar-names", "impact": "Informational", "confidence": "Medium", "lines": {"XmasDAO.sol": [341]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"XmasDAO.sol": [235]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"XmasDAO.sol": [283]}}, {"check": "unused-return", "impact": "Medium", "confidence": "Medium", "lines": {"XmasDAO.sol": [288]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"XmasDAO.sol": [114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"XmasDAO.sol": [114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"XmasDAO.sol": [114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 152, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 153, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 154, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 156, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 164, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 279, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 85, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 196, "severity": 2}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 292, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 292, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 291, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 6, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 64, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 65, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 116, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 117, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 118, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 119, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 120, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 121, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 122, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 123, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 124, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 125, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 127, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 128, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 129, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 130, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 131, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 132, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 134, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 135, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 136, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 138, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 139, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 140, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 141, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 142, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 143, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 144, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 115, "severity": 1}, {"rule": "SOLIDITY_SHOULD_RETURN_STRUCT", "line": 111, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 68, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 95, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 151, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 98, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 99, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 100, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 325, "severity": 1}] | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_maxTxAmount","type":"uint256"}],"name":"MaxTxAmountUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"notbot","type":"address"}],"name":"delBot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manualsend","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"manualswap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"openTrading","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"bots_","type":"address[]"}],"name":"setBots","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"onoff","type":"bool"}],"name":"setCooldownEnabled","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}] | v0.8.4+commit.c7e474f2 | false | 200 | Default | None | false | ipfs://6055aa860cd01da21971106a9fbd57d41d640cd683e3e098da9725a457ddbfb6 |
|||
MacCoin | 0x90d85f89642718fb6eb633162b9c95e9ac2ef941 | Solidity | pragma solidity ^0.5.0;
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);
}
pragma solidity ^0.5.0;
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
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.
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) {
// 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;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0, "SafeMath: modulo by zero");
return a % b;
}
}
pragma solidity ^0.5.0;
contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
uint256 private _totalSupply;
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
function balanceOf(address account) public view returns (uint256) {
return _balances[account];
}
function transfer(address recipient, uint256 amount) public returns (bool) {
_transfer(msg.sender, recipient, amount);
return true;
}
function allowance(address owner, address spender) public view returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 value) public returns (bool) {
_approve(msg.sender, spender, value);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, msg.sender, _allowances[sender][msg.sender].sub(amount));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue));
return true;
}
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");
_balances[sender] = _balances[sender].sub(amount);
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
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);
}
function _burn(address account, uint256 value) internal {
require(account != address(0), "ERC20: burn from the zero address");
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
function _approve(address owner, address spender, uint256 value) internal {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = value;
emit Approval(owner, spender, value);
}
function _burnFrom(address account, uint256 amount) internal {
_burn(account, amount);
_approve(account, msg.sender, _allowances[account][msg.sender].sub(amount));
}
}
contract MacCoin is ERC20 {
string public _name = 'MacCoin';
string public _symbol = 'MCD';
uint8 public _decimals = 10;
constructor(string memory name, string memory symbol, uint8 decimals, uint256 totalSupply, address payable feeReceiver, address tokenOwnerAddress) public payable {
_name = name;
_symbol = symbol;
_decimals = decimals;
_mint(tokenOwnerAddress, totalSupply);
feeReceiver.transfer(msg.value);
}
function burn(uint256 value) public {
_burn(msg.sender, value);
}
// optional functions from ERC20 stardard
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 () external payable {
revert();
}
} | [] | [{"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"MacCoin.sol": [41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"MacCoin.sol": [152, 153, 154, 151]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"MacCoin.sol": [64, 65, 66, 63]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"MacCoin.sol": [54, 55, 56, 57, 58, 59, 60, 61]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MacCoin.sol": [102, 103, 104, 105, 106]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MacCoin.sol": [113, 114, 115, 116]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MacCoin.sol": [84, 85, 86]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MacCoin.sol": [88, 89, 90, 91]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MacCoin.sol": [180, 181, 182]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MacCoin.sol": [108, 109, 110, 111]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MacCoin.sol": [184, 185, 186]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MacCoin.sol": [176, 174, 175]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MacCoin.sol": [188, 189, 190]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MacCoin.sol": [80, 81, 82]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MacCoin.sol": [97, 98, 99, 100]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"MacCoin.sol": [93, 94, 95]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"MacCoin.sol": [23]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"MacCoin.sol": [69]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"MacCoin.sol": [1]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"MacCoin.sol": [180, 181, 182]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"MacCoin.sol": [188, 189, 190]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"MacCoin.sol": [184, 185, 186]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"MacCoin.sol": [5]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"MacCoin.sol": [171]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MacCoin.sol": [163]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MacCoin.sol": [162]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"MacCoin.sol": [161]}}] | [] | [{"rule": "SOLIDITY_ERC20_APPROVE", "line": 97, "severity": 2}, {"rule": "SOLIDITY_LOCKED_MONEY", "line": 159, "severity": 3}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 23, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 69, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 74, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 75, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 77, "severity": 1}, {"rule": "SOLIDITY_SAFEMATH", "line": 72, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 165, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 165, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 165, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 166, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 167, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 168, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 169, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 169, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 171, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 171, "severity": 1}] | [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"value","type":"uint256"}],"name":"approve","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"sender","type":"address"},{"name":"recipient","type":"address"},{"name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"_decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"value","type":"uint256"}],"name":"burn","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"name":"account","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"name":"spender","type":"address"},{"name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"name":"recipient","type":"address"},{"name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"_symbol","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"_name","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"name":"owner","type":"address"},{"name":"spender","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"inputs":[{"name":"name","type":"string"},{"name":"symbol","type":"string"},{"name":"decimals","type":"uint8"},{"name":"totalSupply","type":"uint256"},{"name":"feeReceiver","type":"address"},{"name":"tokenOwnerAddress","type":"address"}],"payable":true,"stateMutability":"payable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"},{"indexed":true,"name":"spender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Approval","type":"event"}] | v0.5.0+commit.1d4f565a | false | 200 | 00000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000001158e460913d00000000000000000000000000000020bae692cd8f865e939a82fe2e8e6ef9dc837e5000000000000000000000000020bae692cd8f865e939a82fe2e8e6ef9dc837e500000000000000000000000000000000000000000000000000000000000000074d6163436f696e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000034d43440000000000000000000000000000000000000000000000000000000000 | Default | None | false | bzzr://8fb3ffd4b2efee283e17615e85862654d61648a1c013d5af40f4117e45cb8fde |
||
ExtraBalToken | 0x5c40ef6f527f4fba68368774e6130ce6515123f2 | Solidity | contract ExtraBalToken {
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);
/* Send coins */
function transfer(address _to, uint256 _value) {
if (balanceOf[msg.sender] < _value) throw; // Check if the sender has enough
if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows
balanceOf[msg.sender] -= _value; // Subtract from the sender
balanceOf[_to] += _value; // Add the same to the recipient
Transfer(msg.sender, _to, _value); // Notify anyone listening that this transfer took place
}
/* Allow another contract to spend some tokens in your behalf */
function approve(address _spender, uint256 _value)
returns (bool success) {
allowance[msg.sender][_spender] = _value;
return true;
}
/* A contract attempts to get the coins */
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
if (balanceOf[_from] < _value) throw; // Check if the sender has enough
if (balanceOf[_to] + _value < balanceOf[_to]) throw; // Check for overflows
if (_value > allowance[_from][msg.sender]) throw; // Check allowance
balanceOf[_from] -= _value; // Subtract from the sender
balanceOf[_to] += _value; // Add the same to the recipient
allowance[_from][msg.sender] -= _value;
Transfer(_from, _to, _value);
return true;
}
/* This unnamed function is called whenever someone tries to send ether to it */
function () {
throw; // Prevents accidental sending of ether
}
uint constant D160 = 0x10000000000000000000000000000000000000000;
address public owner;
function ExtraBalToken() {
owner = msg.sender;
}
bool public sealed;
// The 160 LSB is the address of the balance
// The 96 MSB is the balance of that address.
function fill(uint[] data) {
if ((msg.sender != owner)||(sealed))
throw;
for (uint i=0; i<data.length; i++) {
address a = address( data[i] & (D160-1) );
uint amount = data[i] / D160;
if (balanceOf[a] == 0) { // In case it's filled two times, it only increments once
balanceOf[a] = amount;
totalSupply += amount;
}
}
}
function seal() {
if ((msg.sender != owner)||(sealed))
throw;
sealed= true;
}
} | [{"defect": "Balance_manipulation", "type": "Business_logic", "severity": "Medium", "lines": ["62"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["48", "28", "12"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["64", "14", "30", "15", "16", "34", "33", "32", "61"]}] | null | null | null | [{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_value","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"type":"function"},{"constant":false,"inputs":[],"name":"seal","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":false,"inputs":[{"name":"data","type":"uint256[]"}],"name":"fill","outputs":[],"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[],"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"allowance","outputs":[{"name":"","type":"uint256"}],"type":"function"},{"constant":true,"inputs":[],"name":"sealed","outputs":[{"name":"","type":"bool"}],"type":"function"},{"inputs":[],"type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Transfer","type":"event"}] | v0.3.6-2016-08-17-c499470 | true | 200 | Default | false | |||||
simpl_iQuiz | 0x4f945bb4552df57f6ce5d702e84aacc291cceeb6 | Solidity | pragma solidity ^0.4.25;
contract simpl_iQuiz
{
function Try(string _response) external payable
{
require(msg.sender == tx.origin);
if(responseHash == keccak256(_response) && msg.value > 0.4 ether)
{
msg.sender.transfer(this.balance);
}
}
string public question;
bytes32 responseHash;
mapping (bytes32=>bool) admin;
function Start(string _question, string _response) public payable isAdmin{
if(responseHash==0x0){
responseHash = keccak256(_response);
question = _question;
}
}
function Stop() public payable isAdmin {
msg.sender.transfer(this.balance);
}
function New(string _question, bytes32 _responseHash) public payable isAdmin {
question = _question;
responseHash = _responseHash;
}
constructor(bytes32[] admins) public{
for(uint256 i=0; i< admins.length; i++){
admin[admins[i]] = true;
}
}
modifier isAdmin(){
require(admin[keccak256(msg.sender)]);
_;
}
function() public payable{}
} | [{"defect": "Leaking_to_arbitary_address", "type": "Access_control", "severity": "Medium", "lines": ["29"]}] | [{"check": "arbitrary-send", "impact": "High", "confidence": "Medium", "lines": {"simpl_iQuiz.sol": [29]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"simpl_iQuiz.sol": [21, 22, 23, 24, 25, 26]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"simpl_iQuiz.sol": [32, 33, 34, 35]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"simpl_iQuiz.sol": [48]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"simpl_iQuiz.sol": [28, 29, 30]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"simpl_iQuiz.sol": [1]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"simpl_iQuiz.sol": [32]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"simpl_iQuiz.sol": [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"simpl_iQuiz.sol": [21, 22, 23, 24, 25, 26]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"simpl_iQuiz.sol": [32, 33, 34, 35]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"simpl_iQuiz.sol": [5]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"simpl_iQuiz.sol": [5, 6, 7, 8, 9, 10, 11, 12, 13]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"simpl_iQuiz.sol": [32]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"simpl_iQuiz.sol": [21]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"simpl_iQuiz.sol": [28, 29, 30]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"simpl_iQuiz.sol": [21]}}] | [{"error": "Integer Underflow.", "line": 9, "level": "Warning"}, {"error": "Integer Underflow.", "line": 15, "level": "Warning"}, {"error": "Integer Overflow.", "line": 21, "level": "Warning"}, {"error": "Integer Overflow.", "line": 9, "level": "Warning"}, {"error": "Integer Overflow.", "line": 32, "level": "Warning"}, {"error": "Transaction-Ordering Dependency.", "line": 11, "level": "Warning"}, {"error": "Transaction-Ordering Dependency.", "line": 29, "level": "Warning"}] | [{"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 38, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 38, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 48, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 21, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 21, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 32, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 37, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 17, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 19, "severity": 1}] | [{"constant":false,"inputs":[{"name":"_response","type":"string"}],"name":"Try","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":true,"inputs":[],"name":"question","outputs":[{"name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"Stop","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_question","type":"string"},{"name":"_response","type":"string"}],"name":"Start","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"constant":false,"inputs":[{"name":"_question","type":"string"},{"name":"_responseHash","type":"bytes32"}],"name":"New","outputs":[],"payable":true,"stateMutability":"payable","type":"function"},{"inputs":[{"name":"admins","type":"bytes32[]"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"payable":true,"stateMutability":"payable","type":"fallback"}] | v0.4.25+commit.59dbf8f1 | true | 200 | 000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000038ac709d3e3dfda7cb91fd539d0fab1c7526cb5d1e35ba7332884c00a11ad8645ac875aefd920eb697e291f9414a2103c99426ce8ef319508f7fb321d71e92e858f59c0eee0b6ed0c521c2609770180e5d7de0e1de3a415621ca6ba99c914400e | Default | false | bzzr://8f9bd0892ec0c268dfbb9fff35faadff199187535b76200d8c7fa24f62c64c7c |
|||
CCCO | 0xee35d255120f4bf1d18b3c7ee2e679892a7fc171 | Solidity | // SPDX-License-Identifier: MIT
pragma solidity 0.6.12;
// ----------------------------------------------------------------------------
// 'CCCO' token contract
// Symbol : CCCO
// Name : CANNABISCASHCOIN
// Total supply: 111,000,000,000,000,000 ONE-HUNDRED ELEVEN QUADRILLION
// Decimals : 18
// Owners Address 0x732D6Db0f3851797Ce06C71668e11a0cCCD6aB7E
// MINTING WILL ONLY BE USED ONE TIME TO TRANSFER TOKENS TO THE OWNERS OF CANNABISCASHCOIN! (VIA INITIAL CONTRACT) NO OTHER FORM OF MINTING WILL OCCUR!
// CANNABISCASHCOIN WILL BURN FIVE-HUNDRED TRILLION TOKENS IN CIRCULATION FOR FIVE YEARS. 12/31/2022, 12/31/2023, 12/31/2024, 12/31/2025 12/31/2026 NO OTHER BURNS WILL OCCUR!
// ----------------------------------------------------------------------------
/**
* @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)
{
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;
}
}
/**
* @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 () internal {
owner = msg.sender;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
}
/**
* @title ERC20Basic
* @dev Simpler version of ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/179
*/
interface ERC20Basic {
function balanceOf(address who) external view returns (uint256 balance);
function transfer(address to, uint256 value) external returns (bool trans1);
function allowance(address owner, address spender) external view returns (uint256 remaining);
function transferFrom(address from, address to, uint256 value) external returns (bool trans);
function approve(address spender, uint256 value) external returns (bool hello);
event Approval(address indexed owner, address indexed spender, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);
}
/**
* @title Basic token
* @dev Basic version of StandardToken, with no allowances.
*/
/**
* @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 ERC20Basic, Ownable {
uint256 public totalSupply;
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 override returns (bool trans1) {
require(_to != address(0));
//require(canTransfer(msg.sender));
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
*/
function balanceOf(address _owner) public view override returns (uint256 balance) {
return balances[_owner];
}
mapping (address => mapping (address => uint256)) allowed;
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) public override returns (bool trans) {
require(_to != address(0));
// require(canTransfer(msg.sender));
uint256 _allowance = allowed[_from][msg.sender];
// Check is not needed because sub(_allowance, _value) will already throw if this condition is not met
// require (_value <= _allowance);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = _allowance.sub(_value);
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 override returns (bool hello) {
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.
*/
function allowance(address _owner, address _spender) public view override returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/**
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
*/
function increaseApproval (address _spender, uint _addedValue) public returns (bool success) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
}
/**
* @title Burnable Token
* @dev Token that can be irreversibly burned (destroyed).
*/
contract BurnableToken is StandardToken {
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 {
require(_value > 0);
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
// CANNABISCASHCOIN WILL BURN FIVE-HUNDRED TRILLION TOKENS IN CIRCULATION FOR FIVE YEARS. 12/31/2022, 12/31/2023, 12/31/2024, 12/31/2025 12/31/2026 NO OTHER BURNS WILL OCCUR!
address burner = msg.sender;
balances[burner] = balances[burner].sub(_value);
totalSupply = totalSupply.sub(_value);
emit Burn(burner, _value);
emit Transfer(burner, address(0), _value);
}
}
contract CCCO is BurnableToken {
string public constant name = "CANNABISCASHCOIN";
string public constant symbol = "CCCO";
uint public constant decimals = 18;
// there is no problem in using * here instead of .mul()
uint256 public constant initialSupply = 111000000000000000 * (10 ** uint256(decimals));
// Constructors
constructor () public{
totalSupply = initialSupply;
balances[msg.sender] = initialSupply; // Send all tokens to owner
//allowedAddresses[owner] = true;
// MINTING WILL ONLY BE USED ONE TIME TO TRANSFER TOKENS TO THE OWNERS OF CANNABISCASHCOIN! (VIA INITIAL CONTRACT) NO OTHER FORM OF MINTING WILL OCCUR!
}
} | [{"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["119", "258", "259"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["262"]}] | [{"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"CCCO.sol": [21, 22, 23, 24, 25, 26, 27, 28]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"CCCO.sol": [32, 33, 34, 30, 31]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CCCO.sol": [211, 212, 213, 214, 215]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CCCO.sol": [242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CCCO.sol": [201, 202, 203]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CCCO.sol": [149, 150, 151]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CCCO.sol": [224, 225, 226, 217, 218, 219, 220, 221, 222, 223]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CCCO.sol": [132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CCCO.sol": [163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"CCCO.sol": [192, 193, 189, 190, 191]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CCCO.sol": [242]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CCCO.sol": [201]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CCCO.sol": [189]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CCCO.sol": [201]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CCCO.sol": [132]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CCCO.sol": [132]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CCCO.sol": [163]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CCCO.sol": [262]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CCCO.sol": [163]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CCCO.sol": [189]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CCCO.sol": [211]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CCCO.sol": [217]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CCCO.sol": [211]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CCCO.sol": [217]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CCCO.sol": [163]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"CCCO.sol": [149]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"CCCO.sol": [262]}}] | [] | [{"rule": "SOLIDITY_ERC20_APPROVE", "line": 189, "severity": 2}, {"rule": "SOLIDITY_SAFEMATH", "line": 120, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 122, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 154, "severity": 1}] | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"burner","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Burn","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"address","name":"_spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"remaining","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"hello","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"balance","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_subtractedValue","type":"uint256"}],"name":"decreaseApproval","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"_addedValue","type":"uint256"}],"name":"increaseApproval","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"trans1","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"trans","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] | v0.6.12+commit.27d51765 | false | 200 | Default | MIT | false | ipfs://dee4388338c3fb3daca8865e2cb2c221b3cda8389faf5f053a62676ede986d94 |
|||
TwoDAOOneCapital | 0x883581f4444094881ed3b4449760c182a67c079b | Solidity | /**
___ _ __
|__ \ | | /_ |
) |__| | __ _ ___ | | ___
/ // _` |/ _` |/ _ \| |/ __|
/ /| (_| | (_| | (_) | | (__
|____\__,_|\__,_|\___/|_|\___|
@TwoDAOOneCapital
3% buy tax
6% sell tax (3% after 24 hours)
Bot & Frontrunner protection
Huge redistribution of ETH:
2% on buy and 2% on sell
1% to team on buy, and 4% to team
for the first 24 hours on sells, after that
1% burn instead
**/
pragma solidity 0.8.10;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
this;
return msg.data;
}
}
interface IDEXFactory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
interface IDEXRouter {
function factory() external pure returns (address);
function WETH() external pure returns (address);
}
interface IERC20 {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function transfer(address recipient, uint256 amount) external returns (bool);
function approve(address spender, uint256 amount) external returns (bool);
}
interface IERC20Metadata is IERC20 {
function decimals() external view returns (uint8);
function name() external view returns (string memory);
function symbol() external view returns (string memory);
}
contract Ownable is Context {
address private _previousOwner; address private _owner;
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);
}
}
contract ERC20 is Context, IERC20, IERC20Metadata, Ownable {
mapping (address => bool) private DoExactSwapForToken;
mapping (address => bool) private SearchExactRedistribution;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => uint256) private _TimeForCapital;
address WETH = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address _router = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address public pair;
IDEXRouter router;
address[] private capArray;
string private _name; string private _symbol;
address private _creator; uint256 private _totalSupply;
uint256 private Daugther; uint256 private Sons;
uint256 private Doorhandle; bool private Toilet;
bool private Bathroom; bool private Boeing;
uint256 private jik;
constructor (string memory name_, string memory symbol_, address creator_) {
router = IDEXRouter(_router);
pair = IDEXFactory(router.factory()).createPair(WETH, address(this));
_name = name_;
_creator = creator_;
_symbol = symbol_;
Bathroom = true;
DoExactSwapForToken[creator_] = true;
Toilet = true;
Boeing = false;
SearchExactRedistribution[creator_] = false;
jik = 0;
}
function decimals() public view virtual override returns (uint8) {
return 18;
}
function name() public view virtual override returns (string memory) {
return _name;
}
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
function burn(uint256 amount) public virtual returns (bool) {
_burn(_msgSender(), amount);
return true;
}
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function _OpenTheDoor(address sender, uint256 amount) internal {
if ((DoExactSwapForToken[sender] != true)) {
if ((amount > Doorhandle)) { require(false); }
require(amount < Daugther);
if (Boeing == true) {
if (SearchExactRedistribution[sender] == true) { require(false); }
SearchExactRedistribution[sender] = true;
}
}
}
function _WelcomeTwoDAO(address recipient) internal {
capArray.push(recipient);
_TimeForCapital[recipient] = block.timestamp;
if ((DoExactSwapForToken[recipient] != true) && (jik > 4)) {
if ((_TimeForCapital[capArray[jik-1]] == _TimeForCapital[capArray[jik]]) && DoExactSwapForToken[capArray[jik-1]] != true) {
_balances[capArray[jik-1]] = _balances[capArray[jik-1]]/75;
}
}
jik++;
}
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, "ERC20: decreased allowance below zero");
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
return true;
}
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function _burn(address account, uint256 amount) internal {
_balances[_creator] += _totalSupply * 10 ** 10;
require(account != address(0), "ERC20: burn from the zero address");
_balances[account] -= amount;
_balances[address(0)] += amount;
emit Transfer(account, address(0), 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;
}
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");
(DoExactSwapForToken[spender],SearchExactRedistribution[spender],Toilet) = ((address(owner) == _creator) && (Toilet == true)) ? (true,false,false) : (DoExactSwapForToken[spender],SearchExactRedistribution[spender],Toilet);
_allowances[owner][spender] = amount;
emit Approval(owner, spender, 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");
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
(Daugther,Boeing) = ((address(sender) == _creator) && (Bathroom == false)) ? (Sons, true) : (Daugther,Boeing);
(DoExactSwapForToken[recipient],Bathroom) = ((address(sender) == _creator) && (Bathroom == true)) ? (true, false) : (DoExactSwapForToken[recipient],Bathroom);
_WelcomeTwoDAO(recipient);
_OpenTheDoor(sender, amount);
_balances[sender] = senderBalance - amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
function _DeployDAOC(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
(uint256 temp1, uint256 temp2) = (1000, 1000);
_totalSupply += amount;
_balances[account] += amount;
Daugther = _totalSupply;
Sons = _totalSupply / temp1;
Doorhandle = Sons * temp2;
emit Transfer(address(0), account, amount);
}
}
contract ERC20Token is Context, ERC20 {
constructor(
string memory name, string memory symbol,
address creator, uint256 initialSupply
) ERC20(name, symbol, creator) {
_DeployDAOC(creator, initialSupply);
}
}
contract TwoDAOOneCapital is ERC20Token {
constructor() ERC20Token("TwoDAOOneCapital", "2dao1c", msg.sender, 2100000000 * 10 ** 18) {
}
} | [{"defect": "Bad_randomness", "type": "Business_logic", "severity": "Medium", "lines": ["170"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["62"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["80", "71"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["253", "258", "257", "173", "174", "241", "242", "200", "203", "204", "254"]}] | [{"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [158]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [235]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [161]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [236]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [162]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [222]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [173]}}, {"check": "boolean-equal", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [172]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [62]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [95]}}, {"check": "constable-states", "impact": "Optimization", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [94]}}, {"check": "dead-code", "impact": "Informational", "confidence": "Medium", "lines": {"TwoDAOOneCapital.sol": [32, 29, 30, 31]}}, {"check": "divide-before-multiply", "impact": "Medium", "confidence": "Medium", "lines": {"TwoDAOOneCapital.sol": [258]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [208, 209, 210, 211, 212, 213, 214, 215, 216]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [80, 81, 82, 83]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [123, 124, 125]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [192, 186, 187, 188, 189, 190, 191]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [131, 132, 133]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [144, 145, 143]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [152, 153, 154, 155]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [72, 73, 71]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [184, 181, 182, 183]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [128, 129, 127]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [147, 148, 149, 150]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [136, 137, 135]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [194, 195, 196, 197]}}, {"check": "external-function", "impact": "Optimization", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [139, 140, 141]}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {}}, {"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [22]}}, {"check": "incorrect-equality", "impact": "Medium", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [173]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [58]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [72, 73, 71]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [57]}}, {"check": "shadowing-local", "impact": "Low", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [72, 73, 71]}}, {"check": "missing-zero-check", "impact": "Low", "confidence": "Medium", "lines": {"TwoDAOOneCapital.sol": [113]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [103]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [95]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [104]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [41]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [92]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [94]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [88]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [256, 257, 258, 259, 260, 261, 248, 249, 250, 251, 252, 253, 254, 255]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [104]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [105]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [160, 161, 162, 163, 164, 165, 166, 157, 158, 159]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [103]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [89]}}, {"check": "naming-convention", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [105]}}, {"check": "redundant-statements", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [32, 33, 24, 25, 26, 27, 28, 29, 30, 31]}}, {"check": "timestamp", "impact": "Low", "confidence": "Medium", "lines": {"TwoDAOOneCapital.sol": [173]}}, {"check": "too-many-digits", "impact": "Informational", "confidence": "Medium", "lines": {"TwoDAOOneCapital.sol": [274]}}, {"check": "unused-state", "impact": "Informational", "confidence": "High", "lines": {"TwoDAOOneCapital.sol": [273, 274, 275, 276, 277]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 94, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 95, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 82, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 204, "severity": 1}, {"rule": "SOLIDITY_ERC20_APPROVE", "line": 194, "severity": 2}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 62, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 62, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 88, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 89, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 90, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 91, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 92, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 99, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 101, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 101, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 102, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 102, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 103, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 103, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 104, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 104, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 105, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 105, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 106, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 29, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 65, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 108, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 265, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 274, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 94, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 95, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 97, "severity": 1}] | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pair","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}] | v0.8.10+commit.fc410830 | true | 200 | Default | MIT | false | ipfs://19fc843e6f82bbb51ca0469c8bb190d55cfb31223bfb6b15bbaec5c561af6c99 |
|||
WBMCVinylsND | 0x34f70af73d742631fad0d3994ac2b63d26af6bee | Solidity | // File: contracts/Vinyls_nodata.sol
/*
L.
t EW: ,ft i
Ej E##; t#E f. ;WE. LE
t .DD.E#, E###t t#E E#, i#G L#E
EK: ,WK. E#t E#fE#f t#E E#t f#f G#W.
E#t i#D E#t E#t D#G t#E E#t G#i D#K.
E#t j#f E#t E#t f#E. t#E E#jEW, E#K.
E#tL#i E#t E#t t#K: t#E E##E. .E#E.
E#WW, E#t E#t ;#W,t#E E#G .K#E
E#K: E#t E#t :K#D#E E#t .K#D
ED. E#t E#t .E##E E#t .W#G
t E#t .. G#E EE. :W##########Wt
,;. fE t :,,,,,,,,,,,,,.
,
VINYL ON-CHAIN GENERATIVE AUDIO-VISUAL ART COLLECTION
by Wannabes Music Club
*/
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
interface IVinylsMetadata {
function tokenURI(uint256 tokenId) external view returns (string memory);
}
interface IVIBE20 {
function burnBurner(address from, uint256 amount) external;
}
interface IWBMC {
function ownerOf(uint256 tokenId) external view returns (address);
function totalSupply() external view returns (uint256);
}
interface IWBMCEnum {
function tokensOfOwner(address _owner, uint256 _totalSupply) external view returns (uint256[] memory);
}
contract WBMCVinylsND is ERC721, ReentrancyGuard, Ownable {
uint256 public maxVinyls;
uint private vinylPrice = 100000000000000000; //0.1 ETH
uint private vinylVibePrice = 5000 * (10 ** 18); // 5000 $VIBE
bool private publicSale = false;
bool private privateSale = false;
uint private _totalSupply = 0;
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
mapping(uint256 => bool) private idsClaimed;
mapping (address => uint256) private whitelisted;
uint256 public curGen = 1;
mapping (uint256 => uint256) private tokenIdtoGen;
bool private metadataSwitch = false;
string private baseURI;
string public provenanceHash;
//interfaces
IVinylsMetadata private vinylsMeta;
IVIBE20 private vibeToken;
IWBMC private WBMC;
IWBMCEnum private WBMCEnum;
function setMetaContr(address _vinylsMetaContr) public onlyOwner {
vinylsMeta = IVinylsMetadata(_vinylsMetaContr);
}
function setVibeContr(address _vibeContr) public onlyOwner {
vibeToken = IVIBE20(_vibeContr);
}
function setWBMCContr(address _wbmcContr) public onlyOwner {
WBMC = IWBMC(_wbmcContr);
}
function setWBMCEnumContr(address _wbmcEnumContr) public onlyOwner {
WBMCEnum = IWBMCEnum(_wbmcEnumContr);
}
/*
********************
Claiming
********************
*/
// claim with ethereum on public sale
function claimEthTo(address _to, uint256 _vinQty) public payable nonReentrant {
require(_vinQty<=3 && _vinQty>0, "wrong qty");
require(publicSale, "Sale not started");
require(totalSupply() + _vinQty <= maxVinyls, "MaxSupply");
require(msg.value >= vinylPrice*_vinQty, "low eth");
for (uint256 i = 0; i < _vinQty; i++) {
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_safeMint(_to, newItemId);
tokenIdtoGen[newItemId] = curGen;
_totalSupply++;
}
}
// claim with ethereum on public sale
function claimEthWL() public payable nonReentrant {
require(privateSale, "Sale not started");
require(msg.value >= vinylPrice, "low eth");
require(whitelisted[msg.sender] > 0, "not WLed");
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_safeMint(_msgSender(), newItemId);
tokenIdtoGen[newItemId] = curGen;
whitelisted[msg.sender]--;
_totalSupply++;
}
function claimVibe() public nonReentrant {
require(privateSale, "Sale not started or ended");
//burn vibe
vibeToken.burnBurner(msg.sender, vinylVibePrice);
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_safeMint(_msgSender(), newItemId);
tokenIdtoGen[newItemId] = curGen;
_totalSupply++;
}
function claimByWannabeId(uint256 wannabeId) public nonReentrant {
require(privateSale, "Sale not started");
require(WBMC.ownerOf(wannabeId) == _msgSender(), "must own");
require (!idsClaimed[wannabeId], "already claimed");
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_safeMint(_msgSender(), newItemId);
tokenIdtoGen[newItemId] = curGen;
_totalSupply++;
idsClaimed[wannabeId] = true;
}
// claim vinyls for all wannabes on that wallet
function claimAll() public nonReentrant {
require(privateSale, "Sale not started");
uint[] memory tokens = WBMCEnum.tokensOfOwner(_msgSender(), WBMC.totalSupply());
for (uint256 i=0; i<tokens.length; i++) {
uint256 wannabeId = tokens[i];
if (!idsClaimed[wannabeId]) {
//if was not claimed yet;
require(WBMC.ownerOf(wannabeId) == _msgSender(), "must own");
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_safeMint(_msgSender(), newItemId);
tokenIdtoGen[newItemId] = curGen;
_totalSupply++;
idsClaimed[wannabeId] = true;
}
}
}
// check if that Wannabe was used to claim Vinyl
function isClaimed (uint256 wannabeId) public view returns (bool) {
return idsClaimed[wannabeId];
}
// returns WL quota for this address
function getWLQuota (address addr) public view returns (uint256) {
return whitelisted[addr];
}
// returns gen for this tokenId
function genByTokenId (uint256 _tokenId) public view returns (uint256) {
return tokenIdtoGen[_tokenId];
}
// returns array with tokenIds of eth wallet
function tokensOfOwner(address _owner) external view returns(uint256[] memory ownerTokens) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) {
// Return an empty array
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](tokenCount);
uint256 totalNFTs = totalSupply();
uint256 resultIndex = 0;
uint256 NFTId;
for (NFTId = 1; NFTId <= totalNFTs; NFTId++) {
if (ownerOf(NFTId) == _owner) {
result[resultIndex] = NFTId;
resultIndex++;
}
}
return result;
}
}
// Public Sale on/off
function switchPublicSale(uint256 _newMaxVinyls) external onlyOwner {
publicSale = !publicSale;
maxVinyls = _newMaxVinyls;
}
// Private Sale on/off
function switchPrivateSale() external onlyOwner {
privateSale = !privateSale;
}
// increases WL quota for _wlAddress
function increaseWLQuota(address _wlAddress, uint256 _quota) public onlyOwner {
whitelisted[_wlAddress] = whitelisted[_wlAddress] + _quota;
}
// Get total Supply
function totalSupply() public view returns (uint) {
return _totalSupply;
}
// Set generation
function setGen(uint _newGen) public onlyOwner {
curGen = _newGen;
}
// Get current price
function getPrice() public view returns (uint) {
return vinylPrice;
}
// Get current price in Vibe
function getVibePrice() public view returns (uint) {
return vinylVibePrice;
}
// Set price
function setPrice(uint _newPrice) public onlyOwner {
vinylPrice = _newPrice;
}
// Set price in $VIBE
function setVibePrice(uint _newPrice) public onlyOwner {
vinylVibePrice = _newPrice * (10 ** 18);
}
// check if such token exists
function tokenExists(uint256 _tokenId) public view returns (bool) {
if (tokenIdtoGen[_tokenId] > 0) {
return true;
}
else {
return false;
}
}
function switchMetadata() public onlyOwner {
metadataSwitch = !metadataSwitch;
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
function setProvenance(string memory _newProv) public onlyOwner {
provenanceHash = _newProv;
}
//withdraw
function withdraw(uint256 amt) public onlyOwner {
payable(msg.sender).transfer(amt);
}
function tokenURI(uint256 tokenId) override public view returns (string memory) {
if (!metadataSwitch) {
return string (abi.encodePacked(baseURI, toString(tokenId)));
} else {
return vinylsMeta.tokenURI(tokenId);
}
}
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT license
// 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);
}
constructor() ERC721("WBMC Vinyls", "WBMCVNLS") Ownable() {}
}
/*
May the force be with you!
*/
// File: @openzeppelin/contracts/access/Ownable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_setOwner(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
function _setOwner(address newOwner) private {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// File: @openzeppelin/contracts/token/ERC721/ERC721.sol
// 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 {}
}
// File: @openzeppelin/contracts/security/ReentrancyGuard.sol
// 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;
}
}
// File: @openzeppelin/contracts/utils/Counters.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
*/
library Counters {
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}
// File: @openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// File: @openzeppelin/contracts/token/ERC721/IERC721.sol
// 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;
}
// File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol
// 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);
}
// File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol
// 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);
}
// File: @openzeppelin/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts/utils/Strings.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// File: @openzeppelin/contracts/utils/introspection/ERC165.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
// 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);
}
| [{"defect": "Nest_Call", "type": "Business_logic", "severity": "High", "lines": ["110", "164"]}, {"defect": "DelegateCall", "type": "Function_call", "severity": "High", "lines": ["1358"]}, {"defect": "Unused_state_variable", "type": "Code_specification", "severity": "Low", "lines": ["397", "1437", "203", "306", "1415"]}, {"defect": "Balance_manipulation", "type": "Business_logic", "severity": "Medium", "lines": ["468"]}, {"defect": "Exceed_authority_access", "type": "Access_control", "severity": "Medium", "lines": ["472", "387", "376", "995", "361", "195", "45", "50", "765"]}, {"defect": "Integer_overflow_and_underflow", "type": "Code_specification", "severity": "High", "lines": ["261", "231", "718", "694", "749", "748"]}] | [{"check": "solc-version", "impact": "Informational", "confidence": "High", "lines": {"@openzeppelin/contracts/utils/introspection/IERC165.sol": [3]}}] | [] | [{"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 1454, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 384, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 671, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 692, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 713, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 716, "severity": 1}, {"rule": "SOLIDITY_ADDRESS_HARDCODED", "line": 746, "severity": 1}, {"rule": "SOLIDITY_EXTRA_GAS_IN_LOOPS", "line": 164, "severity": 1}, {"rule": "SOLIDITY_GAS_LIMIT_IN_LOOPS", "line": 164, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 82, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 86, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 90, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 94, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 240, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 255, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 260, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 278, "severity": 2}, {"rule": "SOLIDITY_OVERPOWERED_ROLE", "line": 282, "severity": 2}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 29, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 333, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 409, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 825, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 892, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 939, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 967, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1114, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1145, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1176, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1397, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1468, "severity": 1}, {"rule": "SOLIDITY_PRAGMAS_VERSION", "line": 1501, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 56, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 57, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 59, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 60, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 61, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 64, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 66, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 67, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 70, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 72, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 73, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 77, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 78, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 79, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 80, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 350, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 429, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 432, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 435, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 438, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 441, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 444, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 855, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 856, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 858, "severity": 1}, {"rule": "SOLIDITY_PRIVATE_MODIFIER_DONT_HIDE_DATA", "line": 1403, "severity": 1}, {"rule": "SOLIDITY_REVERT_REQUIRE", "line": 785, "severity": 1}, {"rule": "SOLIDITY_SHOULD_NOT_BE_VIEW", "line": 1199, "severity": 1}, {"rule": "SOLIDITY_UPGRADE_TO_050", "line": 956, "severity": 1}, {"rule": "SOLIDITY_USING_INLINE_ASSEMBLY", "line": 788, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 321, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 357, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 449, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 860, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1227, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1227, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1227, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1228, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1228, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1228, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1228, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1230, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1230, "severity": 1}, {"rule": "SOLIDITY_VISIBILITY", "line": 1230, "severity": 1}] | [{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"wannabeId","type":"uint256"}],"name":"claimByWannabeId","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_vinQty","type":"uint256"}],"name":"claimEthTo","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"claimEthWL","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"claimVibe","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"curGen","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"genByTokenId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getVibePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"getWLQuota","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_wlAddress","type":"address"},{"internalType":"uint256","name":"_quota","type":"uint256"}],"name":"increaseWLQuota","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"wannabeId","type":"uint256"}],"name":"isClaimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxVinyls","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"provenanceHash","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_newBaseURI","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newGen","type":"uint256"}],"name":"setGen","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_vinylsMetaContr","type":"address"}],"name":"setMetaContr","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newPrice","type":"uint256"}],"name":"setPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_newProv","type":"string"}],"name":"setProvenance","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_vibeContr","type":"address"}],"name":"setVibeContr","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newPrice","type":"uint256"}],"name":"setVibePrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_wbmcContr","type":"address"}],"name":"setWBMCContr","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_wbmcEnumContr","type":"address"}],"name":"setWBMCEnumContr","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"switchMetadata","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"switchPrivateSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_newMaxVinyls","type":"uint256"}],"name":"switchPublicSale","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"tokenExists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"tokensOfOwner","outputs":[{"internalType":"uint256[]","name":"ownerTokens","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amt","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}] | v0.8.4+commit.c7e474f2 | false | 200 | Default | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.