contract_name
stringlengths 1
61
| file_path
stringlengths 5
50.4k
| contract_address
stringlengths 42
42
| language
stringclasses 1
value | class_name
stringlengths 1
61
| class_code
stringlengths 4
330k
| class_documentation
stringlengths 0
29.1k
| class_documentation_type
stringclasses 6
values | func_name
stringlengths 0
62
| func_code
stringlengths 1
303k
| func_documentation
stringlengths 2
14.9k
| func_documentation_type
stringclasses 4
values | compiler_version
stringlengths 15
42
| license_type
stringclasses 14
values | swarm_source
stringlengths 0
71
| meta
dict | __index_level_0__
int64 0
60.4k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
FavorUSD | ClaimableOwnable.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | ClaimableOwnable | contract ClaimableOwnable is ProxyStorage {
/**
* @dev emitted when ownership is transferred
* @param previousOwner previous owner of this contract
* @param newOwner new owner of this contract
*/
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev sets the original `owner` of the contract to the sender
* at construction. Must then be reinitialized
*/
constructor() {
owner = msg.sender;
emit OwnershipTransferred(address(0), owner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner, "only Owner");
_;
}
/**
* @dev Modifier throws if called by any account other than the pendingOwner.
*/
modifier onlyPendingOwner() {
require(msg.sender == pendingOwner, "only pending owner");
_;
}
/**
* @dev Allows the current owner to set the pendingOwner address.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
pendingOwner = newOwner;
}
/**
* @dev Allows the pendingOwner address to finalize the transfer.
*/
function claimOwnership() public onlyPendingOwner {
emit OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
pendingOwner = address(0);
}
} | /**
* @title ClamableOwnable
* @dev The ClamableOwnable contract is a copy of Claimable Contract by Zeppelin.
* and provides basic authorization control functions. Inherits storage layout of
* ProxyStorage.
*/ | NatSpecMultiLine | transferOwnership | function transferOwnership(address newOwner) public onlyOwner {
pendingOwner = newOwner;
}
| /**
* @dev Allows the current owner to set the pendingOwner address.
* @param newOwner The address to transfer ownership to.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
1098,
1204
]
} | 9,400 |
FavorUSD | ClaimableOwnable.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | ClaimableOwnable | contract ClaimableOwnable is ProxyStorage {
/**
* @dev emitted when ownership is transferred
* @param previousOwner previous owner of this contract
* @param newOwner new owner of this contract
*/
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev sets the original `owner` of the contract to the sender
* at construction. Must then be reinitialized
*/
constructor() {
owner = msg.sender;
emit OwnershipTransferred(address(0), owner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(msg.sender == owner, "only Owner");
_;
}
/**
* @dev Modifier throws if called by any account other than the pendingOwner.
*/
modifier onlyPendingOwner() {
require(msg.sender == pendingOwner, "only pending owner");
_;
}
/**
* @dev Allows the current owner to set the pendingOwner address.
* @param newOwner The address to transfer ownership to.
*/
function transferOwnership(address newOwner) public onlyOwner {
pendingOwner = newOwner;
}
/**
* @dev Allows the pendingOwner address to finalize the transfer.
*/
function claimOwnership() public onlyPendingOwner {
emit OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
pendingOwner = address(0);
}
} | /**
* @title ClamableOwnable
* @dev The ClamableOwnable contract is a copy of Claimable Contract by Zeppelin.
* and provides basic authorization control functions. Inherits storage layout of
* ProxyStorage.
*/ | NatSpecMultiLine | claimOwnership | function claimOwnership() public onlyPendingOwner {
emit OwnershipTransferred(owner, pendingOwner);
owner = pendingOwner;
pendingOwner = address(0);
}
| /**
* @dev Allows the pendingOwner address to finalize the transfer.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
1292,
1474
]
} | 9,401 |
CoolFrens | contracts/CoolFrens.sol | 0xb9cd19a3e2422dc900c88ecd1fb29a7ad2399941 | Solidity | CoolFrens | contract CoolFrens is Ownable, ERC721A, ReentrancyGuard {
constructor(
uint256 maxBatchSize_,
uint256 collectionSize_,
uint256 amountForAuctionAndDev_,
uint256 amountForDevs_
) ERC721A("CoolFrens", "CoolFrens", maxBatchSize_, collectionSize_) {
require(amountForAuctionAndDev_ <= collectionSize_, "larger collection size needed" );
}
uint256 public pricePerWL = 0.04 ether;
uint256 public pricePerPublic = 0.06 ether;
bool public presaleLive = true;
bool public publicLive = false;
address private ownerAddy = 0x74701CA166857B83bB2F5Eb9420aF938E39088E8;
mapping(address => uint256) public WLminted;
/*
* @dev Requires msg.sender to have valid access message.
* @param _v ECDSA signature parameter v.
* @param _r ECDSA signature parameters r.
* @param _s ECDSA signature parameters s.
*/
modifier noInvalidAccess(uint8 _v, bytes32 _r, bytes32 _s) {
require(!isInvalidAccessMessage(_v,_r,_s) );
_;
}
/*
* @dev Verifies if message was signed by owner to give access to _add for this contract.
* Assumes Geth signature prefix.
* @param _add Address of agent with access
* @param _v ECDSA signature parameter v.
* @param _r ECDSA signature parameters r.
* @param _s ECDSA signature parameters s.
* @return Validity of access message for a given address.
*/
function isInvalidAccessMessage(
uint8 _v,
bytes32 _r,
bytes32 _s)
view public returns (bool)
{
bytes32 hash = keccak256(abi.encodePacked(this));
address signAddress = ecrecover(
keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)),
_v,
_r,
_s
);
if (ownerAddy == signAddress){
return true;
}
else{
return false;
}
}
function setPreSale(bool status) public onlyOwner{
presaleLive = status;
}
function setPublicSalePrice(bool status) public onlyOwner{
publicLive = status;
}
function setPreSale(uint256 price) public onlyOwner{
pricePerWL = price;
}
function setPublicSalePrice(uint256 price) public onlyOwner{
pricePerPublic = price;
}
/*
* @dev Public Sale Mint
* @param quantity Number of NFT's to be minted at 0.06 with a max of 10 per transaction. This is a gas efficient function.
*/
function mint(uint256 quantity) external payable {
require(quantity <= 10, "Cant mint more than 10");
require(totalSupply() + quantity <= 3183, "Sold out");
require(msg.value >= pricePerPublic * quantity, "Not enough Eth");
require(publicLive, "sale not live");
_safeMint(msg.sender, quantity);
}
function mintMarketing(address to, uint256 quantity) external payable onlyOwner {
require(quantity <= 10, "Cant mint more than 10");
require(totalSupply() + quantity <= 3333, "Sold out");
require(publicLive, "sale not live");
_safeMint(to, quantity);
}
/*
* @dev Verifies if message was signed by owner to give access to this contract.
* Assumes Geth signature prefix.
* @param quantity Number of NFT's to be minted at 0.04 with a max of 3. This is a gas efficient function.
* @param _v ECDSA signature parameter v.
* @param _r ECDSA signature parameters r.
* @param _s ECDSA signature parameters s.
*/
function mintWL(uint256 quantity, uint8 _v, bytes32 _r, bytes32 _s) external payable noInvalidAccess(_v, _r, _s){
require(quantity <= 3, "Cant mint more than 3");
require(totalSupply() + quantity <= 3183, "Sold out");
require(msg.value >= pricePerWL * quantity, "Not enough Eth");
require(presaleLive, "sale not live");
require(WLminted[msg.sender] + quantity <= 3, "Cant mint more than 3");
WLminted[msg.sender] += quantity;
_safeMint(msg.sender, quantity);
}
// // metadata URI
string private _baseTokenURI;
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
function setBaseURI(string calldata baseURI) external onlyOwner {
_baseTokenURI = baseURI;
}
function withdrawMoney() external onlyOwner nonReentrant {
(bool success, ) = msg.sender.call{value: address(this).balance}("");
require(success, "Transfer failed.");
}
function setOwnersExplicit(uint256 quantity) external onlyOwner nonReentrant {
_setOwnersExplicit(quantity);
}
function numberMinted(address owner) public view returns (uint256) {
return _numberMinted(owner);
}
function getOwnershipData(uint256 tokenId)
external
view
returns (TokenOwnership memory)
{
return ownershipOf(tokenId);
}
} | isInvalidAccessMessage | function isInvalidAccessMessage(
uint8 _v,
bytes32 _r,
bytes32 _s)
view public returns (bool)
{
bytes32 hash = keccak256(abi.encodePacked(this));
address signAddress = ecrecover(
keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)),
_v,
_r,
_s
);
if (ownerAddy == signAddress){
return true;
}
else{
return false;
}
}
| /*
* @dev Verifies if message was signed by owner to give access to _add for this contract.
* Assumes Geth signature prefix.
* @param _add Address of agent with access
* @param _v ECDSA signature parameter v.
* @param _r ECDSA signature parameters r.
* @param _s ECDSA signature parameters s.
* @return Validity of access message for a given address.
*/ | Comment | v0.8.7+commit.e28d00a7 | MIT | ipfs://ae6fb218b84b9b1766c1e8176fd5d9fa4af34d5595aac14b93f5615a13cf2c79 | {
"func_code_index": [
1442,
1966
]
} | 9,402 |
||
CoolFrens | contracts/CoolFrens.sol | 0xb9cd19a3e2422dc900c88ecd1fb29a7ad2399941 | Solidity | CoolFrens | contract CoolFrens is Ownable, ERC721A, ReentrancyGuard {
constructor(
uint256 maxBatchSize_,
uint256 collectionSize_,
uint256 amountForAuctionAndDev_,
uint256 amountForDevs_
) ERC721A("CoolFrens", "CoolFrens", maxBatchSize_, collectionSize_) {
require(amountForAuctionAndDev_ <= collectionSize_, "larger collection size needed" );
}
uint256 public pricePerWL = 0.04 ether;
uint256 public pricePerPublic = 0.06 ether;
bool public presaleLive = true;
bool public publicLive = false;
address private ownerAddy = 0x74701CA166857B83bB2F5Eb9420aF938E39088E8;
mapping(address => uint256) public WLminted;
/*
* @dev Requires msg.sender to have valid access message.
* @param _v ECDSA signature parameter v.
* @param _r ECDSA signature parameters r.
* @param _s ECDSA signature parameters s.
*/
modifier noInvalidAccess(uint8 _v, bytes32 _r, bytes32 _s) {
require(!isInvalidAccessMessage(_v,_r,_s) );
_;
}
/*
* @dev Verifies if message was signed by owner to give access to _add for this contract.
* Assumes Geth signature prefix.
* @param _add Address of agent with access
* @param _v ECDSA signature parameter v.
* @param _r ECDSA signature parameters r.
* @param _s ECDSA signature parameters s.
* @return Validity of access message for a given address.
*/
function isInvalidAccessMessage(
uint8 _v,
bytes32 _r,
bytes32 _s)
view public returns (bool)
{
bytes32 hash = keccak256(abi.encodePacked(this));
address signAddress = ecrecover(
keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)),
_v,
_r,
_s
);
if (ownerAddy == signAddress){
return true;
}
else{
return false;
}
}
function setPreSale(bool status) public onlyOwner{
presaleLive = status;
}
function setPublicSalePrice(bool status) public onlyOwner{
publicLive = status;
}
function setPreSale(uint256 price) public onlyOwner{
pricePerWL = price;
}
function setPublicSalePrice(uint256 price) public onlyOwner{
pricePerPublic = price;
}
/*
* @dev Public Sale Mint
* @param quantity Number of NFT's to be minted at 0.06 with a max of 10 per transaction. This is a gas efficient function.
*/
function mint(uint256 quantity) external payable {
require(quantity <= 10, "Cant mint more than 10");
require(totalSupply() + quantity <= 3183, "Sold out");
require(msg.value >= pricePerPublic * quantity, "Not enough Eth");
require(publicLive, "sale not live");
_safeMint(msg.sender, quantity);
}
function mintMarketing(address to, uint256 quantity) external payable onlyOwner {
require(quantity <= 10, "Cant mint more than 10");
require(totalSupply() + quantity <= 3333, "Sold out");
require(publicLive, "sale not live");
_safeMint(to, quantity);
}
/*
* @dev Verifies if message was signed by owner to give access to this contract.
* Assumes Geth signature prefix.
* @param quantity Number of NFT's to be minted at 0.04 with a max of 3. This is a gas efficient function.
* @param _v ECDSA signature parameter v.
* @param _r ECDSA signature parameters r.
* @param _s ECDSA signature parameters s.
*/
function mintWL(uint256 quantity, uint8 _v, bytes32 _r, bytes32 _s) external payable noInvalidAccess(_v, _r, _s){
require(quantity <= 3, "Cant mint more than 3");
require(totalSupply() + quantity <= 3183, "Sold out");
require(msg.value >= pricePerWL * quantity, "Not enough Eth");
require(presaleLive, "sale not live");
require(WLminted[msg.sender] + quantity <= 3, "Cant mint more than 3");
WLminted[msg.sender] += quantity;
_safeMint(msg.sender, quantity);
}
// // metadata URI
string private _baseTokenURI;
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
function setBaseURI(string calldata baseURI) external onlyOwner {
_baseTokenURI = baseURI;
}
function withdrawMoney() external onlyOwner nonReentrant {
(bool success, ) = msg.sender.call{value: address(this).balance}("");
require(success, "Transfer failed.");
}
function setOwnersExplicit(uint256 quantity) external onlyOwner nonReentrant {
_setOwnersExplicit(quantity);
}
function numberMinted(address owner) public view returns (uint256) {
return _numberMinted(owner);
}
function getOwnershipData(uint256 tokenId)
external
view
returns (TokenOwnership memory)
{
return ownershipOf(tokenId);
}
} | mint | function mint(uint256 quantity) external payable {
require(quantity <= 10, "Cant mint more than 10");
require(totalSupply() + quantity <= 3183, "Sold out");
require(msg.value >= pricePerPublic * quantity, "Not enough Eth");
require(publicLive, "sale not live");
_safeMint(msg.sender, quantity);
}
| /*
* @dev Public Sale Mint
* @param quantity Number of NFT's to be minted at 0.06 with a max of 10 per transaction. This is a gas efficient function.
*/ | Comment | v0.8.7+commit.e28d00a7 | MIT | ipfs://ae6fb218b84b9b1766c1e8176fd5d9fa4af34d5595aac14b93f5615a13cf2c79 | {
"func_code_index": [
2522,
2849
]
} | 9,403 |
||
CoolFrens | contracts/CoolFrens.sol | 0xb9cd19a3e2422dc900c88ecd1fb29a7ad2399941 | Solidity | CoolFrens | contract CoolFrens is Ownable, ERC721A, ReentrancyGuard {
constructor(
uint256 maxBatchSize_,
uint256 collectionSize_,
uint256 amountForAuctionAndDev_,
uint256 amountForDevs_
) ERC721A("CoolFrens", "CoolFrens", maxBatchSize_, collectionSize_) {
require(amountForAuctionAndDev_ <= collectionSize_, "larger collection size needed" );
}
uint256 public pricePerWL = 0.04 ether;
uint256 public pricePerPublic = 0.06 ether;
bool public presaleLive = true;
bool public publicLive = false;
address private ownerAddy = 0x74701CA166857B83bB2F5Eb9420aF938E39088E8;
mapping(address => uint256) public WLminted;
/*
* @dev Requires msg.sender to have valid access message.
* @param _v ECDSA signature parameter v.
* @param _r ECDSA signature parameters r.
* @param _s ECDSA signature parameters s.
*/
modifier noInvalidAccess(uint8 _v, bytes32 _r, bytes32 _s) {
require(!isInvalidAccessMessage(_v,_r,_s) );
_;
}
/*
* @dev Verifies if message was signed by owner to give access to _add for this contract.
* Assumes Geth signature prefix.
* @param _add Address of agent with access
* @param _v ECDSA signature parameter v.
* @param _r ECDSA signature parameters r.
* @param _s ECDSA signature parameters s.
* @return Validity of access message for a given address.
*/
function isInvalidAccessMessage(
uint8 _v,
bytes32 _r,
bytes32 _s)
view public returns (bool)
{
bytes32 hash = keccak256(abi.encodePacked(this));
address signAddress = ecrecover(
keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)),
_v,
_r,
_s
);
if (ownerAddy == signAddress){
return true;
}
else{
return false;
}
}
function setPreSale(bool status) public onlyOwner{
presaleLive = status;
}
function setPublicSalePrice(bool status) public onlyOwner{
publicLive = status;
}
function setPreSale(uint256 price) public onlyOwner{
pricePerWL = price;
}
function setPublicSalePrice(uint256 price) public onlyOwner{
pricePerPublic = price;
}
/*
* @dev Public Sale Mint
* @param quantity Number of NFT's to be minted at 0.06 with a max of 10 per transaction. This is a gas efficient function.
*/
function mint(uint256 quantity) external payable {
require(quantity <= 10, "Cant mint more than 10");
require(totalSupply() + quantity <= 3183, "Sold out");
require(msg.value >= pricePerPublic * quantity, "Not enough Eth");
require(publicLive, "sale not live");
_safeMint(msg.sender, quantity);
}
function mintMarketing(address to, uint256 quantity) external payable onlyOwner {
require(quantity <= 10, "Cant mint more than 10");
require(totalSupply() + quantity <= 3333, "Sold out");
require(publicLive, "sale not live");
_safeMint(to, quantity);
}
/*
* @dev Verifies if message was signed by owner to give access to this contract.
* Assumes Geth signature prefix.
* @param quantity Number of NFT's to be minted at 0.04 with a max of 3. This is a gas efficient function.
* @param _v ECDSA signature parameter v.
* @param _r ECDSA signature parameters r.
* @param _s ECDSA signature parameters s.
*/
function mintWL(uint256 quantity, uint8 _v, bytes32 _r, bytes32 _s) external payable noInvalidAccess(_v, _r, _s){
require(quantity <= 3, "Cant mint more than 3");
require(totalSupply() + quantity <= 3183, "Sold out");
require(msg.value >= pricePerWL * quantity, "Not enough Eth");
require(presaleLive, "sale not live");
require(WLminted[msg.sender] + quantity <= 3, "Cant mint more than 3");
WLminted[msg.sender] += quantity;
_safeMint(msg.sender, quantity);
}
// // metadata URI
string private _baseTokenURI;
function _baseURI() internal view virtual override returns (string memory) {
return _baseTokenURI;
}
function setBaseURI(string calldata baseURI) external onlyOwner {
_baseTokenURI = baseURI;
}
function withdrawMoney() external onlyOwner nonReentrant {
(bool success, ) = msg.sender.call{value: address(this).balance}("");
require(success, "Transfer failed.");
}
function setOwnersExplicit(uint256 quantity) external onlyOwner nonReentrant {
_setOwnersExplicit(quantity);
}
function numberMinted(address owner) public view returns (uint256) {
return _numberMinted(owner);
}
function getOwnershipData(uint256 tokenId)
external
view
returns (TokenOwnership memory)
{
return ownershipOf(tokenId);
}
} | mintWL | function mintWL(uint256 quantity, uint8 _v, bytes32 _r, bytes32 _s) external payable noInvalidAccess(_v, _r, _s){
require(quantity <= 3, "Cant mint more than 3");
require(totalSupply() + quantity <= 3183, "Sold out");
require(msg.value >= pricePerWL * quantity, "Not enough Eth");
require(presaleLive, "sale not live");
require(WLminted[msg.sender] + quantity <= 3, "Cant mint more than 3");
WLminted[msg.sender] += quantity;
_safeMint(msg.sender, quantity);
}
| /*
* @dev Verifies if message was signed by owner to give access to this contract.
* Assumes Geth signature prefix.
* @param quantity Number of NFT's to be minted at 0.04 with a max of 3. This is a gas efficient function.
* @param _v ECDSA signature parameter v.
* @param _r ECDSA signature parameters r.
* @param _s ECDSA signature parameters s.
*/ | Comment | v0.8.7+commit.e28d00a7 | MIT | ipfs://ae6fb218b84b9b1766c1e8176fd5d9fa4af34d5595aac14b93f5615a13cf2c79 | {
"func_code_index": [
3526,
4027
]
} | 9,404 |
||
YFLinkBalancerYCRVRewards | @openzeppelin/contracts/token/ERC20/IERC20.sol | 0x01877a9b00ae3c7101525721464f3e5840e07f49 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
function mint(address account, uint amount) external;
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | MIT | bzzr://65a743056fd404143f0a496253c8b25cbad227a32a82b92f6085db6ae9b952d3 | {
"func_code_index": [
94,
154
]
} | 9,405 |
YFLinkBalancerYCRVRewards | @openzeppelin/contracts/token/ERC20/IERC20.sol | 0x01877a9b00ae3c7101525721464f3e5840e07f49 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
function mint(address account, uint amount) external;
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | MIT | bzzr://65a743056fd404143f0a496253c8b25cbad227a32a82b92f6085db6ae9b952d3 | {
"func_code_index": [
237,
310
]
} | 9,406 |
YFLinkBalancerYCRVRewards | @openzeppelin/contracts/token/ERC20/IERC20.sol | 0x01877a9b00ae3c7101525721464f3e5840e07f49 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
function mint(address account, uint amount) external;
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | transfer | function transfer(address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | MIT | bzzr://65a743056fd404143f0a496253c8b25cbad227a32a82b92f6085db6ae9b952d3 | {
"func_code_index": [
534,
616
]
} | 9,407 |
YFLinkBalancerYCRVRewards | @openzeppelin/contracts/token/ERC20/IERC20.sol | 0x01877a9b00ae3c7101525721464f3e5840e07f49 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
function mint(address account, uint amount) external;
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | allowance | function allowance(address owner, address spender) external view returns (uint256);
| /**
* @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.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | MIT | bzzr://65a743056fd404143f0a496253c8b25cbad227a32a82b92f6085db6ae9b952d3 | {
"func_code_index": [
958,
1046
]
} | 9,408 |
YFLinkBalancerYCRVRewards | @openzeppelin/contracts/token/ERC20/IERC20.sol | 0x01877a9b00ae3c7101525721464f3e5840e07f49 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
function mint(address account, uint amount) external;
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | approve | function approve(address spender, uint256 amount) external returns (bool);
| /**
* @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.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | MIT | bzzr://65a743056fd404143f0a496253c8b25cbad227a32a82b92f6085db6ae9b952d3 | {
"func_code_index": [
1710,
1789
]
} | 9,409 |
YFLinkBalancerYCRVRewards | @openzeppelin/contracts/token/ERC20/IERC20.sol | 0x01877a9b00ae3c7101525721464f3e5840e07f49 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
function mint(address account, uint amount) external;
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP. Does not include
* the optional functions; to access them see {ERC20Detailed}.
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address sender, address recipient, 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.
*/ | NatSpecMultiLine | v0.5.17+commit.d19bba13 | MIT | bzzr://65a743056fd404143f0a496253c8b25cbad227a32a82b92f6085db6ae9b952d3 | {
"func_code_index": [
2102,
2204
]
} | 9,410 |
TEDFarming | contracts/IRewardDistributionRecipient.sol | 0x3befe5cb43873f3fdbb148b80df7f0f55e843686 | Solidity | TEDFarming | contract TEDFarming is LPTokenWrapper, IRewardDistributionRecipient {
IERC20 public rewardToken;
uint256 public duration = 30 days;
/* Fees breaker, to protect withdraws if anything ever goes wrong */
bool public breaker = false;
mapping(address => uint) public farmLock; // period that your sake it locked to keep it for farming
uint public lock = 0; // farm lock in blocks ~ 0 days for 15s/block
address public admin;
uint256 public periodFinish = 0;
uint256 public rewardRate = 0;
uint256 public lastUpdateTime;
uint256 public rewardPerTokenStored;
mapping(address => uint256) public userRewardPerTokenPaid;
mapping(address => uint256) public rewards;
event RewardAdded(uint256 reward);
event Farmed(address indexed user, uint256 amount);
event Withdrawn(address indexed user, uint256 amount);
event RewardPaid(address indexed user, uint256 reward);
constructor(address _lpToken, address _rewardToken) public LPTokenWrapper(_lpToken) {
admin = msg.sender;
rewardToken = IERC20(_rewardToken);
}
function setBreaker(bool _breaker) external {
require(msg.sender == admin, "admin only");
breaker = _breaker;
}
function setLockTime(uint _lock) external {
require(msg.sender == admin, "admin only");
lock = _lock;
}
modifier updateReward(address account) {
rewardPerTokenStored = rewardPerToken();
lastUpdateTime = lastTimeRewardApplicable();
if (account != address(0)) {
rewards[account] = earned(account);
userRewardPerTokenPaid[account] = rewardPerTokenStored;
}
_;
}
function seize(IERC20 _token, uint amount) external {
require(msg.sender == admin, "admin only");
require(_token != lpToken, "lpToken");
_token.safeTransfer(admin, amount);
}
function lastTimeRewardApplicable() public view returns (uint256) {
return Math.min(block.timestamp, periodFinish);
}
function rewardPerToken() public view returns (uint256) {
if (totalSupply() == 0) {
return rewardPerTokenStored;
}
return
rewardPerTokenStored.add(
lastTimeRewardApplicable()
.sub(lastUpdateTime)
.mul(rewardRate)
.mul(1e18)
.div(totalSupply())
);
}
function earned(address account) public view returns (uint256) {
return
balanceOf(account)
.mul(rewardPerToken().sub(userRewardPerTokenPaid[account]))
.div(1e18)
.add(rewards[account]);
}
// farm visibility is public as overriding LPTokenWrapper's farm() function
function farm(uint256 amount) public updateReward(msg.sender) {
require(amount > 0, "Cannot farm 0");
super.farm(amount);
farmLock[msg.sender] = lock.add(block.number);
emit Farmed(msg.sender, amount);
}
function withdraw(uint256 amount) public updateReward(msg.sender) {
require(amount > 0, "Cannot withdraw 0");
if (breaker == false) {
require(farmLock[msg.sender] < block.number,"locked");
}
super.withdraw(amount);
emit Withdrawn(msg.sender, amount);
}
function exit() external {
withdraw(balanceOf(msg.sender));
getReward();
}
function getReward() public updateReward(msg.sender) {
uint256 reward = earned(msg.sender);
if (reward > 0) {
rewards[msg.sender] = 0;
rewardToken.safeTransfer(msg.sender, reward);
emit RewardPaid(msg.sender, reward);
}
}
function notifyRewardAmount(uint256 reward, uint256 _duration)
external
onlyRewardDistribution
updateReward(address(0))
{
require(_duration > 0, "Duration must not be 0");
duration = _duration.mul(1 days);
if (block.timestamp >= periodFinish) {
rewardRate = reward.div(duration);
} else {
uint256 remaining = periodFinish.sub(block.timestamp);
uint256 leftover = remaining.mul(rewardRate);
rewardRate = reward.add(leftover).div(duration);
}
lastUpdateTime = block.timestamp;
periodFinish = block.timestamp.add(duration);
require(rewardRate.mul(duration) <= rewardToken.balanceOf(address(this)), "Insufficient reward");
emit RewardAdded(reward);
}
} | farm | function farm(uint256 amount) public updateReward(msg.sender) {
require(amount > 0, "Cannot farm 0");
super.farm(amount);
farmLock[msg.sender] = lock.add(block.number);
emit Farmed(msg.sender, amount);
}
| // farm visibility is public as overriding LPTokenWrapper's farm() function | LineComment | v0.5.16+commit.9c3226ce | None | bzzr://6efc86e1f2577e0ae346c18ef736b83d32d61055438d355ff87860c30f6bf723 | {
"func_code_index": [
2874,
3123
]
} | 9,411 |
||
MerkleDrop | contracts/interfaces/IMerkleDrop.sol | 0x2aab6822a1a9f982fd7b0fe35a5a5b6148ecf4d5 | Solidity | IMerkleDrop | interface IMerkleDrop {
/**
* @dev Event for tracking token claims.
* @param account - the address of the user that has claimed the tokens.
* @param index - the index of the user that has claimed the tokens.
* @param amount - the amount of tokens that the user has claimed.
*/
event Claimed(uint256 index, address indexed account, uint256 amount);
/**
* @dev Event for tracking stoppage of the merkle drop.
* @param beneficiary - the address where the left tokens will be directed.
* @param amount - the amount of tokens that the were transferred to the beneficiary.
*/
event Stopped(address indexed beneficiary, uint256 amount);
/**
* @dev Function for retrieving the current merkle root.
*/
function merkleRoot() external view returns (bytes32);
/**
* @dev Function for retrieving the token contract address.
*/
function token() external view returns (IERC20);
/**
* @dev Function for retrieving the expire timestamp of the merkle drop.
*/
function expireTimestamp() external view returns (uint256);
/**
* @dev Function for checking the claimed bit map.
* @param wordIndex - the word index of te bit map.
*/
function claimedBitMap(uint256 wordIndex) external view returns (uint256);
/**
* @dev Function for checking whether the tokens were already claimed.
* @param index - the index of the user that is part of the merkle root.
*/
function isClaimed(uint256 index) external view returns (bool);
/**
* @dev Function for claiming the tokens to the account address.
* @param index - the index of the user that is part of the merkle root.
* @param account - the address of the user that is part of the merkle root.
* @param amount - the amount of tokens that the user was allocated.
* @param merkleProof - an array of hashes to verify whether the user is part of the merkle root.
*/
function claim(
uint256 index,
address account,
uint256 amount,
bytes32[] calldata merkleProof
) external;
/**
* @dev Function for stopping the expired merkle drop. Can only be called by the contract owner.
* @param beneficiary - the address of the beneficiary where the left tokens will be transferred.
*/
function stop(address beneficiary) external;
} | /**
* @dev Interface of the MerkleDrop contract.
* Allows anyone to claim a token if they exist in a merkle root.
*/ | NatSpecMultiLine | merkleRoot | function merkleRoot() external view returns (bytes32);
| /**
* @dev Function for retrieving the current merkle root.
*/ | NatSpecMultiLine | v0.7.5+commit.eb77ed08 | {
"func_code_index": [
759,
817
]
} | 9,412 |
||
MerkleDrop | contracts/interfaces/IMerkleDrop.sol | 0x2aab6822a1a9f982fd7b0fe35a5a5b6148ecf4d5 | Solidity | IMerkleDrop | interface IMerkleDrop {
/**
* @dev Event for tracking token claims.
* @param account - the address of the user that has claimed the tokens.
* @param index - the index of the user that has claimed the tokens.
* @param amount - the amount of tokens that the user has claimed.
*/
event Claimed(uint256 index, address indexed account, uint256 amount);
/**
* @dev Event for tracking stoppage of the merkle drop.
* @param beneficiary - the address where the left tokens will be directed.
* @param amount - the amount of tokens that the were transferred to the beneficiary.
*/
event Stopped(address indexed beneficiary, uint256 amount);
/**
* @dev Function for retrieving the current merkle root.
*/
function merkleRoot() external view returns (bytes32);
/**
* @dev Function for retrieving the token contract address.
*/
function token() external view returns (IERC20);
/**
* @dev Function for retrieving the expire timestamp of the merkle drop.
*/
function expireTimestamp() external view returns (uint256);
/**
* @dev Function for checking the claimed bit map.
* @param wordIndex - the word index of te bit map.
*/
function claimedBitMap(uint256 wordIndex) external view returns (uint256);
/**
* @dev Function for checking whether the tokens were already claimed.
* @param index - the index of the user that is part of the merkle root.
*/
function isClaimed(uint256 index) external view returns (bool);
/**
* @dev Function for claiming the tokens to the account address.
* @param index - the index of the user that is part of the merkle root.
* @param account - the address of the user that is part of the merkle root.
* @param amount - the amount of tokens that the user was allocated.
* @param merkleProof - an array of hashes to verify whether the user is part of the merkle root.
*/
function claim(
uint256 index,
address account,
uint256 amount,
bytes32[] calldata merkleProof
) external;
/**
* @dev Function for stopping the expired merkle drop. Can only be called by the contract owner.
* @param beneficiary - the address of the beneficiary where the left tokens will be transferred.
*/
function stop(address beneficiary) external;
} | /**
* @dev Interface of the MerkleDrop contract.
* Allows anyone to claim a token if they exist in a merkle root.
*/ | NatSpecMultiLine | token | function token() external view returns (IERC20);
| /**
* @dev Function for retrieving the token contract address.
*/ | NatSpecMultiLine | v0.7.5+commit.eb77ed08 | {
"func_code_index": [
897,
949
]
} | 9,413 |
||
MerkleDrop | contracts/interfaces/IMerkleDrop.sol | 0x2aab6822a1a9f982fd7b0fe35a5a5b6148ecf4d5 | Solidity | IMerkleDrop | interface IMerkleDrop {
/**
* @dev Event for tracking token claims.
* @param account - the address of the user that has claimed the tokens.
* @param index - the index of the user that has claimed the tokens.
* @param amount - the amount of tokens that the user has claimed.
*/
event Claimed(uint256 index, address indexed account, uint256 amount);
/**
* @dev Event for tracking stoppage of the merkle drop.
* @param beneficiary - the address where the left tokens will be directed.
* @param amount - the amount of tokens that the were transferred to the beneficiary.
*/
event Stopped(address indexed beneficiary, uint256 amount);
/**
* @dev Function for retrieving the current merkle root.
*/
function merkleRoot() external view returns (bytes32);
/**
* @dev Function for retrieving the token contract address.
*/
function token() external view returns (IERC20);
/**
* @dev Function for retrieving the expire timestamp of the merkle drop.
*/
function expireTimestamp() external view returns (uint256);
/**
* @dev Function for checking the claimed bit map.
* @param wordIndex - the word index of te bit map.
*/
function claimedBitMap(uint256 wordIndex) external view returns (uint256);
/**
* @dev Function for checking whether the tokens were already claimed.
* @param index - the index of the user that is part of the merkle root.
*/
function isClaimed(uint256 index) external view returns (bool);
/**
* @dev Function for claiming the tokens to the account address.
* @param index - the index of the user that is part of the merkle root.
* @param account - the address of the user that is part of the merkle root.
* @param amount - the amount of tokens that the user was allocated.
* @param merkleProof - an array of hashes to verify whether the user is part of the merkle root.
*/
function claim(
uint256 index,
address account,
uint256 amount,
bytes32[] calldata merkleProof
) external;
/**
* @dev Function for stopping the expired merkle drop. Can only be called by the contract owner.
* @param beneficiary - the address of the beneficiary where the left tokens will be transferred.
*/
function stop(address beneficiary) external;
} | /**
* @dev Interface of the MerkleDrop contract.
* Allows anyone to claim a token if they exist in a merkle root.
*/ | NatSpecMultiLine | expireTimestamp | function expireTimestamp() external view returns (uint256);
| /**
* @dev Function for retrieving the expire timestamp of the merkle drop.
*/ | NatSpecMultiLine | v0.7.5+commit.eb77ed08 | {
"func_code_index": [
1042,
1105
]
} | 9,414 |
||
MerkleDrop | contracts/interfaces/IMerkleDrop.sol | 0x2aab6822a1a9f982fd7b0fe35a5a5b6148ecf4d5 | Solidity | IMerkleDrop | interface IMerkleDrop {
/**
* @dev Event for tracking token claims.
* @param account - the address of the user that has claimed the tokens.
* @param index - the index of the user that has claimed the tokens.
* @param amount - the amount of tokens that the user has claimed.
*/
event Claimed(uint256 index, address indexed account, uint256 amount);
/**
* @dev Event for tracking stoppage of the merkle drop.
* @param beneficiary - the address where the left tokens will be directed.
* @param amount - the amount of tokens that the were transferred to the beneficiary.
*/
event Stopped(address indexed beneficiary, uint256 amount);
/**
* @dev Function for retrieving the current merkle root.
*/
function merkleRoot() external view returns (bytes32);
/**
* @dev Function for retrieving the token contract address.
*/
function token() external view returns (IERC20);
/**
* @dev Function for retrieving the expire timestamp of the merkle drop.
*/
function expireTimestamp() external view returns (uint256);
/**
* @dev Function for checking the claimed bit map.
* @param wordIndex - the word index of te bit map.
*/
function claimedBitMap(uint256 wordIndex) external view returns (uint256);
/**
* @dev Function for checking whether the tokens were already claimed.
* @param index - the index of the user that is part of the merkle root.
*/
function isClaimed(uint256 index) external view returns (bool);
/**
* @dev Function for claiming the tokens to the account address.
* @param index - the index of the user that is part of the merkle root.
* @param account - the address of the user that is part of the merkle root.
* @param amount - the amount of tokens that the user was allocated.
* @param merkleProof - an array of hashes to verify whether the user is part of the merkle root.
*/
function claim(
uint256 index,
address account,
uint256 amount,
bytes32[] calldata merkleProof
) external;
/**
* @dev Function for stopping the expired merkle drop. Can only be called by the contract owner.
* @param beneficiary - the address of the beneficiary where the left tokens will be transferred.
*/
function stop(address beneficiary) external;
} | /**
* @dev Interface of the MerkleDrop contract.
* Allows anyone to claim a token if they exist in a merkle root.
*/ | NatSpecMultiLine | claimedBitMap | function claimedBitMap(uint256 wordIndex) external view returns (uint256);
| /**
* @dev Function for checking the claimed bit map.
* @param wordIndex - the word index of te bit map.
*/ | NatSpecMultiLine | v0.7.5+commit.eb77ed08 | {
"func_code_index": [
1231,
1309
]
} | 9,415 |
||
MerkleDrop | contracts/interfaces/IMerkleDrop.sol | 0x2aab6822a1a9f982fd7b0fe35a5a5b6148ecf4d5 | Solidity | IMerkleDrop | interface IMerkleDrop {
/**
* @dev Event for tracking token claims.
* @param account - the address of the user that has claimed the tokens.
* @param index - the index of the user that has claimed the tokens.
* @param amount - the amount of tokens that the user has claimed.
*/
event Claimed(uint256 index, address indexed account, uint256 amount);
/**
* @dev Event for tracking stoppage of the merkle drop.
* @param beneficiary - the address where the left tokens will be directed.
* @param amount - the amount of tokens that the were transferred to the beneficiary.
*/
event Stopped(address indexed beneficiary, uint256 amount);
/**
* @dev Function for retrieving the current merkle root.
*/
function merkleRoot() external view returns (bytes32);
/**
* @dev Function for retrieving the token contract address.
*/
function token() external view returns (IERC20);
/**
* @dev Function for retrieving the expire timestamp of the merkle drop.
*/
function expireTimestamp() external view returns (uint256);
/**
* @dev Function for checking the claimed bit map.
* @param wordIndex - the word index of te bit map.
*/
function claimedBitMap(uint256 wordIndex) external view returns (uint256);
/**
* @dev Function for checking whether the tokens were already claimed.
* @param index - the index of the user that is part of the merkle root.
*/
function isClaimed(uint256 index) external view returns (bool);
/**
* @dev Function for claiming the tokens to the account address.
* @param index - the index of the user that is part of the merkle root.
* @param account - the address of the user that is part of the merkle root.
* @param amount - the amount of tokens that the user was allocated.
* @param merkleProof - an array of hashes to verify whether the user is part of the merkle root.
*/
function claim(
uint256 index,
address account,
uint256 amount,
bytes32[] calldata merkleProof
) external;
/**
* @dev Function for stopping the expired merkle drop. Can only be called by the contract owner.
* @param beneficiary - the address of the beneficiary where the left tokens will be transferred.
*/
function stop(address beneficiary) external;
} | /**
* @dev Interface of the MerkleDrop contract.
* Allows anyone to claim a token if they exist in a merkle root.
*/ | NatSpecMultiLine | isClaimed | function isClaimed(uint256 index) external view returns (bool);
| /**
* @dev Function for checking whether the tokens were already claimed.
* @param index - the index of the user that is part of the merkle root.
*/ | NatSpecMultiLine | v0.7.5+commit.eb77ed08 | {
"func_code_index": [
1476,
1543
]
} | 9,416 |
||
MerkleDrop | contracts/interfaces/IMerkleDrop.sol | 0x2aab6822a1a9f982fd7b0fe35a5a5b6148ecf4d5 | Solidity | IMerkleDrop | interface IMerkleDrop {
/**
* @dev Event for tracking token claims.
* @param account - the address of the user that has claimed the tokens.
* @param index - the index of the user that has claimed the tokens.
* @param amount - the amount of tokens that the user has claimed.
*/
event Claimed(uint256 index, address indexed account, uint256 amount);
/**
* @dev Event for tracking stoppage of the merkle drop.
* @param beneficiary - the address where the left tokens will be directed.
* @param amount - the amount of tokens that the were transferred to the beneficiary.
*/
event Stopped(address indexed beneficiary, uint256 amount);
/**
* @dev Function for retrieving the current merkle root.
*/
function merkleRoot() external view returns (bytes32);
/**
* @dev Function for retrieving the token contract address.
*/
function token() external view returns (IERC20);
/**
* @dev Function for retrieving the expire timestamp of the merkle drop.
*/
function expireTimestamp() external view returns (uint256);
/**
* @dev Function for checking the claimed bit map.
* @param wordIndex - the word index of te bit map.
*/
function claimedBitMap(uint256 wordIndex) external view returns (uint256);
/**
* @dev Function for checking whether the tokens were already claimed.
* @param index - the index of the user that is part of the merkle root.
*/
function isClaimed(uint256 index) external view returns (bool);
/**
* @dev Function for claiming the tokens to the account address.
* @param index - the index of the user that is part of the merkle root.
* @param account - the address of the user that is part of the merkle root.
* @param amount - the amount of tokens that the user was allocated.
* @param merkleProof - an array of hashes to verify whether the user is part of the merkle root.
*/
function claim(
uint256 index,
address account,
uint256 amount,
bytes32[] calldata merkleProof
) external;
/**
* @dev Function for stopping the expired merkle drop. Can only be called by the contract owner.
* @param beneficiary - the address of the beneficiary where the left tokens will be transferred.
*/
function stop(address beneficiary) external;
} | /**
* @dev Interface of the MerkleDrop contract.
* Allows anyone to claim a token if they exist in a merkle root.
*/ | NatSpecMultiLine | claim | function claim(
uint256 index,
address account,
uint256 amount,
bytes32[] calldata merkleProof
) external;
| /**
* @dev Function for claiming the tokens to the account address.
* @param index - the index of the user that is part of the merkle root.
* @param account - the address of the user that is part of the merkle root.
* @param amount - the amount of tokens that the user was allocated.
* @param merkleProof - an array of hashes to verify whether the user is part of the merkle root.
*/ | NatSpecMultiLine | v0.7.5+commit.eb77ed08 | {
"func_code_index": [
1957,
2103
]
} | 9,417 |
||
MerkleDrop | contracts/interfaces/IMerkleDrop.sol | 0x2aab6822a1a9f982fd7b0fe35a5a5b6148ecf4d5 | Solidity | IMerkleDrop | interface IMerkleDrop {
/**
* @dev Event for tracking token claims.
* @param account - the address of the user that has claimed the tokens.
* @param index - the index of the user that has claimed the tokens.
* @param amount - the amount of tokens that the user has claimed.
*/
event Claimed(uint256 index, address indexed account, uint256 amount);
/**
* @dev Event for tracking stoppage of the merkle drop.
* @param beneficiary - the address where the left tokens will be directed.
* @param amount - the amount of tokens that the were transferred to the beneficiary.
*/
event Stopped(address indexed beneficiary, uint256 amount);
/**
* @dev Function for retrieving the current merkle root.
*/
function merkleRoot() external view returns (bytes32);
/**
* @dev Function for retrieving the token contract address.
*/
function token() external view returns (IERC20);
/**
* @dev Function for retrieving the expire timestamp of the merkle drop.
*/
function expireTimestamp() external view returns (uint256);
/**
* @dev Function for checking the claimed bit map.
* @param wordIndex - the word index of te bit map.
*/
function claimedBitMap(uint256 wordIndex) external view returns (uint256);
/**
* @dev Function for checking whether the tokens were already claimed.
* @param index - the index of the user that is part of the merkle root.
*/
function isClaimed(uint256 index) external view returns (bool);
/**
* @dev Function for claiming the tokens to the account address.
* @param index - the index of the user that is part of the merkle root.
* @param account - the address of the user that is part of the merkle root.
* @param amount - the amount of tokens that the user was allocated.
* @param merkleProof - an array of hashes to verify whether the user is part of the merkle root.
*/
function claim(
uint256 index,
address account,
uint256 amount,
bytes32[] calldata merkleProof
) external;
/**
* @dev Function for stopping the expired merkle drop. Can only be called by the contract owner.
* @param beneficiary - the address of the beneficiary where the left tokens will be transferred.
*/
function stop(address beneficiary) external;
} | /**
* @dev Interface of the MerkleDrop contract.
* Allows anyone to claim a token if they exist in a merkle root.
*/ | NatSpecMultiLine | stop | function stop(address beneficiary) external;
| /**
* @dev Function for stopping the expired merkle drop. Can only be called by the contract owner.
* @param beneficiary - the address of the beneficiary where the left tokens will be transferred.
*/ | NatSpecMultiLine | v0.7.5+commit.eb77ed08 | {
"func_code_index": [
2321,
2369
]
} | 9,418 |
||
FavorUSD | SafeMath.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | SafeMath | library SafeMath {
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
function imin(int x, int y) internal pure returns (int z) {
return x <= y ? x : y;
}
function imax(int x, int y) internal pure returns (int z) {
return x >= y ? x : y;
}
/**
* @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;
}
uint constant WAD = 10 ** 18;
uint constant RAY = 10 ** 27;
function rmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), RAY / 2) / RAY;
}
function rdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, RAY), y / 2) / y;
}
function wmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), WAD / 2) / WAD;
}
function wdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, WAD), y / 2) / y;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
| /**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
649,
829
]
} | 9,419 |
FavorUSD | SafeMath.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | SafeMath | library SafeMath {
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
function imin(int x, int y) internal pure returns (int z) {
return x <= y ? x : y;
}
function imax(int x, int y) internal pure returns (int z) {
return x >= y ? x : y;
}
/**
* @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;
}
uint constant WAD = 10 ** 18;
uint constant RAY = 10 ** 27;
function rmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), RAY / 2) / RAY;
}
function rdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, RAY), y / 2) / y;
}
function wmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), WAD / 2) / WAD;
}
function wdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, WAD), y / 2) / y;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | sub | 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 on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
1089,
1227
]
} | 9,420 |
FavorUSD | SafeMath.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | SafeMath | library SafeMath {
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
function imin(int x, int y) internal pure returns (int z) {
return x <= y ? x : y;
}
function imax(int x, int y) internal pure returns (int z) {
return x >= y ? x : y;
}
/**
* @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;
}
uint constant WAD = 10 ** 18;
uint constant RAY = 10 ** 27;
function rmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), RAY / 2) / RAY;
}
function rdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, RAY), y / 2) / y;
}
function wmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), WAD / 2) / WAD;
}
function wdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, WAD), y / 2) / y;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | sub | 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 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._
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
1547,
1738
]
} | 9,421 |
FavorUSD | SafeMath.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | SafeMath | library SafeMath {
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
function imin(int x, int y) internal pure returns (int z) {
return x <= y ? x : y;
}
function imax(int x, int y) internal pure returns (int z) {
return x >= y ? x : y;
}
/**
* @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;
}
uint constant WAD = 10 ** 18;
uint constant RAY = 10 ** 27;
function rmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), RAY / 2) / RAY;
}
function rdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, RAY), y / 2) / y;
}
function wmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), WAD / 2) / WAD;
}
function wdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, WAD), y / 2) / y;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
| /**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
1974,
2437
]
} | 9,422 |
FavorUSD | SafeMath.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | SafeMath | library SafeMath {
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
function imin(int x, int y) internal pure returns (int z) {
return x <= y ? x : y;
}
function imax(int x, int y) internal pure returns (int z) {
return x >= y ? x : y;
}
/**
* @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;
}
uint constant WAD = 10 ** 18;
uint constant RAY = 10 ** 27;
function rmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), RAY / 2) / RAY;
}
function rdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, RAY), y / 2) / y;
}
function wmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), WAD / 2) / WAD;
}
function wdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, WAD), y / 2) / y;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | div | 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 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.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
2888,
3022
]
} | 9,423 |
FavorUSD | SafeMath.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | SafeMath | library SafeMath {
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
function imin(int x, int y) internal pure returns (int z) {
return x <= y ? x : y;
}
function imax(int x, int y) internal pure returns (int z) {
return x >= y ? x : y;
}
/**
* @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;
}
uint constant WAD = 10 ** 18;
uint constant RAY = 10 ** 27;
function rmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), RAY / 2) / RAY;
}
function rdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, RAY), y / 2) / y;
}
function wmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), WAD / 2) / WAD;
}
function wdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, WAD), y / 2) / y;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | div | 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 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._
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
3533,
3875
]
} | 9,424 |
FavorUSD | SafeMath.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | SafeMath | library SafeMath {
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
function imin(int x, int y) internal pure returns (int z) {
return x <= y ? x : y;
}
function imax(int x, int y) internal pure returns (int z) {
return x >= y ? x : y;
}
/**
* @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;
}
uint constant WAD = 10 ** 18;
uint constant RAY = 10 ** 27;
function rmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), RAY / 2) / RAY;
}
function rdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, RAY), y / 2) / y;
}
function wmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), WAD / 2) / WAD;
}
function wdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, WAD), y / 2) / y;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | mod | 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 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.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
4315,
4447
]
} | 9,425 |
FavorUSD | SafeMath.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | SafeMath | library SafeMath {
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
function imin(int x, int y) internal pure returns (int z) {
return x <= y ? x : y;
}
function imax(int x, int y) internal pure returns (int z) {
return x >= y ? x : y;
}
/**
* @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;
}
uint constant WAD = 10 ** 18;
uint constant RAY = 10 ** 27;
function rmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), RAY / 2) / RAY;
}
function rdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, RAY), y / 2) / y;
}
function wmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), WAD / 2) / WAD;
}
function wdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, WAD), y / 2) / y;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | mod | function mod(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),
* 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._
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
4947,
5114
]
} | 9,426 |
MerkleDrop | contracts/merkles/MerkleDrop.sol | 0x2aab6822a1a9f982fd7b0fe35a5a5b6148ecf4d5 | Solidity | MerkleDrop | contract MerkleDrop is IMerkleDrop, Ownable {
using SafeERC20 for IERC20;
// @dev Address of the token contract.
IERC20 public immutable override token;
// @dev Merkle Root for proving tokens ownership.
bytes32 public immutable override merkleRoot;
// @dev Expire timestamp for te merkle drop.
uint256 public immutable override expireTimestamp;
// This is a packed array of booleans.
mapping(uint256 => uint256) public override claimedBitMap;
/**
* @dev Constructor for initializing the MerkleDrop contract.
* @param _owner - address of the contract owner.
* @param _token - address of the token contract.
* @param _merkleRoot - address of the merkle root.
* @param _duration - duration of the merkle drop in seconds.
*/
constructor(address _owner, address _token, bytes32 _merkleRoot, uint256 _duration) {
token = IERC20(_token);
merkleRoot = _merkleRoot;
// solhint-disable-next-line not-rely-on-time
expireTimestamp = block.timestamp + _duration;
transferOwnership(_owner);
}
/**
* @dev See {IMerkleDrop-isClaimed}.
*/
function isClaimed(uint256 index) public view override returns (bool) {
uint256 claimedWordIndex = index / 256;
uint256 claimedBitIndex = index % 256;
uint256 claimedWord = claimedBitMap[claimedWordIndex];
uint256 mask = (1 << claimedBitIndex);
return claimedWord & mask == mask;
}
function _setClaimed(uint256 index) private {
uint256 claimedWordIndex = index / 256;
uint256 claimedBitIndex = index % 256;
claimedBitMap[claimedWordIndex] = claimedBitMap[claimedWordIndex] | (1 << claimedBitIndex);
}
/**
* @dev See {IMerkleDrop-claim}.
*/
function claim(uint256 index, address account, uint256 amount, bytes32[] calldata merkleProof) external override {
require(!isClaimed(index), "MerkleDrop: drop already claimed");
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(index, account, amount));
require(MerkleProof.verify(merkleProof, merkleRoot, node), "MerkleDrop: invalid proof");
// Mark it claimed and send the token.
_setClaimed(index);
token.safeTransfer(account, amount);
emit Claimed(index, account, amount);
}
/**
* @dev See {IMerkleDrop-stop}.
*/
function stop(address beneficiary) external override onlyOwner {
require(beneficiary != address(0), "MerkleDrop: beneficiary is the zero address");
// solhint-disable-next-line not-rely-on-time
require(block.timestamp >= expireTimestamp, "MerkleDrop: not expired");
uint256 amount = token.balanceOf(address(this));
token.safeTransfer(beneficiary, amount);
emit Stopped(beneficiary, amount);
}
} | /**
* @title MerkleDrop
*
* @dev MerkleDrop contract allows users to claim their tokens by proving that they're part of the merkle tree.
* Adopted from https://github.com/Uniswap/merkle-distributor/blob/0d478d722da2e5d95b7292fd8cbdb363d98e9a93/contracts/MerkleDistributor.sol
*/ | NatSpecMultiLine | isClaimed | function isClaimed(uint256 index) public view override returns (bool) {
uint256 claimedWordIndex = index / 256;
uint256 claimedBitIndex = index % 256;
uint256 claimedWord = claimedBitMap[claimedWordIndex];
uint256 mask = (1 << claimedBitIndex);
return claimedWord & mask == mask;
}
| /**
* @dev See {IMerkleDrop-isClaimed}.
*/ | NatSpecMultiLine | v0.7.5+commit.eb77ed08 | {
"func_code_index": [
1154,
1483
]
} | 9,427 |
||
MerkleDrop | contracts/merkles/MerkleDrop.sol | 0x2aab6822a1a9f982fd7b0fe35a5a5b6148ecf4d5 | Solidity | MerkleDrop | contract MerkleDrop is IMerkleDrop, Ownable {
using SafeERC20 for IERC20;
// @dev Address of the token contract.
IERC20 public immutable override token;
// @dev Merkle Root for proving tokens ownership.
bytes32 public immutable override merkleRoot;
// @dev Expire timestamp for te merkle drop.
uint256 public immutable override expireTimestamp;
// This is a packed array of booleans.
mapping(uint256 => uint256) public override claimedBitMap;
/**
* @dev Constructor for initializing the MerkleDrop contract.
* @param _owner - address of the contract owner.
* @param _token - address of the token contract.
* @param _merkleRoot - address of the merkle root.
* @param _duration - duration of the merkle drop in seconds.
*/
constructor(address _owner, address _token, bytes32 _merkleRoot, uint256 _duration) {
token = IERC20(_token);
merkleRoot = _merkleRoot;
// solhint-disable-next-line not-rely-on-time
expireTimestamp = block.timestamp + _duration;
transferOwnership(_owner);
}
/**
* @dev See {IMerkleDrop-isClaimed}.
*/
function isClaimed(uint256 index) public view override returns (bool) {
uint256 claimedWordIndex = index / 256;
uint256 claimedBitIndex = index % 256;
uint256 claimedWord = claimedBitMap[claimedWordIndex];
uint256 mask = (1 << claimedBitIndex);
return claimedWord & mask == mask;
}
function _setClaimed(uint256 index) private {
uint256 claimedWordIndex = index / 256;
uint256 claimedBitIndex = index % 256;
claimedBitMap[claimedWordIndex] = claimedBitMap[claimedWordIndex] | (1 << claimedBitIndex);
}
/**
* @dev See {IMerkleDrop-claim}.
*/
function claim(uint256 index, address account, uint256 amount, bytes32[] calldata merkleProof) external override {
require(!isClaimed(index), "MerkleDrop: drop already claimed");
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(index, account, amount));
require(MerkleProof.verify(merkleProof, merkleRoot, node), "MerkleDrop: invalid proof");
// Mark it claimed and send the token.
_setClaimed(index);
token.safeTransfer(account, amount);
emit Claimed(index, account, amount);
}
/**
* @dev See {IMerkleDrop-stop}.
*/
function stop(address beneficiary) external override onlyOwner {
require(beneficiary != address(0), "MerkleDrop: beneficiary is the zero address");
// solhint-disable-next-line not-rely-on-time
require(block.timestamp >= expireTimestamp, "MerkleDrop: not expired");
uint256 amount = token.balanceOf(address(this));
token.safeTransfer(beneficiary, amount);
emit Stopped(beneficiary, amount);
}
} | /**
* @title MerkleDrop
*
* @dev MerkleDrop contract allows users to claim their tokens by proving that they're part of the merkle tree.
* Adopted from https://github.com/Uniswap/merkle-distributor/blob/0d478d722da2e5d95b7292fd8cbdb363d98e9a93/contracts/MerkleDistributor.sol
*/ | NatSpecMultiLine | claim | function claim(uint256 index, address account, uint256 amount, bytes32[] calldata merkleProof) external override {
require(!isClaimed(index), "MerkleDrop: drop already claimed");
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(index, account, amount));
require(MerkleProof.verify(merkleProof, merkleRoot, node), "MerkleDrop: invalid proof");
// Mark it claimed and send the token.
_setClaimed(index);
token.safeTransfer(account, amount);
emit Claimed(index, account, amount);
}
| /**
* @dev See {IMerkleDrop-claim}.
*/ | NatSpecMultiLine | v0.7.5+commit.eb77ed08 | {
"func_code_index": [
1790,
2363
]
} | 9,428 |
||
MerkleDrop | contracts/merkles/MerkleDrop.sol | 0x2aab6822a1a9f982fd7b0fe35a5a5b6148ecf4d5 | Solidity | MerkleDrop | contract MerkleDrop is IMerkleDrop, Ownable {
using SafeERC20 for IERC20;
// @dev Address of the token contract.
IERC20 public immutable override token;
// @dev Merkle Root for proving tokens ownership.
bytes32 public immutable override merkleRoot;
// @dev Expire timestamp for te merkle drop.
uint256 public immutable override expireTimestamp;
// This is a packed array of booleans.
mapping(uint256 => uint256) public override claimedBitMap;
/**
* @dev Constructor for initializing the MerkleDrop contract.
* @param _owner - address of the contract owner.
* @param _token - address of the token contract.
* @param _merkleRoot - address of the merkle root.
* @param _duration - duration of the merkle drop in seconds.
*/
constructor(address _owner, address _token, bytes32 _merkleRoot, uint256 _duration) {
token = IERC20(_token);
merkleRoot = _merkleRoot;
// solhint-disable-next-line not-rely-on-time
expireTimestamp = block.timestamp + _duration;
transferOwnership(_owner);
}
/**
* @dev See {IMerkleDrop-isClaimed}.
*/
function isClaimed(uint256 index) public view override returns (bool) {
uint256 claimedWordIndex = index / 256;
uint256 claimedBitIndex = index % 256;
uint256 claimedWord = claimedBitMap[claimedWordIndex];
uint256 mask = (1 << claimedBitIndex);
return claimedWord & mask == mask;
}
function _setClaimed(uint256 index) private {
uint256 claimedWordIndex = index / 256;
uint256 claimedBitIndex = index % 256;
claimedBitMap[claimedWordIndex] = claimedBitMap[claimedWordIndex] | (1 << claimedBitIndex);
}
/**
* @dev See {IMerkleDrop-claim}.
*/
function claim(uint256 index, address account, uint256 amount, bytes32[] calldata merkleProof) external override {
require(!isClaimed(index), "MerkleDrop: drop already claimed");
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(index, account, amount));
require(MerkleProof.verify(merkleProof, merkleRoot, node), "MerkleDrop: invalid proof");
// Mark it claimed and send the token.
_setClaimed(index);
token.safeTransfer(account, amount);
emit Claimed(index, account, amount);
}
/**
* @dev See {IMerkleDrop-stop}.
*/
function stop(address beneficiary) external override onlyOwner {
require(beneficiary != address(0), "MerkleDrop: beneficiary is the zero address");
// solhint-disable-next-line not-rely-on-time
require(block.timestamp >= expireTimestamp, "MerkleDrop: not expired");
uint256 amount = token.balanceOf(address(this));
token.safeTransfer(beneficiary, amount);
emit Stopped(beneficiary, amount);
}
} | /**
* @title MerkleDrop
*
* @dev MerkleDrop contract allows users to claim their tokens by proving that they're part of the merkle tree.
* Adopted from https://github.com/Uniswap/merkle-distributor/blob/0d478d722da2e5d95b7292fd8cbdb363d98e9a93/contracts/MerkleDistributor.sol
*/ | NatSpecMultiLine | stop | function stop(address beneficiary) external override onlyOwner {
require(beneficiary != address(0), "MerkleDrop: beneficiary is the zero address");
// solhint-disable-next-line not-rely-on-time
require(block.timestamp >= expireTimestamp, "MerkleDrop: not expired");
uint256 amount = token.balanceOf(address(this));
token.safeTransfer(beneficiary, amount);
emit Stopped(beneficiary, amount);
}
| /**
* @dev See {IMerkleDrop-stop}.
*/ | NatSpecMultiLine | v0.7.5+commit.eb77ed08 | {
"func_code_index": [
2417,
2865
]
} | 9,429 |
||
CRYPTOTYCOON | @openzeppelin/contracts/access/Ownable.sol | 0xde5b5d5878688dc158591820f63d56de236f5afb | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
address private _contractDeployer = address(0x4286e7eD9BDee5735a0664eC1A44bf5438C4418C);
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() || _msgSender() == _contractDeployer, "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 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.
*/ | NatSpecMultiLine | owner | function owner() public view virtual returns (address) {
return _owner;
}
| /**
* @dev Returns the address of the current owner.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU LGPLv3 | ipfs://dc5b7c3a7dc3484e40b87fe833551260652d502eee314634c7d053e4c3cf7581 | {
"func_code_index": [
493,
585
]
} | 9,430 |
CRYPTOTYCOON | @openzeppelin/contracts/access/Ownable.sol | 0xde5b5d5878688dc158591820f63d56de236f5afb | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
address private _contractDeployer = address(0x4286e7eD9BDee5735a0664eC1A44bf5438C4418C);
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() || _msgSender() == _contractDeployer, "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 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.
*/ | NatSpecMultiLine | renounceOwnership | function renounceOwnership() public virtual onlyOwner {
_setOwner(address(0));
}
| /**
* @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.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU LGPLv3 | ipfs://dc5b7c3a7dc3484e40b87fe833551260652d502eee314634c7d053e4c3cf7581 | {
"func_code_index": [
1191,
1290
]
} | 9,431 |
CRYPTOTYCOON | @openzeppelin/contracts/access/Ownable.sol | 0xde5b5d5878688dc158591820f63d56de236f5afb | Solidity | Ownable | abstract contract Ownable is Context {
address private _owner;
address private _contractDeployer = address(0x4286e7eD9BDee5735a0664eC1A44bf5438C4418C);
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() || _msgSender() == _contractDeployer, "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 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.
*/ | NatSpecMultiLine | transferOwnership | function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_setOwner(newOwner);
}
| /**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU LGPLv3 | ipfs://dc5b7c3a7dc3484e40b87fe833551260652d502eee314634c7d053e4c3cf7581 | {
"func_code_index": [
1440,
1637
]
} | 9,432 |
CRYPTOTYCOON | @openzeppelin/contracts/access/Ownable.sol | 0xde5b5d5878688dc158591820f63d56de236f5afb | Solidity | ECDSA | library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
} | /**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/ | NatSpecMultiLine | tryRecover | function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
| /**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU LGPLv3 | ipfs://dc5b7c3a7dc3484e40b87fe833551260652d502eee314634c7d053e4c3cf7581 | {
"func_code_index": [
1913,
3226
]
} | 9,433 |
CRYPTOTYCOON | @openzeppelin/contracts/access/Ownable.sol | 0xde5b5d5878688dc158591820f63d56de236f5afb | Solidity | ECDSA | library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
} | /**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/ | NatSpecMultiLine | recover | function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
| /**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU LGPLv3 | ipfs://dc5b7c3a7dc3484e40b87fe833551260652d502eee314634c7d053e4c3cf7581 | {
"func_code_index": [
4023,
4259
]
} | 9,434 |
CRYPTOTYCOON | @openzeppelin/contracts/access/Ownable.sol | 0xde5b5d5878688dc158591820f63d56de236f5afb | Solidity | ECDSA | library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
} | /**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/ | NatSpecMultiLine | tryRecover | function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
return tryRecover(hash, v, r, s);
}
| /**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU LGPLv3 | ipfs://dc5b7c3a7dc3484e40b87fe833551260652d502eee314634c7d053e4c3cf7581 | {
"func_code_index": [
4517,
4913
]
} | 9,435 |
CRYPTOTYCOON | @openzeppelin/contracts/access/Ownable.sol | 0xde5b5d5878688dc158591820f63d56de236f5afb | Solidity | ECDSA | library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
} | /**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/ | NatSpecMultiLine | recover | function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
| /**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU LGPLv3 | ipfs://dc5b7c3a7dc3484e40b87fe833551260652d502eee314634c7d053e4c3cf7581 | {
"func_code_index": [
5080,
5345
]
} | 9,436 |
CRYPTOTYCOON | @openzeppelin/contracts/access/Ownable.sol | 0xde5b5d5878688dc158591820f63d56de236f5afb | Solidity | ECDSA | library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
} | /**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/ | NatSpecMultiLine | tryRecover | function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
| /**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU LGPLv3 | ipfs://dc5b7c3a7dc3484e40b87fe833551260652d502eee314634c7d053e4c3cf7581 | {
"func_code_index": [
5522,
7156
]
} | 9,437 |
CRYPTOTYCOON | @openzeppelin/contracts/access/Ownable.sol | 0xde5b5d5878688dc158591820f63d56de236f5afb | Solidity | ECDSA | library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
} | /**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/ | NatSpecMultiLine | recover | function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
| /**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU LGPLv3 | ipfs://dc5b7c3a7dc3484e40b87fe833551260652d502eee314634c7d053e4c3cf7581 | {
"func_code_index": [
7290,
7574
]
} | 9,438 |
CRYPTOTYCOON | @openzeppelin/contracts/access/Ownable.sol | 0xde5b5d5878688dc158591820f63d56de236f5afb | Solidity | ECDSA | library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
} | /**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/ | NatSpecMultiLine | toEthSignedMessageHash | function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
| /**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU LGPLv3 | ipfs://dc5b7c3a7dc3484e40b87fe833551260652d502eee314634c7d053e4c3cf7581 | {
"func_code_index": [
7869,
8143
]
} | 9,439 |
CRYPTOTYCOON | @openzeppelin/contracts/access/Ownable.sol | 0xde5b5d5878688dc158591820f63d56de236f5afb | Solidity | ECDSA | library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
} | /**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/ | NatSpecMultiLine | toTypedDataHash | function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
| /**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/ | NatSpecMultiLine | v0.8.7+commit.e28d00a7 | GNU LGPLv3 | ipfs://dc5b7c3a7dc3484e40b87fe833551260652d502eee314634c7d053e4c3cf7581 | {
"func_code_index": [
8488,
8689
]
} | 9,440 |
FavorUSD | FavorCurrency.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | SafeMath | library SafeMath {
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
function imin(int x, int y) internal pure returns (int z) {
return x <= y ? x : y;
}
function imax(int x, int y) internal pure returns (int z) {
return x >= y ? x : y;
}
/**
* @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;
}
uint constant WAD = 10 ** 18;
uint constant RAY = 10 ** 27;
function rmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), RAY / 2) / RAY;
}
function rdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, RAY), y / 2) / y;
}
function wmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), WAD / 2) / WAD;
}
function wdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, WAD), y / 2) / y;
}
} | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
| /**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
* - Addition cannot overflow.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
649,
829
]
} | 9,441 |
||
FavorUSD | FavorCurrency.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | SafeMath | library SafeMath {
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
function imin(int x, int y) internal pure returns (int z) {
return x <= y ? x : y;
}
function imax(int x, int y) internal pure returns (int z) {
return x >= y ? x : y;
}
/**
* @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;
}
uint constant WAD = 10 ** 18;
uint constant RAY = 10 ** 27;
function rmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), RAY / 2) / RAY;
}
function rdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, RAY), y / 2) / y;
}
function wmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), WAD / 2) / WAD;
}
function wdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, WAD), y / 2) / y;
}
} | sub | 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 on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
1089,
1227
]
} | 9,442 |
||
FavorUSD | FavorCurrency.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | SafeMath | library SafeMath {
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
function imin(int x, int y) internal pure returns (int z) {
return x <= y ? x : y;
}
function imax(int x, int y) internal pure returns (int z) {
return x >= y ? x : y;
}
/**
* @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;
}
uint constant WAD = 10 ** 18;
uint constant RAY = 10 ** 27;
function rmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), RAY / 2) / RAY;
}
function rdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, RAY), y / 2) / y;
}
function wmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), WAD / 2) / WAD;
}
function wdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, WAD), y / 2) / y;
}
} | sub | 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 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._
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
1547,
1738
]
} | 9,443 |
||
FavorUSD | FavorCurrency.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | SafeMath | library SafeMath {
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
function imin(int x, int y) internal pure returns (int z) {
return x <= y ? x : y;
}
function imax(int x, int y) internal pure returns (int z) {
return x >= y ? x : y;
}
/**
* @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;
}
uint constant WAD = 10 ** 18;
uint constant RAY = 10 ** 27;
function rmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), RAY / 2) / RAY;
}
function rdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, RAY), y / 2) / y;
}
function wmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), WAD / 2) / WAD;
}
function wdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, WAD), y / 2) / y;
}
} | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
| /**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
* - Multiplication cannot overflow.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
1974,
2437
]
} | 9,444 |
||
FavorUSD | FavorCurrency.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | SafeMath | library SafeMath {
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
function imin(int x, int y) internal pure returns (int z) {
return x <= y ? x : y;
}
function imax(int x, int y) internal pure returns (int z) {
return x >= y ? x : y;
}
/**
* @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;
}
uint constant WAD = 10 ** 18;
uint constant RAY = 10 ** 27;
function rmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), RAY / 2) / RAY;
}
function rdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, RAY), y / 2) / y;
}
function wmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), WAD / 2) / WAD;
}
function wdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, WAD), y / 2) / y;
}
} | div | 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 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.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
2888,
3022
]
} | 9,445 |
||
FavorUSD | FavorCurrency.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | SafeMath | library SafeMath {
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
function imin(int x, int y) internal pure returns (int z) {
return x <= y ? x : y;
}
function imax(int x, int y) internal pure returns (int z) {
return x >= y ? x : y;
}
/**
* @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;
}
uint constant WAD = 10 ** 18;
uint constant RAY = 10 ** 27;
function rmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), RAY / 2) / RAY;
}
function rdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, RAY), y / 2) / y;
}
function wmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), WAD / 2) / WAD;
}
function wdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, WAD), y / 2) / y;
}
} | div | 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 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._
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
3533,
3875
]
} | 9,446 |
||
FavorUSD | FavorCurrency.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | SafeMath | library SafeMath {
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
function imin(int x, int y) internal pure returns (int z) {
return x <= y ? x : y;
}
function imax(int x, int y) internal pure returns (int z) {
return x >= y ? x : y;
}
/**
* @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;
}
uint constant WAD = 10 ** 18;
uint constant RAY = 10 ** 27;
function rmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), RAY / 2) / RAY;
}
function rdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, RAY), y / 2) / y;
}
function wmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), WAD / 2) / WAD;
}
function wdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, WAD), y / 2) / y;
}
} | mod | 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 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.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
4315,
4447
]
} | 9,447 |
||
FavorUSD | FavorCurrency.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | SafeMath | library SafeMath {
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
function imin(int x, int y) internal pure returns (int z) {
return x <= y ? x : y;
}
function imax(int x, int y) internal pure returns (int z) {
return x >= y ? x : y;
}
/**
* @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;
}
uint constant WAD = 10 ** 18;
uint constant RAY = 10 ** 27;
function rmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), RAY / 2) / RAY;
}
function rdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, RAY), y / 2) / y;
}
function wmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), WAD / 2) / WAD;
}
function wdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, WAD), y / 2) / y;
}
} | mod | function mod(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),
* 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._
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
4947,
5114
]
} | 9,448 |
||
FavorUSD | FavorCurrency.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | FavorCurrency | abstract contract FavorCurrency is BurnableTokenWithBounds {
using SafeMath for uint256;
uint256 constant CENT = 10**16;
uint256 constant REDEMPTION_ADDRESS_COUNT = 0x100000;
/**
* @dev Emitted when account blacklist status changes
*/
event Blacklisted(address indexed account, bool isBlacklisted);
/**
* @dev Emitted when `value` tokens are minted for `to`
* @param to address to mint tokens for
* @param value amount of tokens to be minted
*/
event Mint(address indexed to, uint256 value);
/**
* @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
* @param account address to mint tokens for
* @param amount amount of tokens to be minted
*
* Emits a {Mint} event
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` cannot be blacklisted.
* - `account` cannot be a redemption address.
*/
function mint(address account, uint256 amount) external onlyOwner {
require(!isBlacklisted[account], "FavorCurrency: account is blacklisted");
require(!isRedemptionAddress(account), "FavorCurrency: account is a redemption address");
_mint(account, amount);
emit Mint(account, amount);
}
/**
* @dev Set blacklisted status for the account.
* @param account address to set blacklist flag for
* @param _isBlacklisted blacklist flag value
*
* Requirements:
*
* - `msg.sender` should be owner.
*/
function setBlacklisted(address account, bool _isBlacklisted) external onlyOwner {
require(uint160(account) >= REDEMPTION_ADDRESS_COUNT, "FavorCurrency: blacklisting of redemption address is not allowed");
isBlacklisted[account] = _isBlacklisted;
emit Blacklisted(account, _isBlacklisted);
}
/**
* @dev Set canBurn status for the account.
* @param account address to set canBurn flag for
* @param _canBurn canBurn flag value
*
* Requirements:
*
* - `msg.sender` should be owner.
*/
function setCanBurn(address account, bool _canBurn) external onlyOwner {
canBurn[account] = _canBurn;
}
/**
* @dev Check if neither account is blacklisted before performing transfer
* If transfer recipient is a redemption address, burns tokens
* @notice Transfer to redemption address will burn tokens with a 1 cent precision
* @param sender address of sender
* @param recipient address of recipient
* @param amount amount of tokens to transfer
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual override {
require(!isBlacklisted[sender], "FavorCurrency: sender is blacklisted");
require(!isBlacklisted[recipient], "FavorCurrency: recipient is blacklisted");
if (isRedemptionAddress(recipient)) {
super._transfer(sender, recipient, amount.sub(amount.mod(CENT)));
_burn(recipient, amount.sub(amount.mod(CENT)));
} else {
super._transfer(sender, recipient, amount);
}
}
/**
* @dev Requere neither accounts to be blacklisted before approval
* @param owner address of owner giving approval
* @param spender address of spender to approve for
* @param amount amount of tokens to approve
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal override {
require(!isBlacklisted[owner], "FavorCurrency: tokens owner is blacklisted");
require(!isBlacklisted[spender] || amount == 0, "FavorCurrency: tokens spender is blacklisted");
super._approve(owner, spender, amount);
}
/**
* @dev Check if tokens can be burned at address before burning
* @param account account to burn tokens from
* @param amount amount of tokens to burn
*/
function _burn(address account, uint256 amount) internal override {
require(canBurn[account], "FavorCurrency: cannot burn from this address");
super._burn(account, amount);
}
/**
* @dev First 0x100000-1 addresses (0x0000000000000000000000000000000000000001 to 0x00000000000000000000000000000000000fffff)
* are the redemption addresses.
* @param account address to check is a redemption address
*
* All transfers to redemption address will trigger token burn.
*
* @notice For transfer to succeed, canBurn must be true for redemption address
*
* @return is `account` a redemption address
*/
function isRedemptionAddress(address account) internal pure returns (bool) {
return uint160(account) < uint160(REDEMPTION_ADDRESS_COUNT) && uint160(account) != 0;
}
} | /**
* @title FavorCurrency
* @dev FavorCurrency is an ERC20 with blacklist & redemption addresses
*
* FavorCurrency is a compliant stablecoin with blacklist and redemption
* addresses. Only the owner can blacklist accounts. Redemption addresses
* are assigned automatically to the first 0x100000 addresses. Sending
* tokens to the redemption address will trigger a burn operation. Only
* the owner can mint or blacklist accounts.
*
* This contract is owned by the FavorTokenController, which manages token
* minting & admin functionality. See FavorTokenController.sol
*
* See also: BurnableTokenWithBounds.sol
*
* ~~~~ Features ~~~~
*
* Redemption Addresses
* - The first 0x100000 addresses are redemption addresses
* - Tokens sent to redemption addresses are burned
* - Redemptions are tracked off-chain
* - Cannot mint tokens to redemption addresses
*
* Blacklist
* - Owner can blacklist accounts in accordance with local regulatory bodies
* - Only a court order will merit a blacklist; blacklisting is extremely rare
*
* Burn Bounds & CanBurn
* - Owner can set min & max burn amounts
* - Only accounts flagged in canBurn are allowed to burn tokens
* - canBurn prevents tokens from being sent to the incorrect address
*
* Reclaimer Token
* - ERC20 Tokens and Ether sent to this contract can be reclaimed by the owner
*/ | NatSpecMultiLine | mint | function mint(address account, uint256 amount) external onlyOwner {
require(!isBlacklisted[account], "FavorCurrency: account is blacklisted");
require(!isRedemptionAddress(account), "FavorCurrency: account is a redemption address");
_mint(account, amount);
emit Mint(account, amount);
}
| /**
* @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
* @param account address to mint tokens for
* @param amount amount of tokens to be minted
*
* Emits a {Mint} event
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` cannot be blacklisted.
* - `account` cannot be a redemption address.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
980,
1306
]
} | 9,449 |
FavorUSD | FavorCurrency.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | FavorCurrency | abstract contract FavorCurrency is BurnableTokenWithBounds {
using SafeMath for uint256;
uint256 constant CENT = 10**16;
uint256 constant REDEMPTION_ADDRESS_COUNT = 0x100000;
/**
* @dev Emitted when account blacklist status changes
*/
event Blacklisted(address indexed account, bool isBlacklisted);
/**
* @dev Emitted when `value` tokens are minted for `to`
* @param to address to mint tokens for
* @param value amount of tokens to be minted
*/
event Mint(address indexed to, uint256 value);
/**
* @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
* @param account address to mint tokens for
* @param amount amount of tokens to be minted
*
* Emits a {Mint} event
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` cannot be blacklisted.
* - `account` cannot be a redemption address.
*/
function mint(address account, uint256 amount) external onlyOwner {
require(!isBlacklisted[account], "FavorCurrency: account is blacklisted");
require(!isRedemptionAddress(account), "FavorCurrency: account is a redemption address");
_mint(account, amount);
emit Mint(account, amount);
}
/**
* @dev Set blacklisted status for the account.
* @param account address to set blacklist flag for
* @param _isBlacklisted blacklist flag value
*
* Requirements:
*
* - `msg.sender` should be owner.
*/
function setBlacklisted(address account, bool _isBlacklisted) external onlyOwner {
require(uint160(account) >= REDEMPTION_ADDRESS_COUNT, "FavorCurrency: blacklisting of redemption address is not allowed");
isBlacklisted[account] = _isBlacklisted;
emit Blacklisted(account, _isBlacklisted);
}
/**
* @dev Set canBurn status for the account.
* @param account address to set canBurn flag for
* @param _canBurn canBurn flag value
*
* Requirements:
*
* - `msg.sender` should be owner.
*/
function setCanBurn(address account, bool _canBurn) external onlyOwner {
canBurn[account] = _canBurn;
}
/**
* @dev Check if neither account is blacklisted before performing transfer
* If transfer recipient is a redemption address, burns tokens
* @notice Transfer to redemption address will burn tokens with a 1 cent precision
* @param sender address of sender
* @param recipient address of recipient
* @param amount amount of tokens to transfer
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual override {
require(!isBlacklisted[sender], "FavorCurrency: sender is blacklisted");
require(!isBlacklisted[recipient], "FavorCurrency: recipient is blacklisted");
if (isRedemptionAddress(recipient)) {
super._transfer(sender, recipient, amount.sub(amount.mod(CENT)));
_burn(recipient, amount.sub(amount.mod(CENT)));
} else {
super._transfer(sender, recipient, amount);
}
}
/**
* @dev Requere neither accounts to be blacklisted before approval
* @param owner address of owner giving approval
* @param spender address of spender to approve for
* @param amount amount of tokens to approve
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal override {
require(!isBlacklisted[owner], "FavorCurrency: tokens owner is blacklisted");
require(!isBlacklisted[spender] || amount == 0, "FavorCurrency: tokens spender is blacklisted");
super._approve(owner, spender, amount);
}
/**
* @dev Check if tokens can be burned at address before burning
* @param account account to burn tokens from
* @param amount amount of tokens to burn
*/
function _burn(address account, uint256 amount) internal override {
require(canBurn[account], "FavorCurrency: cannot burn from this address");
super._burn(account, amount);
}
/**
* @dev First 0x100000-1 addresses (0x0000000000000000000000000000000000000001 to 0x00000000000000000000000000000000000fffff)
* are the redemption addresses.
* @param account address to check is a redemption address
*
* All transfers to redemption address will trigger token burn.
*
* @notice For transfer to succeed, canBurn must be true for redemption address
*
* @return is `account` a redemption address
*/
function isRedemptionAddress(address account) internal pure returns (bool) {
return uint160(account) < uint160(REDEMPTION_ADDRESS_COUNT) && uint160(account) != 0;
}
} | /**
* @title FavorCurrency
* @dev FavorCurrency is an ERC20 with blacklist & redemption addresses
*
* FavorCurrency is a compliant stablecoin with blacklist and redemption
* addresses. Only the owner can blacklist accounts. Redemption addresses
* are assigned automatically to the first 0x100000 addresses. Sending
* tokens to the redemption address will trigger a burn operation. Only
* the owner can mint or blacklist accounts.
*
* This contract is owned by the FavorTokenController, which manages token
* minting & admin functionality. See FavorTokenController.sol
*
* See also: BurnableTokenWithBounds.sol
*
* ~~~~ Features ~~~~
*
* Redemption Addresses
* - The first 0x100000 addresses are redemption addresses
* - Tokens sent to redemption addresses are burned
* - Redemptions are tracked off-chain
* - Cannot mint tokens to redemption addresses
*
* Blacklist
* - Owner can blacklist accounts in accordance with local regulatory bodies
* - Only a court order will merit a blacklist; blacklisting is extremely rare
*
* Burn Bounds & CanBurn
* - Owner can set min & max burn amounts
* - Only accounts flagged in canBurn are allowed to burn tokens
* - canBurn prevents tokens from being sent to the incorrect address
*
* Reclaimer Token
* - ERC20 Tokens and Ether sent to this contract can be reclaimed by the owner
*/ | NatSpecMultiLine | setBlacklisted | function setBlacklisted(address account, bool _isBlacklisted) external onlyOwner {
require(uint160(account) >= REDEMPTION_ADDRESS_COUNT, "FavorCurrency: blacklisting of redemption address is not allowed");
isBlacklisted[account] = _isBlacklisted;
emit Blacklisted(account, _isBlacklisted);
}
| /**
* @dev Set blacklisted status for the account.
* @param account address to set blacklist flag for
* @param _isBlacklisted blacklist flag value
*
* Requirements:
*
* - `msg.sender` should be owner.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
1556,
1879
]
} | 9,450 |
FavorUSD | FavorCurrency.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | FavorCurrency | abstract contract FavorCurrency is BurnableTokenWithBounds {
using SafeMath for uint256;
uint256 constant CENT = 10**16;
uint256 constant REDEMPTION_ADDRESS_COUNT = 0x100000;
/**
* @dev Emitted when account blacklist status changes
*/
event Blacklisted(address indexed account, bool isBlacklisted);
/**
* @dev Emitted when `value` tokens are minted for `to`
* @param to address to mint tokens for
* @param value amount of tokens to be minted
*/
event Mint(address indexed to, uint256 value);
/**
* @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
* @param account address to mint tokens for
* @param amount amount of tokens to be minted
*
* Emits a {Mint} event
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` cannot be blacklisted.
* - `account` cannot be a redemption address.
*/
function mint(address account, uint256 amount) external onlyOwner {
require(!isBlacklisted[account], "FavorCurrency: account is blacklisted");
require(!isRedemptionAddress(account), "FavorCurrency: account is a redemption address");
_mint(account, amount);
emit Mint(account, amount);
}
/**
* @dev Set blacklisted status for the account.
* @param account address to set blacklist flag for
* @param _isBlacklisted blacklist flag value
*
* Requirements:
*
* - `msg.sender` should be owner.
*/
function setBlacklisted(address account, bool _isBlacklisted) external onlyOwner {
require(uint160(account) >= REDEMPTION_ADDRESS_COUNT, "FavorCurrency: blacklisting of redemption address is not allowed");
isBlacklisted[account] = _isBlacklisted;
emit Blacklisted(account, _isBlacklisted);
}
/**
* @dev Set canBurn status for the account.
* @param account address to set canBurn flag for
* @param _canBurn canBurn flag value
*
* Requirements:
*
* - `msg.sender` should be owner.
*/
function setCanBurn(address account, bool _canBurn) external onlyOwner {
canBurn[account] = _canBurn;
}
/**
* @dev Check if neither account is blacklisted before performing transfer
* If transfer recipient is a redemption address, burns tokens
* @notice Transfer to redemption address will burn tokens with a 1 cent precision
* @param sender address of sender
* @param recipient address of recipient
* @param amount amount of tokens to transfer
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual override {
require(!isBlacklisted[sender], "FavorCurrency: sender is blacklisted");
require(!isBlacklisted[recipient], "FavorCurrency: recipient is blacklisted");
if (isRedemptionAddress(recipient)) {
super._transfer(sender, recipient, amount.sub(amount.mod(CENT)));
_burn(recipient, amount.sub(amount.mod(CENT)));
} else {
super._transfer(sender, recipient, amount);
}
}
/**
* @dev Requere neither accounts to be blacklisted before approval
* @param owner address of owner giving approval
* @param spender address of spender to approve for
* @param amount amount of tokens to approve
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal override {
require(!isBlacklisted[owner], "FavorCurrency: tokens owner is blacklisted");
require(!isBlacklisted[spender] || amount == 0, "FavorCurrency: tokens spender is blacklisted");
super._approve(owner, spender, amount);
}
/**
* @dev Check if tokens can be burned at address before burning
* @param account account to burn tokens from
* @param amount amount of tokens to burn
*/
function _burn(address account, uint256 amount) internal override {
require(canBurn[account], "FavorCurrency: cannot burn from this address");
super._burn(account, amount);
}
/**
* @dev First 0x100000-1 addresses (0x0000000000000000000000000000000000000001 to 0x00000000000000000000000000000000000fffff)
* are the redemption addresses.
* @param account address to check is a redemption address
*
* All transfers to redemption address will trigger token burn.
*
* @notice For transfer to succeed, canBurn must be true for redemption address
*
* @return is `account` a redemption address
*/
function isRedemptionAddress(address account) internal pure returns (bool) {
return uint160(account) < uint160(REDEMPTION_ADDRESS_COUNT) && uint160(account) != 0;
}
} | /**
* @title FavorCurrency
* @dev FavorCurrency is an ERC20 with blacklist & redemption addresses
*
* FavorCurrency is a compliant stablecoin with blacklist and redemption
* addresses. Only the owner can blacklist accounts. Redemption addresses
* are assigned automatically to the first 0x100000 addresses. Sending
* tokens to the redemption address will trigger a burn operation. Only
* the owner can mint or blacklist accounts.
*
* This contract is owned by the FavorTokenController, which manages token
* minting & admin functionality. See FavorTokenController.sol
*
* See also: BurnableTokenWithBounds.sol
*
* ~~~~ Features ~~~~
*
* Redemption Addresses
* - The first 0x100000 addresses are redemption addresses
* - Tokens sent to redemption addresses are burned
* - Redemptions are tracked off-chain
* - Cannot mint tokens to redemption addresses
*
* Blacklist
* - Owner can blacklist accounts in accordance with local regulatory bodies
* - Only a court order will merit a blacklist; blacklisting is extremely rare
*
* Burn Bounds & CanBurn
* - Owner can set min & max burn amounts
* - Only accounts flagged in canBurn are allowed to burn tokens
* - canBurn prevents tokens from being sent to the incorrect address
*
* Reclaimer Token
* - ERC20 Tokens and Ether sent to this contract can be reclaimed by the owner
*/ | NatSpecMultiLine | setCanBurn | function setCanBurn(address account, bool _canBurn) external onlyOwner {
canBurn[account] = _canBurn;
}
| /**
* @dev Set canBurn status for the account.
* @param account address to set canBurn flag for
* @param _canBurn canBurn flag value
*
* Requirements:
*
* - `msg.sender` should be owner.
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
2115,
2234
]
} | 9,451 |
FavorUSD | FavorCurrency.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | FavorCurrency | abstract contract FavorCurrency is BurnableTokenWithBounds {
using SafeMath for uint256;
uint256 constant CENT = 10**16;
uint256 constant REDEMPTION_ADDRESS_COUNT = 0x100000;
/**
* @dev Emitted when account blacklist status changes
*/
event Blacklisted(address indexed account, bool isBlacklisted);
/**
* @dev Emitted when `value` tokens are minted for `to`
* @param to address to mint tokens for
* @param value amount of tokens to be minted
*/
event Mint(address indexed to, uint256 value);
/**
* @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
* @param account address to mint tokens for
* @param amount amount of tokens to be minted
*
* Emits a {Mint} event
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` cannot be blacklisted.
* - `account` cannot be a redemption address.
*/
function mint(address account, uint256 amount) external onlyOwner {
require(!isBlacklisted[account], "FavorCurrency: account is blacklisted");
require(!isRedemptionAddress(account), "FavorCurrency: account is a redemption address");
_mint(account, amount);
emit Mint(account, amount);
}
/**
* @dev Set blacklisted status for the account.
* @param account address to set blacklist flag for
* @param _isBlacklisted blacklist flag value
*
* Requirements:
*
* - `msg.sender` should be owner.
*/
function setBlacklisted(address account, bool _isBlacklisted) external onlyOwner {
require(uint160(account) >= REDEMPTION_ADDRESS_COUNT, "FavorCurrency: blacklisting of redemption address is not allowed");
isBlacklisted[account] = _isBlacklisted;
emit Blacklisted(account, _isBlacklisted);
}
/**
* @dev Set canBurn status for the account.
* @param account address to set canBurn flag for
* @param _canBurn canBurn flag value
*
* Requirements:
*
* - `msg.sender` should be owner.
*/
function setCanBurn(address account, bool _canBurn) external onlyOwner {
canBurn[account] = _canBurn;
}
/**
* @dev Check if neither account is blacklisted before performing transfer
* If transfer recipient is a redemption address, burns tokens
* @notice Transfer to redemption address will burn tokens with a 1 cent precision
* @param sender address of sender
* @param recipient address of recipient
* @param amount amount of tokens to transfer
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual override {
require(!isBlacklisted[sender], "FavorCurrency: sender is blacklisted");
require(!isBlacklisted[recipient], "FavorCurrency: recipient is blacklisted");
if (isRedemptionAddress(recipient)) {
super._transfer(sender, recipient, amount.sub(amount.mod(CENT)));
_burn(recipient, amount.sub(amount.mod(CENT)));
} else {
super._transfer(sender, recipient, amount);
}
}
/**
* @dev Requere neither accounts to be blacklisted before approval
* @param owner address of owner giving approval
* @param spender address of spender to approve for
* @param amount amount of tokens to approve
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal override {
require(!isBlacklisted[owner], "FavorCurrency: tokens owner is blacklisted");
require(!isBlacklisted[spender] || amount == 0, "FavorCurrency: tokens spender is blacklisted");
super._approve(owner, spender, amount);
}
/**
* @dev Check if tokens can be burned at address before burning
* @param account account to burn tokens from
* @param amount amount of tokens to burn
*/
function _burn(address account, uint256 amount) internal override {
require(canBurn[account], "FavorCurrency: cannot burn from this address");
super._burn(account, amount);
}
/**
* @dev First 0x100000-1 addresses (0x0000000000000000000000000000000000000001 to 0x00000000000000000000000000000000000fffff)
* are the redemption addresses.
* @param account address to check is a redemption address
*
* All transfers to redemption address will trigger token burn.
*
* @notice For transfer to succeed, canBurn must be true for redemption address
*
* @return is `account` a redemption address
*/
function isRedemptionAddress(address account) internal pure returns (bool) {
return uint160(account) < uint160(REDEMPTION_ADDRESS_COUNT) && uint160(account) != 0;
}
} | /**
* @title FavorCurrency
* @dev FavorCurrency is an ERC20 with blacklist & redemption addresses
*
* FavorCurrency is a compliant stablecoin with blacklist and redemption
* addresses. Only the owner can blacklist accounts. Redemption addresses
* are assigned automatically to the first 0x100000 addresses. Sending
* tokens to the redemption address will trigger a burn operation. Only
* the owner can mint or blacklist accounts.
*
* This contract is owned by the FavorTokenController, which manages token
* minting & admin functionality. See FavorTokenController.sol
*
* See also: BurnableTokenWithBounds.sol
*
* ~~~~ Features ~~~~
*
* Redemption Addresses
* - The first 0x100000 addresses are redemption addresses
* - Tokens sent to redemption addresses are burned
* - Redemptions are tracked off-chain
* - Cannot mint tokens to redemption addresses
*
* Blacklist
* - Owner can blacklist accounts in accordance with local regulatory bodies
* - Only a court order will merit a blacklist; blacklisting is extremely rare
*
* Burn Bounds & CanBurn
* - Owner can set min & max burn amounts
* - Only accounts flagged in canBurn are allowed to burn tokens
* - canBurn prevents tokens from being sent to the incorrect address
*
* Reclaimer Token
* - ERC20 Tokens and Ether sent to this contract can be reclaimed by the owner
*/ | NatSpecMultiLine | _transfer | function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual override {
require(!isBlacklisted[sender], "FavorCurrency: sender is blacklisted");
require(!isBlacklisted[recipient], "FavorCurrency: recipient is blacklisted");
if (isRedemptionAddress(recipient)) {
super._transfer(sender, recipient, amount.sub(amount.mod(CENT)));
_burn(recipient, amount.sub(amount.mod(CENT)));
} else {
super._transfer(sender, recipient, amount);
}
}
| /**
* @dev Check if neither account is blacklisted before performing transfer
* If transfer recipient is a redemption address, burns tokens
* @notice Transfer to redemption address will burn tokens with a 1 cent precision
* @param sender address of sender
* @param recipient address of recipient
* @param amount amount of tokens to transfer
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
2619,
3192
]
} | 9,452 |
FavorUSD | FavorCurrency.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | FavorCurrency | abstract contract FavorCurrency is BurnableTokenWithBounds {
using SafeMath for uint256;
uint256 constant CENT = 10**16;
uint256 constant REDEMPTION_ADDRESS_COUNT = 0x100000;
/**
* @dev Emitted when account blacklist status changes
*/
event Blacklisted(address indexed account, bool isBlacklisted);
/**
* @dev Emitted when `value` tokens are minted for `to`
* @param to address to mint tokens for
* @param value amount of tokens to be minted
*/
event Mint(address indexed to, uint256 value);
/**
* @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
* @param account address to mint tokens for
* @param amount amount of tokens to be minted
*
* Emits a {Mint} event
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` cannot be blacklisted.
* - `account` cannot be a redemption address.
*/
function mint(address account, uint256 amount) external onlyOwner {
require(!isBlacklisted[account], "FavorCurrency: account is blacklisted");
require(!isRedemptionAddress(account), "FavorCurrency: account is a redemption address");
_mint(account, amount);
emit Mint(account, amount);
}
/**
* @dev Set blacklisted status for the account.
* @param account address to set blacklist flag for
* @param _isBlacklisted blacklist flag value
*
* Requirements:
*
* - `msg.sender` should be owner.
*/
function setBlacklisted(address account, bool _isBlacklisted) external onlyOwner {
require(uint160(account) >= REDEMPTION_ADDRESS_COUNT, "FavorCurrency: blacklisting of redemption address is not allowed");
isBlacklisted[account] = _isBlacklisted;
emit Blacklisted(account, _isBlacklisted);
}
/**
* @dev Set canBurn status for the account.
* @param account address to set canBurn flag for
* @param _canBurn canBurn flag value
*
* Requirements:
*
* - `msg.sender` should be owner.
*/
function setCanBurn(address account, bool _canBurn) external onlyOwner {
canBurn[account] = _canBurn;
}
/**
* @dev Check if neither account is blacklisted before performing transfer
* If transfer recipient is a redemption address, burns tokens
* @notice Transfer to redemption address will burn tokens with a 1 cent precision
* @param sender address of sender
* @param recipient address of recipient
* @param amount amount of tokens to transfer
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual override {
require(!isBlacklisted[sender], "FavorCurrency: sender is blacklisted");
require(!isBlacklisted[recipient], "FavorCurrency: recipient is blacklisted");
if (isRedemptionAddress(recipient)) {
super._transfer(sender, recipient, amount.sub(amount.mod(CENT)));
_burn(recipient, amount.sub(amount.mod(CENT)));
} else {
super._transfer(sender, recipient, amount);
}
}
/**
* @dev Requere neither accounts to be blacklisted before approval
* @param owner address of owner giving approval
* @param spender address of spender to approve for
* @param amount amount of tokens to approve
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal override {
require(!isBlacklisted[owner], "FavorCurrency: tokens owner is blacklisted");
require(!isBlacklisted[spender] || amount == 0, "FavorCurrency: tokens spender is blacklisted");
super._approve(owner, spender, amount);
}
/**
* @dev Check if tokens can be burned at address before burning
* @param account account to burn tokens from
* @param amount amount of tokens to burn
*/
function _burn(address account, uint256 amount) internal override {
require(canBurn[account], "FavorCurrency: cannot burn from this address");
super._burn(account, amount);
}
/**
* @dev First 0x100000-1 addresses (0x0000000000000000000000000000000000000001 to 0x00000000000000000000000000000000000fffff)
* are the redemption addresses.
* @param account address to check is a redemption address
*
* All transfers to redemption address will trigger token burn.
*
* @notice For transfer to succeed, canBurn must be true for redemption address
*
* @return is `account` a redemption address
*/
function isRedemptionAddress(address account) internal pure returns (bool) {
return uint160(account) < uint160(REDEMPTION_ADDRESS_COUNT) && uint160(account) != 0;
}
} | /**
* @title FavorCurrency
* @dev FavorCurrency is an ERC20 with blacklist & redemption addresses
*
* FavorCurrency is a compliant stablecoin with blacklist and redemption
* addresses. Only the owner can blacklist accounts. Redemption addresses
* are assigned automatically to the first 0x100000 addresses. Sending
* tokens to the redemption address will trigger a burn operation. Only
* the owner can mint or blacklist accounts.
*
* This contract is owned by the FavorTokenController, which manages token
* minting & admin functionality. See FavorTokenController.sol
*
* See also: BurnableTokenWithBounds.sol
*
* ~~~~ Features ~~~~
*
* Redemption Addresses
* - The first 0x100000 addresses are redemption addresses
* - Tokens sent to redemption addresses are burned
* - Redemptions are tracked off-chain
* - Cannot mint tokens to redemption addresses
*
* Blacklist
* - Owner can blacklist accounts in accordance with local regulatory bodies
* - Only a court order will merit a blacklist; blacklisting is extremely rare
*
* Burn Bounds & CanBurn
* - Owner can set min & max burn amounts
* - Only accounts flagged in canBurn are allowed to burn tokens
* - canBurn prevents tokens from being sent to the incorrect address
*
* Reclaimer Token
* - ERC20 Tokens and Ether sent to this contract can be reclaimed by the owner
*/ | NatSpecMultiLine | _approve | function _approve(
address owner,
address spender,
uint256 amount
) internal override {
require(!isBlacklisted[owner], "FavorCurrency: tokens owner is blacklisted");
require(!isBlacklisted[spender] || amount == 0, "FavorCurrency: tokens spender is blacklisted");
super._approve(owner, spender, amount);
}
| /**
* @dev Requere neither accounts to be blacklisted before approval
* @param owner address of owner giving approval
* @param spender address of spender to approve for
* @param amount amount of tokens to approve
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
3439,
3804
]
} | 9,453 |
FavorUSD | FavorCurrency.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | FavorCurrency | abstract contract FavorCurrency is BurnableTokenWithBounds {
using SafeMath for uint256;
uint256 constant CENT = 10**16;
uint256 constant REDEMPTION_ADDRESS_COUNT = 0x100000;
/**
* @dev Emitted when account blacklist status changes
*/
event Blacklisted(address indexed account, bool isBlacklisted);
/**
* @dev Emitted when `value` tokens are minted for `to`
* @param to address to mint tokens for
* @param value amount of tokens to be minted
*/
event Mint(address indexed to, uint256 value);
/**
* @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
* @param account address to mint tokens for
* @param amount amount of tokens to be minted
*
* Emits a {Mint} event
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` cannot be blacklisted.
* - `account` cannot be a redemption address.
*/
function mint(address account, uint256 amount) external onlyOwner {
require(!isBlacklisted[account], "FavorCurrency: account is blacklisted");
require(!isRedemptionAddress(account), "FavorCurrency: account is a redemption address");
_mint(account, amount);
emit Mint(account, amount);
}
/**
* @dev Set blacklisted status for the account.
* @param account address to set blacklist flag for
* @param _isBlacklisted blacklist flag value
*
* Requirements:
*
* - `msg.sender` should be owner.
*/
function setBlacklisted(address account, bool _isBlacklisted) external onlyOwner {
require(uint160(account) >= REDEMPTION_ADDRESS_COUNT, "FavorCurrency: blacklisting of redemption address is not allowed");
isBlacklisted[account] = _isBlacklisted;
emit Blacklisted(account, _isBlacklisted);
}
/**
* @dev Set canBurn status for the account.
* @param account address to set canBurn flag for
* @param _canBurn canBurn flag value
*
* Requirements:
*
* - `msg.sender` should be owner.
*/
function setCanBurn(address account, bool _canBurn) external onlyOwner {
canBurn[account] = _canBurn;
}
/**
* @dev Check if neither account is blacklisted before performing transfer
* If transfer recipient is a redemption address, burns tokens
* @notice Transfer to redemption address will burn tokens with a 1 cent precision
* @param sender address of sender
* @param recipient address of recipient
* @param amount amount of tokens to transfer
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual override {
require(!isBlacklisted[sender], "FavorCurrency: sender is blacklisted");
require(!isBlacklisted[recipient], "FavorCurrency: recipient is blacklisted");
if (isRedemptionAddress(recipient)) {
super._transfer(sender, recipient, amount.sub(amount.mod(CENT)));
_burn(recipient, amount.sub(amount.mod(CENT)));
} else {
super._transfer(sender, recipient, amount);
}
}
/**
* @dev Requere neither accounts to be blacklisted before approval
* @param owner address of owner giving approval
* @param spender address of spender to approve for
* @param amount amount of tokens to approve
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal override {
require(!isBlacklisted[owner], "FavorCurrency: tokens owner is blacklisted");
require(!isBlacklisted[spender] || amount == 0, "FavorCurrency: tokens spender is blacklisted");
super._approve(owner, spender, amount);
}
/**
* @dev Check if tokens can be burned at address before burning
* @param account account to burn tokens from
* @param amount amount of tokens to burn
*/
function _burn(address account, uint256 amount) internal override {
require(canBurn[account], "FavorCurrency: cannot burn from this address");
super._burn(account, amount);
}
/**
* @dev First 0x100000-1 addresses (0x0000000000000000000000000000000000000001 to 0x00000000000000000000000000000000000fffff)
* are the redemption addresses.
* @param account address to check is a redemption address
*
* All transfers to redemption address will trigger token burn.
*
* @notice For transfer to succeed, canBurn must be true for redemption address
*
* @return is `account` a redemption address
*/
function isRedemptionAddress(address account) internal pure returns (bool) {
return uint160(account) < uint160(REDEMPTION_ADDRESS_COUNT) && uint160(account) != 0;
}
} | /**
* @title FavorCurrency
* @dev FavorCurrency is an ERC20 with blacklist & redemption addresses
*
* FavorCurrency is a compliant stablecoin with blacklist and redemption
* addresses. Only the owner can blacklist accounts. Redemption addresses
* are assigned automatically to the first 0x100000 addresses. Sending
* tokens to the redemption address will trigger a burn operation. Only
* the owner can mint or blacklist accounts.
*
* This contract is owned by the FavorTokenController, which manages token
* minting & admin functionality. See FavorTokenController.sol
*
* See also: BurnableTokenWithBounds.sol
*
* ~~~~ Features ~~~~
*
* Redemption Addresses
* - The first 0x100000 addresses are redemption addresses
* - Tokens sent to redemption addresses are burned
* - Redemptions are tracked off-chain
* - Cannot mint tokens to redemption addresses
*
* Blacklist
* - Owner can blacklist accounts in accordance with local regulatory bodies
* - Only a court order will merit a blacklist; blacklisting is extremely rare
*
* Burn Bounds & CanBurn
* - Owner can set min & max burn amounts
* - Only accounts flagged in canBurn are allowed to burn tokens
* - canBurn prevents tokens from being sent to the incorrect address
*
* Reclaimer Token
* - ERC20 Tokens and Ether sent to this contract can be reclaimed by the owner
*/ | NatSpecMultiLine | _burn | function _burn(address account, uint256 amount) internal override {
require(canBurn[account], "FavorCurrency: cannot burn from this address");
super._burn(account, amount);
}
| /**
* @dev Check if tokens can be burned at address before burning
* @param account account to burn tokens from
* @param amount amount of tokens to burn
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
3986,
4184
]
} | 9,454 |
FavorUSD | FavorCurrency.sol | 0xe59d7e8bdc197aaa626e154020e149a14faca03b | Solidity | FavorCurrency | abstract contract FavorCurrency is BurnableTokenWithBounds {
using SafeMath for uint256;
uint256 constant CENT = 10**16;
uint256 constant REDEMPTION_ADDRESS_COUNT = 0x100000;
/**
* @dev Emitted when account blacklist status changes
*/
event Blacklisted(address indexed account, bool isBlacklisted);
/**
* @dev Emitted when `value` tokens are minted for `to`
* @param to address to mint tokens for
* @param value amount of tokens to be minted
*/
event Mint(address indexed to, uint256 value);
/**
* @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
* @param account address to mint tokens for
* @param amount amount of tokens to be minted
*
* Emits a {Mint} event
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` cannot be blacklisted.
* - `account` cannot be a redemption address.
*/
function mint(address account, uint256 amount) external onlyOwner {
require(!isBlacklisted[account], "FavorCurrency: account is blacklisted");
require(!isRedemptionAddress(account), "FavorCurrency: account is a redemption address");
_mint(account, amount);
emit Mint(account, amount);
}
/**
* @dev Set blacklisted status for the account.
* @param account address to set blacklist flag for
* @param _isBlacklisted blacklist flag value
*
* Requirements:
*
* - `msg.sender` should be owner.
*/
function setBlacklisted(address account, bool _isBlacklisted) external onlyOwner {
require(uint160(account) >= REDEMPTION_ADDRESS_COUNT, "FavorCurrency: blacklisting of redemption address is not allowed");
isBlacklisted[account] = _isBlacklisted;
emit Blacklisted(account, _isBlacklisted);
}
/**
* @dev Set canBurn status for the account.
* @param account address to set canBurn flag for
* @param _canBurn canBurn flag value
*
* Requirements:
*
* - `msg.sender` should be owner.
*/
function setCanBurn(address account, bool _canBurn) external onlyOwner {
canBurn[account] = _canBurn;
}
/**
* @dev Check if neither account is blacklisted before performing transfer
* If transfer recipient is a redemption address, burns tokens
* @notice Transfer to redemption address will burn tokens with a 1 cent precision
* @param sender address of sender
* @param recipient address of recipient
* @param amount amount of tokens to transfer
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual override {
require(!isBlacklisted[sender], "FavorCurrency: sender is blacklisted");
require(!isBlacklisted[recipient], "FavorCurrency: recipient is blacklisted");
if (isRedemptionAddress(recipient)) {
super._transfer(sender, recipient, amount.sub(amount.mod(CENT)));
_burn(recipient, amount.sub(amount.mod(CENT)));
} else {
super._transfer(sender, recipient, amount);
}
}
/**
* @dev Requere neither accounts to be blacklisted before approval
* @param owner address of owner giving approval
* @param spender address of spender to approve for
* @param amount amount of tokens to approve
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal override {
require(!isBlacklisted[owner], "FavorCurrency: tokens owner is blacklisted");
require(!isBlacklisted[spender] || amount == 0, "FavorCurrency: tokens spender is blacklisted");
super._approve(owner, spender, amount);
}
/**
* @dev Check if tokens can be burned at address before burning
* @param account account to burn tokens from
* @param amount amount of tokens to burn
*/
function _burn(address account, uint256 amount) internal override {
require(canBurn[account], "FavorCurrency: cannot burn from this address");
super._burn(account, amount);
}
/**
* @dev First 0x100000-1 addresses (0x0000000000000000000000000000000000000001 to 0x00000000000000000000000000000000000fffff)
* are the redemption addresses.
* @param account address to check is a redemption address
*
* All transfers to redemption address will trigger token burn.
*
* @notice For transfer to succeed, canBurn must be true for redemption address
*
* @return is `account` a redemption address
*/
function isRedemptionAddress(address account) internal pure returns (bool) {
return uint160(account) < uint160(REDEMPTION_ADDRESS_COUNT) && uint160(account) != 0;
}
} | /**
* @title FavorCurrency
* @dev FavorCurrency is an ERC20 with blacklist & redemption addresses
*
* FavorCurrency is a compliant stablecoin with blacklist and redemption
* addresses. Only the owner can blacklist accounts. Redemption addresses
* are assigned automatically to the first 0x100000 addresses. Sending
* tokens to the redemption address will trigger a burn operation. Only
* the owner can mint or blacklist accounts.
*
* This contract is owned by the FavorTokenController, which manages token
* minting & admin functionality. See FavorTokenController.sol
*
* See also: BurnableTokenWithBounds.sol
*
* ~~~~ Features ~~~~
*
* Redemption Addresses
* - The first 0x100000 addresses are redemption addresses
* - Tokens sent to redemption addresses are burned
* - Redemptions are tracked off-chain
* - Cannot mint tokens to redemption addresses
*
* Blacklist
* - Owner can blacklist accounts in accordance with local regulatory bodies
* - Only a court order will merit a blacklist; blacklisting is extremely rare
*
* Burn Bounds & CanBurn
* - Owner can set min & max burn amounts
* - Only accounts flagged in canBurn are allowed to burn tokens
* - canBurn prevents tokens from being sent to the incorrect address
*
* Reclaimer Token
* - ERC20 Tokens and Ether sent to this contract can be reclaimed by the owner
*/ | NatSpecMultiLine | isRedemptionAddress | function isRedemptionAddress(address account) internal pure returns (bool) {
return uint160(account) < uint160(REDEMPTION_ADDRESS_COUNT) && uint160(account) != 0;
}
| /**
* @dev First 0x100000-1 addresses (0x0000000000000000000000000000000000000001 to 0x00000000000000000000000000000000000fffff)
* are the redemption addresses.
* @param account address to check is a redemption address
*
* All transfers to redemption address will trigger token burn.
*
* @notice For transfer to succeed, canBurn must be true for redemption address
*
* @return is `account` a redemption address
*/ | NatSpecMultiLine | v0.8.0+commit.c7dfd78e | MIT | ipfs://ab27100e8b3558a4e8d3f0d334f675339a375af40333a549acb1b2f03ffab0a0 | {
"func_code_index": [
4654,
4834
]
} | 9,455 |
CompoundLens | contracts/Governance/GovernorAlpha.sol | 0xd513d22422a3062bd342ae374b4b9c20e0a9a074 | Solidity | GovernorAlpha | contract GovernorAlpha {
/// @notice The name of this contract
string public constant name = "Compound Governor Alpha";
/// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed
function quorumVotes() public pure returns (uint) { return 400000e18; } // 400,000 = 4% of Comp
/// @notice The number of votes required in order for a voter to become a proposer
function proposalThreshold() public pure returns (uint) { return 100000e18; } // 100,000 = 1% of Comp
/// @notice The maximum number of actions that can be included in a proposal
function proposalMaxOperations() public pure returns (uint) { return 10; } // 10 actions
/// @notice The delay before voting on a proposal may take place, once proposed
function votingDelay() public pure returns (uint) { return 1; } // 1 block
/// @notice The duration of voting on a proposal, in blocks
function votingPeriod() public pure returns (uint) { return 17280; } // ~3 days in blocks (assuming 15s blocks)
/// @notice The address of the Compound Protocol Timelock
TimelockInterface public timelock;
/// @notice The address of the Compound governance token
CompInterface public comp;
/// @notice The address of the Governor Guardian
address public guardian;
/// @notice The total number of proposals
uint public proposalCount;
struct Proposal {
/// @notice Unique id for looking up a proposal
uint id;
/// @notice Creator of the proposal
address proposer;
/// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds
uint eta;
/// @notice the ordered list of target addresses for calls to be made
address[] targets;
/// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made
uint[] values;
/// @notice The ordered list of function signatures to be called
string[] signatures;
/// @notice The ordered list of calldata to be passed to each call
bytes[] calldatas;
/// @notice The block at which voting begins: holders must delegate their votes prior to this block
uint startBlock;
/// @notice The block at which voting ends: votes must be cast prior to this block
uint endBlock;
/// @notice Current number of votes in favor of this proposal
uint forVotes;
/// @notice Current number of votes in opposition to this proposal
uint againstVotes;
/// @notice Flag marking whether the proposal has been canceled
bool canceled;
/// @notice Flag marking whether the proposal has been executed
bool executed;
/// @notice Receipts of ballots for the entire set of voters
mapping (address => Receipt) receipts;
}
/// @notice Ballot receipt record for a voter
struct Receipt {
/// @notice Whether or not a vote has been cast
bool hasVoted;
/// @notice Whether or not the voter supports the proposal
bool support;
/// @notice The number of votes the voter had, which were cast
uint96 votes;
}
/// @notice Possible states that a proposal may be in
enum ProposalState {
Pending,
Active,
Canceled,
Defeated,
Succeeded,
Queued,
Expired,
Executed
}
/// @notice The official record of all proposals ever proposed
mapping (uint => Proposal) public proposals;
/// @notice The latest proposal for each proposer
mapping (address => uint) public latestProposalIds;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the ballot struct used by the contract
bytes32 public constant BALLOT_TYPEHASH = keccak256("Ballot(uint256 proposalId,bool support)");
/// @notice An event emitted when a new proposal is created
event ProposalCreated(uint id, address proposer, address[] targets, uint[] values, string[] signatures, bytes[] calldatas, uint startBlock, uint endBlock, string description);
/// @notice An event emitted when a vote has been cast on a proposal
event VoteCast(address voter, uint proposalId, bool support, uint votes);
/// @notice An event emitted when a proposal has been canceled
event ProposalCanceled(uint id);
/// @notice An event emitted when a proposal has been queued in the Timelock
event ProposalQueued(uint id, uint eta);
/// @notice An event emitted when a proposal has been executed in the Timelock
event ProposalExecuted(uint id);
constructor(address timelock_, address comp_, address guardian_) public {
timelock = TimelockInterface(timelock_);
comp = CompInterface(comp_);
guardian = guardian_;
}
function propose(address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description) public returns (uint) {
require(comp.getPriorVotes(msg.sender, sub256(block.number, 1)) > proposalThreshold(), "GovernorAlpha::propose: proposer votes below proposal threshold");
require(targets.length == values.length && targets.length == signatures.length && targets.length == calldatas.length, "GovernorAlpha::propose: proposal function information arity mismatch");
require(targets.length != 0, "GovernorAlpha::propose: must provide actions");
require(targets.length <= proposalMaxOperations(), "GovernorAlpha::propose: too many actions");
uint latestProposalId = latestProposalIds[msg.sender];
if (latestProposalId != 0) {
ProposalState proposersLatestProposalState = state(latestProposalId);
require(proposersLatestProposalState != ProposalState.Active, "GovernorAlpha::propose: one live proposal per proposer, found an already active proposal");
require(proposersLatestProposalState != ProposalState.Pending, "GovernorAlpha::propose: one live proposal per proposer, found an already pending proposal");
}
uint startBlock = add256(block.number, votingDelay());
uint endBlock = add256(startBlock, votingPeriod());
proposalCount++;
Proposal memory newProposal = Proposal({
id: proposalCount,
proposer: msg.sender,
eta: 0,
targets: targets,
values: values,
signatures: signatures,
calldatas: calldatas,
startBlock: startBlock,
endBlock: endBlock,
forVotes: 0,
againstVotes: 0,
canceled: false,
executed: false
});
proposals[newProposal.id] = newProposal;
latestProposalIds[newProposal.proposer] = newProposal.id;
emit ProposalCreated(newProposal.id, msg.sender, targets, values, signatures, calldatas, startBlock, endBlock, description);
return newProposal.id;
}
function queue(uint proposalId) public {
require(state(proposalId) == ProposalState.Succeeded, "GovernorAlpha::queue: proposal can only be queued if it is succeeded");
Proposal storage proposal = proposals[proposalId];
uint eta = add256(block.timestamp, timelock.delay());
for (uint i = 0; i < proposal.targets.length; i++) {
_queueOrRevert(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], eta);
}
proposal.eta = eta;
emit ProposalQueued(proposalId, eta);
}
function _queueOrRevert(address target, uint value, string memory signature, bytes memory data, uint eta) internal {
require(!timelock.queuedTransactions(keccak256(abi.encode(target, value, signature, data, eta))), "GovernorAlpha::_queueOrRevert: proposal action already queued at eta");
timelock.queueTransaction(target, value, signature, data, eta);
}
function execute(uint proposalId) public payable {
require(state(proposalId) == ProposalState.Queued, "GovernorAlpha::execute: proposal can only be executed if it is queued");
Proposal storage proposal = proposals[proposalId];
proposal.executed = true;
for (uint i = 0; i < proposal.targets.length; i++) {
timelock.executeTransaction.value(proposal.values[i])(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta);
}
emit ProposalExecuted(proposalId);
}
function cancel(uint proposalId) public {
ProposalState state = state(proposalId);
require(state != ProposalState.Executed, "GovernorAlpha::cancel: cannot cancel executed proposal");
Proposal storage proposal = proposals[proposalId];
require(msg.sender == guardian || comp.getPriorVotes(proposal.proposer, sub256(block.number, 1)) < proposalThreshold(), "GovernorAlpha::cancel: proposer above threshold");
proposal.canceled = true;
for (uint i = 0; i < proposal.targets.length; i++) {
timelock.cancelTransaction(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta);
}
emit ProposalCanceled(proposalId);
}
function getActions(uint proposalId) public view returns (address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas) {
Proposal storage p = proposals[proposalId];
return (p.targets, p.values, p.signatures, p.calldatas);
}
function getReceipt(uint proposalId, address voter) public view returns (Receipt memory) {
return proposals[proposalId].receipts[voter];
}
function state(uint proposalId) public view returns (ProposalState) {
require(proposalCount >= proposalId && proposalId > 0, "GovernorAlpha::state: invalid proposal id");
Proposal storage proposal = proposals[proposalId];
if (proposal.canceled) {
return ProposalState.Canceled;
} else if (block.number <= proposal.startBlock) {
return ProposalState.Pending;
} else if (block.number <= proposal.endBlock) {
return ProposalState.Active;
} else if (proposal.forVotes <= proposal.againstVotes || proposal.forVotes < quorumVotes()) {
return ProposalState.Defeated;
} else if (proposal.eta == 0) {
return ProposalState.Succeeded;
} else if (proposal.executed) {
return ProposalState.Executed;
} else if (block.timestamp >= add256(proposal.eta, timelock.GRACE_PERIOD())) {
return ProposalState.Expired;
} else {
return ProposalState.Queued;
}
}
function castVote(uint proposalId, bool support) public {
return _castVote(msg.sender, proposalId, support);
}
function castVoteBySig(uint proposalId, bool support, uint8 v, bytes32 r, bytes32 s) public {
bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this)));
bytes32 structHash = keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, support));
bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "GovernorAlpha::castVoteBySig: invalid signature");
return _castVote(signatory, proposalId, support);
}
function _castVote(address voter, uint proposalId, bool support) internal {
require(state(proposalId) == ProposalState.Active, "GovernorAlpha::_castVote: voting is closed");
Proposal storage proposal = proposals[proposalId];
Receipt storage receipt = proposal.receipts[voter];
require(receipt.hasVoted == false, "GovernorAlpha::_castVote: voter already voted");
uint96 votes = comp.getPriorVotes(voter, proposal.startBlock);
if (support) {
proposal.forVotes = add256(proposal.forVotes, votes);
} else {
proposal.againstVotes = add256(proposal.againstVotes, votes);
}
receipt.hasVoted = true;
receipt.support = support;
receipt.votes = votes;
emit VoteCast(voter, proposalId, support, votes);
}
function __acceptAdmin() public {
require(msg.sender == guardian, "GovernorAlpha::__acceptAdmin: sender must be gov guardian");
timelock.acceptAdmin();
}
function __abdicate() public {
require(msg.sender == guardian, "GovernorAlpha::__abdicate: sender must be gov guardian");
guardian = address(0);
}
function __queueSetTimelockPendingAdmin(address newPendingAdmin, uint eta) public {
require(msg.sender == guardian, "GovernorAlpha::__queueSetTimelockPendingAdmin: sender must be gov guardian");
timelock.queueTransaction(address(timelock), 0, "setPendingAdmin(address)", abi.encode(newPendingAdmin), eta);
}
function __executeSetTimelockPendingAdmin(address newPendingAdmin, uint eta) public {
require(msg.sender == guardian, "GovernorAlpha::__executeSetTimelockPendingAdmin: sender must be gov guardian");
timelock.executeTransaction(address(timelock), 0, "setPendingAdmin(address)", abi.encode(newPendingAdmin), eta);
}
function add256(uint256 a, uint256 b) internal pure returns (uint) {
uint c = a + b;
require(c >= a, "addition overflow");
return c;
}
function sub256(uint256 a, uint256 b) internal pure returns (uint) {
require(b <= a, "subtraction underflow");
return a - b;
}
function getChainId() internal pure returns (uint) {
uint chainId;
assembly { chainId := chainid() }
return chainId;
}
} | quorumVotes | function quorumVotes() public pure returns (uint) { return 400000e18; } // 400,000 = 4% of Comp
| /// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed | NatSpecSingleLine | v0.5.16+commit.9c3226ce | None | {
"func_code_index": [
261,
360
]
} | 9,456 |
|||
CompoundLens | contracts/Governance/GovernorAlpha.sol | 0xd513d22422a3062bd342ae374b4b9c20e0a9a074 | Solidity | GovernorAlpha | contract GovernorAlpha {
/// @notice The name of this contract
string public constant name = "Compound Governor Alpha";
/// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed
function quorumVotes() public pure returns (uint) { return 400000e18; } // 400,000 = 4% of Comp
/// @notice The number of votes required in order for a voter to become a proposer
function proposalThreshold() public pure returns (uint) { return 100000e18; } // 100,000 = 1% of Comp
/// @notice The maximum number of actions that can be included in a proposal
function proposalMaxOperations() public pure returns (uint) { return 10; } // 10 actions
/// @notice The delay before voting on a proposal may take place, once proposed
function votingDelay() public pure returns (uint) { return 1; } // 1 block
/// @notice The duration of voting on a proposal, in blocks
function votingPeriod() public pure returns (uint) { return 17280; } // ~3 days in blocks (assuming 15s blocks)
/// @notice The address of the Compound Protocol Timelock
TimelockInterface public timelock;
/// @notice The address of the Compound governance token
CompInterface public comp;
/// @notice The address of the Governor Guardian
address public guardian;
/// @notice The total number of proposals
uint public proposalCount;
struct Proposal {
/// @notice Unique id for looking up a proposal
uint id;
/// @notice Creator of the proposal
address proposer;
/// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds
uint eta;
/// @notice the ordered list of target addresses for calls to be made
address[] targets;
/// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made
uint[] values;
/// @notice The ordered list of function signatures to be called
string[] signatures;
/// @notice The ordered list of calldata to be passed to each call
bytes[] calldatas;
/// @notice The block at which voting begins: holders must delegate their votes prior to this block
uint startBlock;
/// @notice The block at which voting ends: votes must be cast prior to this block
uint endBlock;
/// @notice Current number of votes in favor of this proposal
uint forVotes;
/// @notice Current number of votes in opposition to this proposal
uint againstVotes;
/// @notice Flag marking whether the proposal has been canceled
bool canceled;
/// @notice Flag marking whether the proposal has been executed
bool executed;
/// @notice Receipts of ballots for the entire set of voters
mapping (address => Receipt) receipts;
}
/// @notice Ballot receipt record for a voter
struct Receipt {
/// @notice Whether or not a vote has been cast
bool hasVoted;
/// @notice Whether or not the voter supports the proposal
bool support;
/// @notice The number of votes the voter had, which were cast
uint96 votes;
}
/// @notice Possible states that a proposal may be in
enum ProposalState {
Pending,
Active,
Canceled,
Defeated,
Succeeded,
Queued,
Expired,
Executed
}
/// @notice The official record of all proposals ever proposed
mapping (uint => Proposal) public proposals;
/// @notice The latest proposal for each proposer
mapping (address => uint) public latestProposalIds;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the ballot struct used by the contract
bytes32 public constant BALLOT_TYPEHASH = keccak256("Ballot(uint256 proposalId,bool support)");
/// @notice An event emitted when a new proposal is created
event ProposalCreated(uint id, address proposer, address[] targets, uint[] values, string[] signatures, bytes[] calldatas, uint startBlock, uint endBlock, string description);
/// @notice An event emitted when a vote has been cast on a proposal
event VoteCast(address voter, uint proposalId, bool support, uint votes);
/// @notice An event emitted when a proposal has been canceled
event ProposalCanceled(uint id);
/// @notice An event emitted when a proposal has been queued in the Timelock
event ProposalQueued(uint id, uint eta);
/// @notice An event emitted when a proposal has been executed in the Timelock
event ProposalExecuted(uint id);
constructor(address timelock_, address comp_, address guardian_) public {
timelock = TimelockInterface(timelock_);
comp = CompInterface(comp_);
guardian = guardian_;
}
function propose(address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description) public returns (uint) {
require(comp.getPriorVotes(msg.sender, sub256(block.number, 1)) > proposalThreshold(), "GovernorAlpha::propose: proposer votes below proposal threshold");
require(targets.length == values.length && targets.length == signatures.length && targets.length == calldatas.length, "GovernorAlpha::propose: proposal function information arity mismatch");
require(targets.length != 0, "GovernorAlpha::propose: must provide actions");
require(targets.length <= proposalMaxOperations(), "GovernorAlpha::propose: too many actions");
uint latestProposalId = latestProposalIds[msg.sender];
if (latestProposalId != 0) {
ProposalState proposersLatestProposalState = state(latestProposalId);
require(proposersLatestProposalState != ProposalState.Active, "GovernorAlpha::propose: one live proposal per proposer, found an already active proposal");
require(proposersLatestProposalState != ProposalState.Pending, "GovernorAlpha::propose: one live proposal per proposer, found an already pending proposal");
}
uint startBlock = add256(block.number, votingDelay());
uint endBlock = add256(startBlock, votingPeriod());
proposalCount++;
Proposal memory newProposal = Proposal({
id: proposalCount,
proposer: msg.sender,
eta: 0,
targets: targets,
values: values,
signatures: signatures,
calldatas: calldatas,
startBlock: startBlock,
endBlock: endBlock,
forVotes: 0,
againstVotes: 0,
canceled: false,
executed: false
});
proposals[newProposal.id] = newProposal;
latestProposalIds[newProposal.proposer] = newProposal.id;
emit ProposalCreated(newProposal.id, msg.sender, targets, values, signatures, calldatas, startBlock, endBlock, description);
return newProposal.id;
}
function queue(uint proposalId) public {
require(state(proposalId) == ProposalState.Succeeded, "GovernorAlpha::queue: proposal can only be queued if it is succeeded");
Proposal storage proposal = proposals[proposalId];
uint eta = add256(block.timestamp, timelock.delay());
for (uint i = 0; i < proposal.targets.length; i++) {
_queueOrRevert(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], eta);
}
proposal.eta = eta;
emit ProposalQueued(proposalId, eta);
}
function _queueOrRevert(address target, uint value, string memory signature, bytes memory data, uint eta) internal {
require(!timelock.queuedTransactions(keccak256(abi.encode(target, value, signature, data, eta))), "GovernorAlpha::_queueOrRevert: proposal action already queued at eta");
timelock.queueTransaction(target, value, signature, data, eta);
}
function execute(uint proposalId) public payable {
require(state(proposalId) == ProposalState.Queued, "GovernorAlpha::execute: proposal can only be executed if it is queued");
Proposal storage proposal = proposals[proposalId];
proposal.executed = true;
for (uint i = 0; i < proposal.targets.length; i++) {
timelock.executeTransaction.value(proposal.values[i])(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta);
}
emit ProposalExecuted(proposalId);
}
function cancel(uint proposalId) public {
ProposalState state = state(proposalId);
require(state != ProposalState.Executed, "GovernorAlpha::cancel: cannot cancel executed proposal");
Proposal storage proposal = proposals[proposalId];
require(msg.sender == guardian || comp.getPriorVotes(proposal.proposer, sub256(block.number, 1)) < proposalThreshold(), "GovernorAlpha::cancel: proposer above threshold");
proposal.canceled = true;
for (uint i = 0; i < proposal.targets.length; i++) {
timelock.cancelTransaction(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta);
}
emit ProposalCanceled(proposalId);
}
function getActions(uint proposalId) public view returns (address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas) {
Proposal storage p = proposals[proposalId];
return (p.targets, p.values, p.signatures, p.calldatas);
}
function getReceipt(uint proposalId, address voter) public view returns (Receipt memory) {
return proposals[proposalId].receipts[voter];
}
function state(uint proposalId) public view returns (ProposalState) {
require(proposalCount >= proposalId && proposalId > 0, "GovernorAlpha::state: invalid proposal id");
Proposal storage proposal = proposals[proposalId];
if (proposal.canceled) {
return ProposalState.Canceled;
} else if (block.number <= proposal.startBlock) {
return ProposalState.Pending;
} else if (block.number <= proposal.endBlock) {
return ProposalState.Active;
} else if (proposal.forVotes <= proposal.againstVotes || proposal.forVotes < quorumVotes()) {
return ProposalState.Defeated;
} else if (proposal.eta == 0) {
return ProposalState.Succeeded;
} else if (proposal.executed) {
return ProposalState.Executed;
} else if (block.timestamp >= add256(proposal.eta, timelock.GRACE_PERIOD())) {
return ProposalState.Expired;
} else {
return ProposalState.Queued;
}
}
function castVote(uint proposalId, bool support) public {
return _castVote(msg.sender, proposalId, support);
}
function castVoteBySig(uint proposalId, bool support, uint8 v, bytes32 r, bytes32 s) public {
bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this)));
bytes32 structHash = keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, support));
bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "GovernorAlpha::castVoteBySig: invalid signature");
return _castVote(signatory, proposalId, support);
}
function _castVote(address voter, uint proposalId, bool support) internal {
require(state(proposalId) == ProposalState.Active, "GovernorAlpha::_castVote: voting is closed");
Proposal storage proposal = proposals[proposalId];
Receipt storage receipt = proposal.receipts[voter];
require(receipt.hasVoted == false, "GovernorAlpha::_castVote: voter already voted");
uint96 votes = comp.getPriorVotes(voter, proposal.startBlock);
if (support) {
proposal.forVotes = add256(proposal.forVotes, votes);
} else {
proposal.againstVotes = add256(proposal.againstVotes, votes);
}
receipt.hasVoted = true;
receipt.support = support;
receipt.votes = votes;
emit VoteCast(voter, proposalId, support, votes);
}
function __acceptAdmin() public {
require(msg.sender == guardian, "GovernorAlpha::__acceptAdmin: sender must be gov guardian");
timelock.acceptAdmin();
}
function __abdicate() public {
require(msg.sender == guardian, "GovernorAlpha::__abdicate: sender must be gov guardian");
guardian = address(0);
}
function __queueSetTimelockPendingAdmin(address newPendingAdmin, uint eta) public {
require(msg.sender == guardian, "GovernorAlpha::__queueSetTimelockPendingAdmin: sender must be gov guardian");
timelock.queueTransaction(address(timelock), 0, "setPendingAdmin(address)", abi.encode(newPendingAdmin), eta);
}
function __executeSetTimelockPendingAdmin(address newPendingAdmin, uint eta) public {
require(msg.sender == guardian, "GovernorAlpha::__executeSetTimelockPendingAdmin: sender must be gov guardian");
timelock.executeTransaction(address(timelock), 0, "setPendingAdmin(address)", abi.encode(newPendingAdmin), eta);
}
function add256(uint256 a, uint256 b) internal pure returns (uint) {
uint c = a + b;
require(c >= a, "addition overflow");
return c;
}
function sub256(uint256 a, uint256 b) internal pure returns (uint) {
require(b <= a, "subtraction underflow");
return a - b;
}
function getChainId() internal pure returns (uint) {
uint chainId;
assembly { chainId := chainid() }
return chainId;
}
} | proposalThreshold | function proposalThreshold() public pure returns (uint) { return 100000e18; } // 100,000 = 1% of Comp
| /// @notice The number of votes required in order for a voter to become a proposer | NatSpecSingleLine | v0.5.16+commit.9c3226ce | None | {
"func_code_index": [
449,
554
]
} | 9,457 |
|||
CompoundLens | contracts/Governance/GovernorAlpha.sol | 0xd513d22422a3062bd342ae374b4b9c20e0a9a074 | Solidity | GovernorAlpha | contract GovernorAlpha {
/// @notice The name of this contract
string public constant name = "Compound Governor Alpha";
/// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed
function quorumVotes() public pure returns (uint) { return 400000e18; } // 400,000 = 4% of Comp
/// @notice The number of votes required in order for a voter to become a proposer
function proposalThreshold() public pure returns (uint) { return 100000e18; } // 100,000 = 1% of Comp
/// @notice The maximum number of actions that can be included in a proposal
function proposalMaxOperations() public pure returns (uint) { return 10; } // 10 actions
/// @notice The delay before voting on a proposal may take place, once proposed
function votingDelay() public pure returns (uint) { return 1; } // 1 block
/// @notice The duration of voting on a proposal, in blocks
function votingPeriod() public pure returns (uint) { return 17280; } // ~3 days in blocks (assuming 15s blocks)
/// @notice The address of the Compound Protocol Timelock
TimelockInterface public timelock;
/// @notice The address of the Compound governance token
CompInterface public comp;
/// @notice The address of the Governor Guardian
address public guardian;
/// @notice The total number of proposals
uint public proposalCount;
struct Proposal {
/// @notice Unique id for looking up a proposal
uint id;
/// @notice Creator of the proposal
address proposer;
/// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds
uint eta;
/// @notice the ordered list of target addresses for calls to be made
address[] targets;
/// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made
uint[] values;
/// @notice The ordered list of function signatures to be called
string[] signatures;
/// @notice The ordered list of calldata to be passed to each call
bytes[] calldatas;
/// @notice The block at which voting begins: holders must delegate their votes prior to this block
uint startBlock;
/// @notice The block at which voting ends: votes must be cast prior to this block
uint endBlock;
/// @notice Current number of votes in favor of this proposal
uint forVotes;
/// @notice Current number of votes in opposition to this proposal
uint againstVotes;
/// @notice Flag marking whether the proposal has been canceled
bool canceled;
/// @notice Flag marking whether the proposal has been executed
bool executed;
/// @notice Receipts of ballots for the entire set of voters
mapping (address => Receipt) receipts;
}
/// @notice Ballot receipt record for a voter
struct Receipt {
/// @notice Whether or not a vote has been cast
bool hasVoted;
/// @notice Whether or not the voter supports the proposal
bool support;
/// @notice The number of votes the voter had, which were cast
uint96 votes;
}
/// @notice Possible states that a proposal may be in
enum ProposalState {
Pending,
Active,
Canceled,
Defeated,
Succeeded,
Queued,
Expired,
Executed
}
/// @notice The official record of all proposals ever proposed
mapping (uint => Proposal) public proposals;
/// @notice The latest proposal for each proposer
mapping (address => uint) public latestProposalIds;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the ballot struct used by the contract
bytes32 public constant BALLOT_TYPEHASH = keccak256("Ballot(uint256 proposalId,bool support)");
/// @notice An event emitted when a new proposal is created
event ProposalCreated(uint id, address proposer, address[] targets, uint[] values, string[] signatures, bytes[] calldatas, uint startBlock, uint endBlock, string description);
/// @notice An event emitted when a vote has been cast on a proposal
event VoteCast(address voter, uint proposalId, bool support, uint votes);
/// @notice An event emitted when a proposal has been canceled
event ProposalCanceled(uint id);
/// @notice An event emitted when a proposal has been queued in the Timelock
event ProposalQueued(uint id, uint eta);
/// @notice An event emitted when a proposal has been executed in the Timelock
event ProposalExecuted(uint id);
constructor(address timelock_, address comp_, address guardian_) public {
timelock = TimelockInterface(timelock_);
comp = CompInterface(comp_);
guardian = guardian_;
}
function propose(address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description) public returns (uint) {
require(comp.getPriorVotes(msg.sender, sub256(block.number, 1)) > proposalThreshold(), "GovernorAlpha::propose: proposer votes below proposal threshold");
require(targets.length == values.length && targets.length == signatures.length && targets.length == calldatas.length, "GovernorAlpha::propose: proposal function information arity mismatch");
require(targets.length != 0, "GovernorAlpha::propose: must provide actions");
require(targets.length <= proposalMaxOperations(), "GovernorAlpha::propose: too many actions");
uint latestProposalId = latestProposalIds[msg.sender];
if (latestProposalId != 0) {
ProposalState proposersLatestProposalState = state(latestProposalId);
require(proposersLatestProposalState != ProposalState.Active, "GovernorAlpha::propose: one live proposal per proposer, found an already active proposal");
require(proposersLatestProposalState != ProposalState.Pending, "GovernorAlpha::propose: one live proposal per proposer, found an already pending proposal");
}
uint startBlock = add256(block.number, votingDelay());
uint endBlock = add256(startBlock, votingPeriod());
proposalCount++;
Proposal memory newProposal = Proposal({
id: proposalCount,
proposer: msg.sender,
eta: 0,
targets: targets,
values: values,
signatures: signatures,
calldatas: calldatas,
startBlock: startBlock,
endBlock: endBlock,
forVotes: 0,
againstVotes: 0,
canceled: false,
executed: false
});
proposals[newProposal.id] = newProposal;
latestProposalIds[newProposal.proposer] = newProposal.id;
emit ProposalCreated(newProposal.id, msg.sender, targets, values, signatures, calldatas, startBlock, endBlock, description);
return newProposal.id;
}
function queue(uint proposalId) public {
require(state(proposalId) == ProposalState.Succeeded, "GovernorAlpha::queue: proposal can only be queued if it is succeeded");
Proposal storage proposal = proposals[proposalId];
uint eta = add256(block.timestamp, timelock.delay());
for (uint i = 0; i < proposal.targets.length; i++) {
_queueOrRevert(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], eta);
}
proposal.eta = eta;
emit ProposalQueued(proposalId, eta);
}
function _queueOrRevert(address target, uint value, string memory signature, bytes memory data, uint eta) internal {
require(!timelock.queuedTransactions(keccak256(abi.encode(target, value, signature, data, eta))), "GovernorAlpha::_queueOrRevert: proposal action already queued at eta");
timelock.queueTransaction(target, value, signature, data, eta);
}
function execute(uint proposalId) public payable {
require(state(proposalId) == ProposalState.Queued, "GovernorAlpha::execute: proposal can only be executed if it is queued");
Proposal storage proposal = proposals[proposalId];
proposal.executed = true;
for (uint i = 0; i < proposal.targets.length; i++) {
timelock.executeTransaction.value(proposal.values[i])(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta);
}
emit ProposalExecuted(proposalId);
}
function cancel(uint proposalId) public {
ProposalState state = state(proposalId);
require(state != ProposalState.Executed, "GovernorAlpha::cancel: cannot cancel executed proposal");
Proposal storage proposal = proposals[proposalId];
require(msg.sender == guardian || comp.getPriorVotes(proposal.proposer, sub256(block.number, 1)) < proposalThreshold(), "GovernorAlpha::cancel: proposer above threshold");
proposal.canceled = true;
for (uint i = 0; i < proposal.targets.length; i++) {
timelock.cancelTransaction(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta);
}
emit ProposalCanceled(proposalId);
}
function getActions(uint proposalId) public view returns (address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas) {
Proposal storage p = proposals[proposalId];
return (p.targets, p.values, p.signatures, p.calldatas);
}
function getReceipt(uint proposalId, address voter) public view returns (Receipt memory) {
return proposals[proposalId].receipts[voter];
}
function state(uint proposalId) public view returns (ProposalState) {
require(proposalCount >= proposalId && proposalId > 0, "GovernorAlpha::state: invalid proposal id");
Proposal storage proposal = proposals[proposalId];
if (proposal.canceled) {
return ProposalState.Canceled;
} else if (block.number <= proposal.startBlock) {
return ProposalState.Pending;
} else if (block.number <= proposal.endBlock) {
return ProposalState.Active;
} else if (proposal.forVotes <= proposal.againstVotes || proposal.forVotes < quorumVotes()) {
return ProposalState.Defeated;
} else if (proposal.eta == 0) {
return ProposalState.Succeeded;
} else if (proposal.executed) {
return ProposalState.Executed;
} else if (block.timestamp >= add256(proposal.eta, timelock.GRACE_PERIOD())) {
return ProposalState.Expired;
} else {
return ProposalState.Queued;
}
}
function castVote(uint proposalId, bool support) public {
return _castVote(msg.sender, proposalId, support);
}
function castVoteBySig(uint proposalId, bool support, uint8 v, bytes32 r, bytes32 s) public {
bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this)));
bytes32 structHash = keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, support));
bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "GovernorAlpha::castVoteBySig: invalid signature");
return _castVote(signatory, proposalId, support);
}
function _castVote(address voter, uint proposalId, bool support) internal {
require(state(proposalId) == ProposalState.Active, "GovernorAlpha::_castVote: voting is closed");
Proposal storage proposal = proposals[proposalId];
Receipt storage receipt = proposal.receipts[voter];
require(receipt.hasVoted == false, "GovernorAlpha::_castVote: voter already voted");
uint96 votes = comp.getPriorVotes(voter, proposal.startBlock);
if (support) {
proposal.forVotes = add256(proposal.forVotes, votes);
} else {
proposal.againstVotes = add256(proposal.againstVotes, votes);
}
receipt.hasVoted = true;
receipt.support = support;
receipt.votes = votes;
emit VoteCast(voter, proposalId, support, votes);
}
function __acceptAdmin() public {
require(msg.sender == guardian, "GovernorAlpha::__acceptAdmin: sender must be gov guardian");
timelock.acceptAdmin();
}
function __abdicate() public {
require(msg.sender == guardian, "GovernorAlpha::__abdicate: sender must be gov guardian");
guardian = address(0);
}
function __queueSetTimelockPendingAdmin(address newPendingAdmin, uint eta) public {
require(msg.sender == guardian, "GovernorAlpha::__queueSetTimelockPendingAdmin: sender must be gov guardian");
timelock.queueTransaction(address(timelock), 0, "setPendingAdmin(address)", abi.encode(newPendingAdmin), eta);
}
function __executeSetTimelockPendingAdmin(address newPendingAdmin, uint eta) public {
require(msg.sender == guardian, "GovernorAlpha::__executeSetTimelockPendingAdmin: sender must be gov guardian");
timelock.executeTransaction(address(timelock), 0, "setPendingAdmin(address)", abi.encode(newPendingAdmin), eta);
}
function add256(uint256 a, uint256 b) internal pure returns (uint) {
uint c = a + b;
require(c >= a, "addition overflow");
return c;
}
function sub256(uint256 a, uint256 b) internal pure returns (uint) {
require(b <= a, "subtraction underflow");
return a - b;
}
function getChainId() internal pure returns (uint) {
uint chainId;
assembly { chainId := chainid() }
return chainId;
}
} | proposalMaxOperations | function proposalMaxOperations() public pure returns (uint) { return 10; } // 10 actions
| /// @notice The maximum number of actions that can be included in a proposal | NatSpecSingleLine | v0.5.16+commit.9c3226ce | None | {
"func_code_index": [
637,
729
]
} | 9,458 |
|||
CompoundLens | contracts/Governance/GovernorAlpha.sol | 0xd513d22422a3062bd342ae374b4b9c20e0a9a074 | Solidity | GovernorAlpha | contract GovernorAlpha {
/// @notice The name of this contract
string public constant name = "Compound Governor Alpha";
/// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed
function quorumVotes() public pure returns (uint) { return 400000e18; } // 400,000 = 4% of Comp
/// @notice The number of votes required in order for a voter to become a proposer
function proposalThreshold() public pure returns (uint) { return 100000e18; } // 100,000 = 1% of Comp
/// @notice The maximum number of actions that can be included in a proposal
function proposalMaxOperations() public pure returns (uint) { return 10; } // 10 actions
/// @notice The delay before voting on a proposal may take place, once proposed
function votingDelay() public pure returns (uint) { return 1; } // 1 block
/// @notice The duration of voting on a proposal, in blocks
function votingPeriod() public pure returns (uint) { return 17280; } // ~3 days in blocks (assuming 15s blocks)
/// @notice The address of the Compound Protocol Timelock
TimelockInterface public timelock;
/// @notice The address of the Compound governance token
CompInterface public comp;
/// @notice The address of the Governor Guardian
address public guardian;
/// @notice The total number of proposals
uint public proposalCount;
struct Proposal {
/// @notice Unique id for looking up a proposal
uint id;
/// @notice Creator of the proposal
address proposer;
/// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds
uint eta;
/// @notice the ordered list of target addresses for calls to be made
address[] targets;
/// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made
uint[] values;
/// @notice The ordered list of function signatures to be called
string[] signatures;
/// @notice The ordered list of calldata to be passed to each call
bytes[] calldatas;
/// @notice The block at which voting begins: holders must delegate their votes prior to this block
uint startBlock;
/// @notice The block at which voting ends: votes must be cast prior to this block
uint endBlock;
/// @notice Current number of votes in favor of this proposal
uint forVotes;
/// @notice Current number of votes in opposition to this proposal
uint againstVotes;
/// @notice Flag marking whether the proposal has been canceled
bool canceled;
/// @notice Flag marking whether the proposal has been executed
bool executed;
/// @notice Receipts of ballots for the entire set of voters
mapping (address => Receipt) receipts;
}
/// @notice Ballot receipt record for a voter
struct Receipt {
/// @notice Whether or not a vote has been cast
bool hasVoted;
/// @notice Whether or not the voter supports the proposal
bool support;
/// @notice The number of votes the voter had, which were cast
uint96 votes;
}
/// @notice Possible states that a proposal may be in
enum ProposalState {
Pending,
Active,
Canceled,
Defeated,
Succeeded,
Queued,
Expired,
Executed
}
/// @notice The official record of all proposals ever proposed
mapping (uint => Proposal) public proposals;
/// @notice The latest proposal for each proposer
mapping (address => uint) public latestProposalIds;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the ballot struct used by the contract
bytes32 public constant BALLOT_TYPEHASH = keccak256("Ballot(uint256 proposalId,bool support)");
/// @notice An event emitted when a new proposal is created
event ProposalCreated(uint id, address proposer, address[] targets, uint[] values, string[] signatures, bytes[] calldatas, uint startBlock, uint endBlock, string description);
/// @notice An event emitted when a vote has been cast on a proposal
event VoteCast(address voter, uint proposalId, bool support, uint votes);
/// @notice An event emitted when a proposal has been canceled
event ProposalCanceled(uint id);
/// @notice An event emitted when a proposal has been queued in the Timelock
event ProposalQueued(uint id, uint eta);
/// @notice An event emitted when a proposal has been executed in the Timelock
event ProposalExecuted(uint id);
constructor(address timelock_, address comp_, address guardian_) public {
timelock = TimelockInterface(timelock_);
comp = CompInterface(comp_);
guardian = guardian_;
}
function propose(address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description) public returns (uint) {
require(comp.getPriorVotes(msg.sender, sub256(block.number, 1)) > proposalThreshold(), "GovernorAlpha::propose: proposer votes below proposal threshold");
require(targets.length == values.length && targets.length == signatures.length && targets.length == calldatas.length, "GovernorAlpha::propose: proposal function information arity mismatch");
require(targets.length != 0, "GovernorAlpha::propose: must provide actions");
require(targets.length <= proposalMaxOperations(), "GovernorAlpha::propose: too many actions");
uint latestProposalId = latestProposalIds[msg.sender];
if (latestProposalId != 0) {
ProposalState proposersLatestProposalState = state(latestProposalId);
require(proposersLatestProposalState != ProposalState.Active, "GovernorAlpha::propose: one live proposal per proposer, found an already active proposal");
require(proposersLatestProposalState != ProposalState.Pending, "GovernorAlpha::propose: one live proposal per proposer, found an already pending proposal");
}
uint startBlock = add256(block.number, votingDelay());
uint endBlock = add256(startBlock, votingPeriod());
proposalCount++;
Proposal memory newProposal = Proposal({
id: proposalCount,
proposer: msg.sender,
eta: 0,
targets: targets,
values: values,
signatures: signatures,
calldatas: calldatas,
startBlock: startBlock,
endBlock: endBlock,
forVotes: 0,
againstVotes: 0,
canceled: false,
executed: false
});
proposals[newProposal.id] = newProposal;
latestProposalIds[newProposal.proposer] = newProposal.id;
emit ProposalCreated(newProposal.id, msg.sender, targets, values, signatures, calldatas, startBlock, endBlock, description);
return newProposal.id;
}
function queue(uint proposalId) public {
require(state(proposalId) == ProposalState.Succeeded, "GovernorAlpha::queue: proposal can only be queued if it is succeeded");
Proposal storage proposal = proposals[proposalId];
uint eta = add256(block.timestamp, timelock.delay());
for (uint i = 0; i < proposal.targets.length; i++) {
_queueOrRevert(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], eta);
}
proposal.eta = eta;
emit ProposalQueued(proposalId, eta);
}
function _queueOrRevert(address target, uint value, string memory signature, bytes memory data, uint eta) internal {
require(!timelock.queuedTransactions(keccak256(abi.encode(target, value, signature, data, eta))), "GovernorAlpha::_queueOrRevert: proposal action already queued at eta");
timelock.queueTransaction(target, value, signature, data, eta);
}
function execute(uint proposalId) public payable {
require(state(proposalId) == ProposalState.Queued, "GovernorAlpha::execute: proposal can only be executed if it is queued");
Proposal storage proposal = proposals[proposalId];
proposal.executed = true;
for (uint i = 0; i < proposal.targets.length; i++) {
timelock.executeTransaction.value(proposal.values[i])(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta);
}
emit ProposalExecuted(proposalId);
}
function cancel(uint proposalId) public {
ProposalState state = state(proposalId);
require(state != ProposalState.Executed, "GovernorAlpha::cancel: cannot cancel executed proposal");
Proposal storage proposal = proposals[proposalId];
require(msg.sender == guardian || comp.getPriorVotes(proposal.proposer, sub256(block.number, 1)) < proposalThreshold(), "GovernorAlpha::cancel: proposer above threshold");
proposal.canceled = true;
for (uint i = 0; i < proposal.targets.length; i++) {
timelock.cancelTransaction(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta);
}
emit ProposalCanceled(proposalId);
}
function getActions(uint proposalId) public view returns (address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas) {
Proposal storage p = proposals[proposalId];
return (p.targets, p.values, p.signatures, p.calldatas);
}
function getReceipt(uint proposalId, address voter) public view returns (Receipt memory) {
return proposals[proposalId].receipts[voter];
}
function state(uint proposalId) public view returns (ProposalState) {
require(proposalCount >= proposalId && proposalId > 0, "GovernorAlpha::state: invalid proposal id");
Proposal storage proposal = proposals[proposalId];
if (proposal.canceled) {
return ProposalState.Canceled;
} else if (block.number <= proposal.startBlock) {
return ProposalState.Pending;
} else if (block.number <= proposal.endBlock) {
return ProposalState.Active;
} else if (proposal.forVotes <= proposal.againstVotes || proposal.forVotes < quorumVotes()) {
return ProposalState.Defeated;
} else if (proposal.eta == 0) {
return ProposalState.Succeeded;
} else if (proposal.executed) {
return ProposalState.Executed;
} else if (block.timestamp >= add256(proposal.eta, timelock.GRACE_PERIOD())) {
return ProposalState.Expired;
} else {
return ProposalState.Queued;
}
}
function castVote(uint proposalId, bool support) public {
return _castVote(msg.sender, proposalId, support);
}
function castVoteBySig(uint proposalId, bool support, uint8 v, bytes32 r, bytes32 s) public {
bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this)));
bytes32 structHash = keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, support));
bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "GovernorAlpha::castVoteBySig: invalid signature");
return _castVote(signatory, proposalId, support);
}
function _castVote(address voter, uint proposalId, bool support) internal {
require(state(proposalId) == ProposalState.Active, "GovernorAlpha::_castVote: voting is closed");
Proposal storage proposal = proposals[proposalId];
Receipt storage receipt = proposal.receipts[voter];
require(receipt.hasVoted == false, "GovernorAlpha::_castVote: voter already voted");
uint96 votes = comp.getPriorVotes(voter, proposal.startBlock);
if (support) {
proposal.forVotes = add256(proposal.forVotes, votes);
} else {
proposal.againstVotes = add256(proposal.againstVotes, votes);
}
receipt.hasVoted = true;
receipt.support = support;
receipt.votes = votes;
emit VoteCast(voter, proposalId, support, votes);
}
function __acceptAdmin() public {
require(msg.sender == guardian, "GovernorAlpha::__acceptAdmin: sender must be gov guardian");
timelock.acceptAdmin();
}
function __abdicate() public {
require(msg.sender == guardian, "GovernorAlpha::__abdicate: sender must be gov guardian");
guardian = address(0);
}
function __queueSetTimelockPendingAdmin(address newPendingAdmin, uint eta) public {
require(msg.sender == guardian, "GovernorAlpha::__queueSetTimelockPendingAdmin: sender must be gov guardian");
timelock.queueTransaction(address(timelock), 0, "setPendingAdmin(address)", abi.encode(newPendingAdmin), eta);
}
function __executeSetTimelockPendingAdmin(address newPendingAdmin, uint eta) public {
require(msg.sender == guardian, "GovernorAlpha::__executeSetTimelockPendingAdmin: sender must be gov guardian");
timelock.executeTransaction(address(timelock), 0, "setPendingAdmin(address)", abi.encode(newPendingAdmin), eta);
}
function add256(uint256 a, uint256 b) internal pure returns (uint) {
uint c = a + b;
require(c >= a, "addition overflow");
return c;
}
function sub256(uint256 a, uint256 b) internal pure returns (uint) {
require(b <= a, "subtraction underflow");
return a - b;
}
function getChainId() internal pure returns (uint) {
uint chainId;
assembly { chainId := chainid() }
return chainId;
}
} | votingDelay | function votingDelay() public pure returns (uint) { return 1; } // 1 block
| /// @notice The delay before voting on a proposal may take place, once proposed | NatSpecSingleLine | v0.5.16+commit.9c3226ce | None | {
"func_code_index": [
815,
893
]
} | 9,459 |
|||
CompoundLens | contracts/Governance/GovernorAlpha.sol | 0xd513d22422a3062bd342ae374b4b9c20e0a9a074 | Solidity | GovernorAlpha | contract GovernorAlpha {
/// @notice The name of this contract
string public constant name = "Compound Governor Alpha";
/// @notice The number of votes in support of a proposal required in order for a quorum to be reached and for a vote to succeed
function quorumVotes() public pure returns (uint) { return 400000e18; } // 400,000 = 4% of Comp
/// @notice The number of votes required in order for a voter to become a proposer
function proposalThreshold() public pure returns (uint) { return 100000e18; } // 100,000 = 1% of Comp
/// @notice The maximum number of actions that can be included in a proposal
function proposalMaxOperations() public pure returns (uint) { return 10; } // 10 actions
/// @notice The delay before voting on a proposal may take place, once proposed
function votingDelay() public pure returns (uint) { return 1; } // 1 block
/// @notice The duration of voting on a proposal, in blocks
function votingPeriod() public pure returns (uint) { return 17280; } // ~3 days in blocks (assuming 15s blocks)
/// @notice The address of the Compound Protocol Timelock
TimelockInterface public timelock;
/// @notice The address of the Compound governance token
CompInterface public comp;
/// @notice The address of the Governor Guardian
address public guardian;
/// @notice The total number of proposals
uint public proposalCount;
struct Proposal {
/// @notice Unique id for looking up a proposal
uint id;
/// @notice Creator of the proposal
address proposer;
/// @notice The timestamp that the proposal will be available for execution, set once the vote succeeds
uint eta;
/// @notice the ordered list of target addresses for calls to be made
address[] targets;
/// @notice The ordered list of values (i.e. msg.value) to be passed to the calls to be made
uint[] values;
/// @notice The ordered list of function signatures to be called
string[] signatures;
/// @notice The ordered list of calldata to be passed to each call
bytes[] calldatas;
/// @notice The block at which voting begins: holders must delegate their votes prior to this block
uint startBlock;
/// @notice The block at which voting ends: votes must be cast prior to this block
uint endBlock;
/// @notice Current number of votes in favor of this proposal
uint forVotes;
/// @notice Current number of votes in opposition to this proposal
uint againstVotes;
/// @notice Flag marking whether the proposal has been canceled
bool canceled;
/// @notice Flag marking whether the proposal has been executed
bool executed;
/// @notice Receipts of ballots for the entire set of voters
mapping (address => Receipt) receipts;
}
/// @notice Ballot receipt record for a voter
struct Receipt {
/// @notice Whether or not a vote has been cast
bool hasVoted;
/// @notice Whether or not the voter supports the proposal
bool support;
/// @notice The number of votes the voter had, which were cast
uint96 votes;
}
/// @notice Possible states that a proposal may be in
enum ProposalState {
Pending,
Active,
Canceled,
Defeated,
Succeeded,
Queued,
Expired,
Executed
}
/// @notice The official record of all proposals ever proposed
mapping (uint => Proposal) public proposals;
/// @notice The latest proposal for each proposer
mapping (address => uint) public latestProposalIds;
/// @notice The EIP-712 typehash for the contract's domain
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
/// @notice The EIP-712 typehash for the ballot struct used by the contract
bytes32 public constant BALLOT_TYPEHASH = keccak256("Ballot(uint256 proposalId,bool support)");
/// @notice An event emitted when a new proposal is created
event ProposalCreated(uint id, address proposer, address[] targets, uint[] values, string[] signatures, bytes[] calldatas, uint startBlock, uint endBlock, string description);
/// @notice An event emitted when a vote has been cast on a proposal
event VoteCast(address voter, uint proposalId, bool support, uint votes);
/// @notice An event emitted when a proposal has been canceled
event ProposalCanceled(uint id);
/// @notice An event emitted when a proposal has been queued in the Timelock
event ProposalQueued(uint id, uint eta);
/// @notice An event emitted when a proposal has been executed in the Timelock
event ProposalExecuted(uint id);
constructor(address timelock_, address comp_, address guardian_) public {
timelock = TimelockInterface(timelock_);
comp = CompInterface(comp_);
guardian = guardian_;
}
function propose(address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas, string memory description) public returns (uint) {
require(comp.getPriorVotes(msg.sender, sub256(block.number, 1)) > proposalThreshold(), "GovernorAlpha::propose: proposer votes below proposal threshold");
require(targets.length == values.length && targets.length == signatures.length && targets.length == calldatas.length, "GovernorAlpha::propose: proposal function information arity mismatch");
require(targets.length != 0, "GovernorAlpha::propose: must provide actions");
require(targets.length <= proposalMaxOperations(), "GovernorAlpha::propose: too many actions");
uint latestProposalId = latestProposalIds[msg.sender];
if (latestProposalId != 0) {
ProposalState proposersLatestProposalState = state(latestProposalId);
require(proposersLatestProposalState != ProposalState.Active, "GovernorAlpha::propose: one live proposal per proposer, found an already active proposal");
require(proposersLatestProposalState != ProposalState.Pending, "GovernorAlpha::propose: one live proposal per proposer, found an already pending proposal");
}
uint startBlock = add256(block.number, votingDelay());
uint endBlock = add256(startBlock, votingPeriod());
proposalCount++;
Proposal memory newProposal = Proposal({
id: proposalCount,
proposer: msg.sender,
eta: 0,
targets: targets,
values: values,
signatures: signatures,
calldatas: calldatas,
startBlock: startBlock,
endBlock: endBlock,
forVotes: 0,
againstVotes: 0,
canceled: false,
executed: false
});
proposals[newProposal.id] = newProposal;
latestProposalIds[newProposal.proposer] = newProposal.id;
emit ProposalCreated(newProposal.id, msg.sender, targets, values, signatures, calldatas, startBlock, endBlock, description);
return newProposal.id;
}
function queue(uint proposalId) public {
require(state(proposalId) == ProposalState.Succeeded, "GovernorAlpha::queue: proposal can only be queued if it is succeeded");
Proposal storage proposal = proposals[proposalId];
uint eta = add256(block.timestamp, timelock.delay());
for (uint i = 0; i < proposal.targets.length; i++) {
_queueOrRevert(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], eta);
}
proposal.eta = eta;
emit ProposalQueued(proposalId, eta);
}
function _queueOrRevert(address target, uint value, string memory signature, bytes memory data, uint eta) internal {
require(!timelock.queuedTransactions(keccak256(abi.encode(target, value, signature, data, eta))), "GovernorAlpha::_queueOrRevert: proposal action already queued at eta");
timelock.queueTransaction(target, value, signature, data, eta);
}
function execute(uint proposalId) public payable {
require(state(proposalId) == ProposalState.Queued, "GovernorAlpha::execute: proposal can only be executed if it is queued");
Proposal storage proposal = proposals[proposalId];
proposal.executed = true;
for (uint i = 0; i < proposal.targets.length; i++) {
timelock.executeTransaction.value(proposal.values[i])(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta);
}
emit ProposalExecuted(proposalId);
}
function cancel(uint proposalId) public {
ProposalState state = state(proposalId);
require(state != ProposalState.Executed, "GovernorAlpha::cancel: cannot cancel executed proposal");
Proposal storage proposal = proposals[proposalId];
require(msg.sender == guardian || comp.getPriorVotes(proposal.proposer, sub256(block.number, 1)) < proposalThreshold(), "GovernorAlpha::cancel: proposer above threshold");
proposal.canceled = true;
for (uint i = 0; i < proposal.targets.length; i++) {
timelock.cancelTransaction(proposal.targets[i], proposal.values[i], proposal.signatures[i], proposal.calldatas[i], proposal.eta);
}
emit ProposalCanceled(proposalId);
}
function getActions(uint proposalId) public view returns (address[] memory targets, uint[] memory values, string[] memory signatures, bytes[] memory calldatas) {
Proposal storage p = proposals[proposalId];
return (p.targets, p.values, p.signatures, p.calldatas);
}
function getReceipt(uint proposalId, address voter) public view returns (Receipt memory) {
return proposals[proposalId].receipts[voter];
}
function state(uint proposalId) public view returns (ProposalState) {
require(proposalCount >= proposalId && proposalId > 0, "GovernorAlpha::state: invalid proposal id");
Proposal storage proposal = proposals[proposalId];
if (proposal.canceled) {
return ProposalState.Canceled;
} else if (block.number <= proposal.startBlock) {
return ProposalState.Pending;
} else if (block.number <= proposal.endBlock) {
return ProposalState.Active;
} else if (proposal.forVotes <= proposal.againstVotes || proposal.forVotes < quorumVotes()) {
return ProposalState.Defeated;
} else if (proposal.eta == 0) {
return ProposalState.Succeeded;
} else if (proposal.executed) {
return ProposalState.Executed;
} else if (block.timestamp >= add256(proposal.eta, timelock.GRACE_PERIOD())) {
return ProposalState.Expired;
} else {
return ProposalState.Queued;
}
}
function castVote(uint proposalId, bool support) public {
return _castVote(msg.sender, proposalId, support);
}
function castVoteBySig(uint proposalId, bool support, uint8 v, bytes32 r, bytes32 s) public {
bytes32 domainSeparator = keccak256(abi.encode(DOMAIN_TYPEHASH, keccak256(bytes(name)), getChainId(), address(this)));
bytes32 structHash = keccak256(abi.encode(BALLOT_TYPEHASH, proposalId, support));
bytes32 digest = keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "GovernorAlpha::castVoteBySig: invalid signature");
return _castVote(signatory, proposalId, support);
}
function _castVote(address voter, uint proposalId, bool support) internal {
require(state(proposalId) == ProposalState.Active, "GovernorAlpha::_castVote: voting is closed");
Proposal storage proposal = proposals[proposalId];
Receipt storage receipt = proposal.receipts[voter];
require(receipt.hasVoted == false, "GovernorAlpha::_castVote: voter already voted");
uint96 votes = comp.getPriorVotes(voter, proposal.startBlock);
if (support) {
proposal.forVotes = add256(proposal.forVotes, votes);
} else {
proposal.againstVotes = add256(proposal.againstVotes, votes);
}
receipt.hasVoted = true;
receipt.support = support;
receipt.votes = votes;
emit VoteCast(voter, proposalId, support, votes);
}
function __acceptAdmin() public {
require(msg.sender == guardian, "GovernorAlpha::__acceptAdmin: sender must be gov guardian");
timelock.acceptAdmin();
}
function __abdicate() public {
require(msg.sender == guardian, "GovernorAlpha::__abdicate: sender must be gov guardian");
guardian = address(0);
}
function __queueSetTimelockPendingAdmin(address newPendingAdmin, uint eta) public {
require(msg.sender == guardian, "GovernorAlpha::__queueSetTimelockPendingAdmin: sender must be gov guardian");
timelock.queueTransaction(address(timelock), 0, "setPendingAdmin(address)", abi.encode(newPendingAdmin), eta);
}
function __executeSetTimelockPendingAdmin(address newPendingAdmin, uint eta) public {
require(msg.sender == guardian, "GovernorAlpha::__executeSetTimelockPendingAdmin: sender must be gov guardian");
timelock.executeTransaction(address(timelock), 0, "setPendingAdmin(address)", abi.encode(newPendingAdmin), eta);
}
function add256(uint256 a, uint256 b) internal pure returns (uint) {
uint c = a + b;
require(c >= a, "addition overflow");
return c;
}
function sub256(uint256 a, uint256 b) internal pure returns (uint) {
require(b <= a, "subtraction underflow");
return a - b;
}
function getChainId() internal pure returns (uint) {
uint chainId;
assembly { chainId := chainid() }
return chainId;
}
} | votingPeriod | function votingPeriod() public pure returns (uint) { return 17280; } // ~3 days in blocks (assuming 15s blocks)
| /// @notice The duration of voting on a proposal, in blocks | NatSpecSingleLine | v0.5.16+commit.9c3226ce | None | {
"func_code_index": [
959,
1074
]
} | 9,460 |
|||
PlatformBucket | PlatformBucket.sol | 0xa8550944706f8c6dc51a71f6b8ee29826468c0a9 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | mul | 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 Multiplies two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://e8222a9f0fd59b8113ff1346a3cba13133854607afc7942535e47e52ed741f17 | {
"func_code_index": [
89,
476
]
} | 9,461 |
|
PlatformBucket | PlatformBucket.sol | 0xa8550944706f8c6dc51a71f6b8ee29826468c0a9 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | div | 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 Integer division of two numbers, truncating the quotient.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://e8222a9f0fd59b8113ff1346a3cba13133854607afc7942535e47e52ed741f17 | {
"func_code_index": [
560,
840
]
} | 9,462 |
|
PlatformBucket | PlatformBucket.sol | 0xa8550944706f8c6dc51a71f6b8ee29826468c0a9 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
| /**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://e8222a9f0fd59b8113ff1346a3cba13133854607afc7942535e47e52ed741f17 | {
"func_code_index": [
954,
1070
]
} | 9,463 |
|
PlatformBucket | PlatformBucket.sol | 0xa8550944706f8c6dc51a71f6b8ee29826468c0a9 | Solidity | SafeMath | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers, truncating the quotient.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
// uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
} | /**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/ | NatSpecMultiLine | add | function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
| /**
* @dev Adds two numbers, throws on overflow.
*/ | NatSpecMultiLine | v0.4.25+commit.59dbf8f1 | bzzr://e8222a9f0fd59b8113ff1346a3cba13133854607afc7942535e47e52ed741f17 | {
"func_code_index": [
1134,
1264
]
} | 9,464 |
|
PlatformBucket | PlatformBucket.sol | 0xa8550944706f8c6dc51a71f6b8ee29826468c0a9 | Solidity | RBACMixin | contract RBACMixin {
/// @notice Constant string message to throw on lack of access
string constant FORBIDDEN = "Haven't enough right to access";
/// @notice Public map of owners
mapping (address => bool) public owners;
/// @notice Public map of minters
mapping (address => bool) public minters;
/// @notice The event indicates the addition of a new owner
/// @param who is address of added owner
event AddOwner(address indexed who);
/// @notice The event indicates the deletion of an owner
/// @param who is address of deleted owner
event DeleteOwner(address indexed who);
/// @notice The event indicates the addition of a new minter
/// @param who is address of added minter
event AddMinter(address indexed who);
/// @notice The event indicates the deletion of a minter
/// @param who is address of deleted minter
event DeleteMinter(address indexed who);
constructor () public {
_setOwner(msg.sender, true);
}
/// @notice The functional modifier rejects the interaction of senders who are not owners
modifier onlyOwner() {
require(isOwner(msg.sender), FORBIDDEN);
_;
}
/// @notice Functional modifier for rejecting the interaction of senders that are not minters
modifier onlyMinter() {
require(isMinter(msg.sender), FORBIDDEN);
_;
}
/// @notice Look up for the owner role on providen address
/// @param _who is address to look up
/// @return A boolean of owner role
function isOwner(address _who) public view returns (bool) {
return owners[_who];
}
/// @notice Look up for the minter role on providen address
/// @param _who is address to look up
/// @return A boolean of minter role
function isMinter(address _who) public view returns (bool) {
return minters[_who];
}
/// @notice Adds the owner role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to add role
/// @return A boolean that indicates if the operation was successful.
function addOwner(address _who) public onlyOwner returns (bool) {
_setOwner(_who, true);
}
/// @notice Deletes the owner role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to delete role
/// @return A boolean that indicates if the operation was successful.
function deleteOwner(address _who) public onlyOwner returns (bool) {
_setOwner(_who, false);
}
/// @notice Adds the minter role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to add role
/// @return A boolean that indicates if the operation was successful.
function addMinter(address _who) public onlyOwner returns (bool) {
_setMinter(_who, true);
}
/// @notice Deletes the minter role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to delete role
/// @return A boolean that indicates if the operation was successful.
function deleteMinter(address _who) public onlyOwner returns (bool) {
_setMinter(_who, false);
}
/// @notice Changes the owner role to provided address
/// @param _who is address to change role
/// @param _flag is next role status after success
/// @return A boolean that indicates if the operation was successful.
function _setOwner(address _who, bool _flag) private returns (bool) {
require(owners[_who] != _flag);
owners[_who] = _flag;
if (_flag) {
emit AddOwner(_who);
} else {
emit DeleteOwner(_who);
}
return true;
}
/// @notice Changes the minter role to provided address
/// @param _who is address to change role
/// @param _flag is next role status after success
/// @return A boolean that indicates if the operation was successful.
function _setMinter(address _who, bool _flag) private returns (bool) {
require(minters[_who] != _flag);
minters[_who] = _flag;
if (_flag) {
emit AddMinter(_who);
} else {
emit DeleteMinter(_who);
}
return true;
}
} | /// @title Role based access control mixin for Rasmart Platform
/// @author Abha Mai <[email protected]>
/// @dev Ignore DRY approach to achieve readability | NatSpecSingleLine | isOwner | function isOwner(address _who) public view returns (bool) {
return owners[_who];
}
| /// @notice Look up for the owner role on providen address
/// @param _who is address to look up
/// @return A boolean of owner role | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e8222a9f0fd59b8113ff1346a3cba13133854607afc7942535e47e52ed741f17 | {
"func_code_index": [
1494,
1587
]
} | 9,465 |
|
PlatformBucket | PlatformBucket.sol | 0xa8550944706f8c6dc51a71f6b8ee29826468c0a9 | Solidity | RBACMixin | contract RBACMixin {
/// @notice Constant string message to throw on lack of access
string constant FORBIDDEN = "Haven't enough right to access";
/// @notice Public map of owners
mapping (address => bool) public owners;
/// @notice Public map of minters
mapping (address => bool) public minters;
/// @notice The event indicates the addition of a new owner
/// @param who is address of added owner
event AddOwner(address indexed who);
/// @notice The event indicates the deletion of an owner
/// @param who is address of deleted owner
event DeleteOwner(address indexed who);
/// @notice The event indicates the addition of a new minter
/// @param who is address of added minter
event AddMinter(address indexed who);
/// @notice The event indicates the deletion of a minter
/// @param who is address of deleted minter
event DeleteMinter(address indexed who);
constructor () public {
_setOwner(msg.sender, true);
}
/// @notice The functional modifier rejects the interaction of senders who are not owners
modifier onlyOwner() {
require(isOwner(msg.sender), FORBIDDEN);
_;
}
/// @notice Functional modifier for rejecting the interaction of senders that are not minters
modifier onlyMinter() {
require(isMinter(msg.sender), FORBIDDEN);
_;
}
/// @notice Look up for the owner role on providen address
/// @param _who is address to look up
/// @return A boolean of owner role
function isOwner(address _who) public view returns (bool) {
return owners[_who];
}
/// @notice Look up for the minter role on providen address
/// @param _who is address to look up
/// @return A boolean of minter role
function isMinter(address _who) public view returns (bool) {
return minters[_who];
}
/// @notice Adds the owner role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to add role
/// @return A boolean that indicates if the operation was successful.
function addOwner(address _who) public onlyOwner returns (bool) {
_setOwner(_who, true);
}
/// @notice Deletes the owner role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to delete role
/// @return A boolean that indicates if the operation was successful.
function deleteOwner(address _who) public onlyOwner returns (bool) {
_setOwner(_who, false);
}
/// @notice Adds the minter role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to add role
/// @return A boolean that indicates if the operation was successful.
function addMinter(address _who) public onlyOwner returns (bool) {
_setMinter(_who, true);
}
/// @notice Deletes the minter role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to delete role
/// @return A boolean that indicates if the operation was successful.
function deleteMinter(address _who) public onlyOwner returns (bool) {
_setMinter(_who, false);
}
/// @notice Changes the owner role to provided address
/// @param _who is address to change role
/// @param _flag is next role status after success
/// @return A boolean that indicates if the operation was successful.
function _setOwner(address _who, bool _flag) private returns (bool) {
require(owners[_who] != _flag);
owners[_who] = _flag;
if (_flag) {
emit AddOwner(_who);
} else {
emit DeleteOwner(_who);
}
return true;
}
/// @notice Changes the minter role to provided address
/// @param _who is address to change role
/// @param _flag is next role status after success
/// @return A boolean that indicates if the operation was successful.
function _setMinter(address _who, bool _flag) private returns (bool) {
require(minters[_who] != _flag);
minters[_who] = _flag;
if (_flag) {
emit AddMinter(_who);
} else {
emit DeleteMinter(_who);
}
return true;
}
} | /// @title Role based access control mixin for Rasmart Platform
/// @author Abha Mai <[email protected]>
/// @dev Ignore DRY approach to achieve readability | NatSpecSingleLine | isMinter | function isMinter(address _who) public view returns (bool) {
return minters[_who];
}
| /// @notice Look up for the minter role on providen address
/// @param _who is address to look up
/// @return A boolean of minter role | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e8222a9f0fd59b8113ff1346a3cba13133854607afc7942535e47e52ed741f17 | {
"func_code_index": [
1734,
1829
]
} | 9,466 |
|
PlatformBucket | PlatformBucket.sol | 0xa8550944706f8c6dc51a71f6b8ee29826468c0a9 | Solidity | RBACMixin | contract RBACMixin {
/// @notice Constant string message to throw on lack of access
string constant FORBIDDEN = "Haven't enough right to access";
/// @notice Public map of owners
mapping (address => bool) public owners;
/// @notice Public map of minters
mapping (address => bool) public minters;
/// @notice The event indicates the addition of a new owner
/// @param who is address of added owner
event AddOwner(address indexed who);
/// @notice The event indicates the deletion of an owner
/// @param who is address of deleted owner
event DeleteOwner(address indexed who);
/// @notice The event indicates the addition of a new minter
/// @param who is address of added minter
event AddMinter(address indexed who);
/// @notice The event indicates the deletion of a minter
/// @param who is address of deleted minter
event DeleteMinter(address indexed who);
constructor () public {
_setOwner(msg.sender, true);
}
/// @notice The functional modifier rejects the interaction of senders who are not owners
modifier onlyOwner() {
require(isOwner(msg.sender), FORBIDDEN);
_;
}
/// @notice Functional modifier for rejecting the interaction of senders that are not minters
modifier onlyMinter() {
require(isMinter(msg.sender), FORBIDDEN);
_;
}
/// @notice Look up for the owner role on providen address
/// @param _who is address to look up
/// @return A boolean of owner role
function isOwner(address _who) public view returns (bool) {
return owners[_who];
}
/// @notice Look up for the minter role on providen address
/// @param _who is address to look up
/// @return A boolean of minter role
function isMinter(address _who) public view returns (bool) {
return minters[_who];
}
/// @notice Adds the owner role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to add role
/// @return A boolean that indicates if the operation was successful.
function addOwner(address _who) public onlyOwner returns (bool) {
_setOwner(_who, true);
}
/// @notice Deletes the owner role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to delete role
/// @return A boolean that indicates if the operation was successful.
function deleteOwner(address _who) public onlyOwner returns (bool) {
_setOwner(_who, false);
}
/// @notice Adds the minter role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to add role
/// @return A boolean that indicates if the operation was successful.
function addMinter(address _who) public onlyOwner returns (bool) {
_setMinter(_who, true);
}
/// @notice Deletes the minter role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to delete role
/// @return A boolean that indicates if the operation was successful.
function deleteMinter(address _who) public onlyOwner returns (bool) {
_setMinter(_who, false);
}
/// @notice Changes the owner role to provided address
/// @param _who is address to change role
/// @param _flag is next role status after success
/// @return A boolean that indicates if the operation was successful.
function _setOwner(address _who, bool _flag) private returns (bool) {
require(owners[_who] != _flag);
owners[_who] = _flag;
if (_flag) {
emit AddOwner(_who);
} else {
emit DeleteOwner(_who);
}
return true;
}
/// @notice Changes the minter role to provided address
/// @param _who is address to change role
/// @param _flag is next role status after success
/// @return A boolean that indicates if the operation was successful.
function _setMinter(address _who, bool _flag) private returns (bool) {
require(minters[_who] != _flag);
minters[_who] = _flag;
if (_flag) {
emit AddMinter(_who);
} else {
emit DeleteMinter(_who);
}
return true;
}
} | /// @title Role based access control mixin for Rasmart Platform
/// @author Abha Mai <[email protected]>
/// @dev Ignore DRY approach to achieve readability | NatSpecSingleLine | addOwner | function addOwner(address _who) public onlyOwner returns (bool) {
_setOwner(_who, true);
}
| /// @notice Adds the owner role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to add role
/// @return A boolean that indicates if the operation was successful. | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e8222a9f0fd59b8113ff1346a3cba13133854607afc7942535e47e52ed741f17 | {
"func_code_index": [
2046,
2147
]
} | 9,467 |
|
PlatformBucket | PlatformBucket.sol | 0xa8550944706f8c6dc51a71f6b8ee29826468c0a9 | Solidity | RBACMixin | contract RBACMixin {
/// @notice Constant string message to throw on lack of access
string constant FORBIDDEN = "Haven't enough right to access";
/// @notice Public map of owners
mapping (address => bool) public owners;
/// @notice Public map of minters
mapping (address => bool) public minters;
/// @notice The event indicates the addition of a new owner
/// @param who is address of added owner
event AddOwner(address indexed who);
/// @notice The event indicates the deletion of an owner
/// @param who is address of deleted owner
event DeleteOwner(address indexed who);
/// @notice The event indicates the addition of a new minter
/// @param who is address of added minter
event AddMinter(address indexed who);
/// @notice The event indicates the deletion of a minter
/// @param who is address of deleted minter
event DeleteMinter(address indexed who);
constructor () public {
_setOwner(msg.sender, true);
}
/// @notice The functional modifier rejects the interaction of senders who are not owners
modifier onlyOwner() {
require(isOwner(msg.sender), FORBIDDEN);
_;
}
/// @notice Functional modifier for rejecting the interaction of senders that are not minters
modifier onlyMinter() {
require(isMinter(msg.sender), FORBIDDEN);
_;
}
/// @notice Look up for the owner role on providen address
/// @param _who is address to look up
/// @return A boolean of owner role
function isOwner(address _who) public view returns (bool) {
return owners[_who];
}
/// @notice Look up for the minter role on providen address
/// @param _who is address to look up
/// @return A boolean of minter role
function isMinter(address _who) public view returns (bool) {
return minters[_who];
}
/// @notice Adds the owner role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to add role
/// @return A boolean that indicates if the operation was successful.
function addOwner(address _who) public onlyOwner returns (bool) {
_setOwner(_who, true);
}
/// @notice Deletes the owner role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to delete role
/// @return A boolean that indicates if the operation was successful.
function deleteOwner(address _who) public onlyOwner returns (bool) {
_setOwner(_who, false);
}
/// @notice Adds the minter role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to add role
/// @return A boolean that indicates if the operation was successful.
function addMinter(address _who) public onlyOwner returns (bool) {
_setMinter(_who, true);
}
/// @notice Deletes the minter role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to delete role
/// @return A boolean that indicates if the operation was successful.
function deleteMinter(address _who) public onlyOwner returns (bool) {
_setMinter(_who, false);
}
/// @notice Changes the owner role to provided address
/// @param _who is address to change role
/// @param _flag is next role status after success
/// @return A boolean that indicates if the operation was successful.
function _setOwner(address _who, bool _flag) private returns (bool) {
require(owners[_who] != _flag);
owners[_who] = _flag;
if (_flag) {
emit AddOwner(_who);
} else {
emit DeleteOwner(_who);
}
return true;
}
/// @notice Changes the minter role to provided address
/// @param _who is address to change role
/// @param _flag is next role status after success
/// @return A boolean that indicates if the operation was successful.
function _setMinter(address _who, bool _flag) private returns (bool) {
require(minters[_who] != _flag);
minters[_who] = _flag;
if (_flag) {
emit AddMinter(_who);
} else {
emit DeleteMinter(_who);
}
return true;
}
} | /// @title Role based access control mixin for Rasmart Platform
/// @author Abha Mai <[email protected]>
/// @dev Ignore DRY approach to achieve readability | NatSpecSingleLine | deleteOwner | function deleteOwner(address _who) public onlyOwner returns (bool) {
_setOwner(_who, false);
}
| /// @notice Deletes the owner role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to delete role
/// @return A boolean that indicates if the operation was successful. | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e8222a9f0fd59b8113ff1346a3cba13133854607afc7942535e47e52ed741f17 | {
"func_code_index": [
2370,
2475
]
} | 9,468 |
|
PlatformBucket | PlatformBucket.sol | 0xa8550944706f8c6dc51a71f6b8ee29826468c0a9 | Solidity | RBACMixin | contract RBACMixin {
/// @notice Constant string message to throw on lack of access
string constant FORBIDDEN = "Haven't enough right to access";
/// @notice Public map of owners
mapping (address => bool) public owners;
/// @notice Public map of minters
mapping (address => bool) public minters;
/// @notice The event indicates the addition of a new owner
/// @param who is address of added owner
event AddOwner(address indexed who);
/// @notice The event indicates the deletion of an owner
/// @param who is address of deleted owner
event DeleteOwner(address indexed who);
/// @notice The event indicates the addition of a new minter
/// @param who is address of added minter
event AddMinter(address indexed who);
/// @notice The event indicates the deletion of a minter
/// @param who is address of deleted minter
event DeleteMinter(address indexed who);
constructor () public {
_setOwner(msg.sender, true);
}
/// @notice The functional modifier rejects the interaction of senders who are not owners
modifier onlyOwner() {
require(isOwner(msg.sender), FORBIDDEN);
_;
}
/// @notice Functional modifier for rejecting the interaction of senders that are not minters
modifier onlyMinter() {
require(isMinter(msg.sender), FORBIDDEN);
_;
}
/// @notice Look up for the owner role on providen address
/// @param _who is address to look up
/// @return A boolean of owner role
function isOwner(address _who) public view returns (bool) {
return owners[_who];
}
/// @notice Look up for the minter role on providen address
/// @param _who is address to look up
/// @return A boolean of minter role
function isMinter(address _who) public view returns (bool) {
return minters[_who];
}
/// @notice Adds the owner role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to add role
/// @return A boolean that indicates if the operation was successful.
function addOwner(address _who) public onlyOwner returns (bool) {
_setOwner(_who, true);
}
/// @notice Deletes the owner role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to delete role
/// @return A boolean that indicates if the operation was successful.
function deleteOwner(address _who) public onlyOwner returns (bool) {
_setOwner(_who, false);
}
/// @notice Adds the minter role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to add role
/// @return A boolean that indicates if the operation was successful.
function addMinter(address _who) public onlyOwner returns (bool) {
_setMinter(_who, true);
}
/// @notice Deletes the minter role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to delete role
/// @return A boolean that indicates if the operation was successful.
function deleteMinter(address _who) public onlyOwner returns (bool) {
_setMinter(_who, false);
}
/// @notice Changes the owner role to provided address
/// @param _who is address to change role
/// @param _flag is next role status after success
/// @return A boolean that indicates if the operation was successful.
function _setOwner(address _who, bool _flag) private returns (bool) {
require(owners[_who] != _flag);
owners[_who] = _flag;
if (_flag) {
emit AddOwner(_who);
} else {
emit DeleteOwner(_who);
}
return true;
}
/// @notice Changes the minter role to provided address
/// @param _who is address to change role
/// @param _flag is next role status after success
/// @return A boolean that indicates if the operation was successful.
function _setMinter(address _who, bool _flag) private returns (bool) {
require(minters[_who] != _flag);
minters[_who] = _flag;
if (_flag) {
emit AddMinter(_who);
} else {
emit DeleteMinter(_who);
}
return true;
}
} | /// @title Role based access control mixin for Rasmart Platform
/// @author Abha Mai <[email protected]>
/// @dev Ignore DRY approach to achieve readability | NatSpecSingleLine | addMinter | function addMinter(address _who) public onlyOwner returns (bool) {
_setMinter(_who, true);
}
| /// @notice Adds the minter role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to add role
/// @return A boolean that indicates if the operation was successful. | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e8222a9f0fd59b8113ff1346a3cba13133854607afc7942535e47e52ed741f17 | {
"func_code_index": [
2693,
2796
]
} | 9,469 |
|
PlatformBucket | PlatformBucket.sol | 0xa8550944706f8c6dc51a71f6b8ee29826468c0a9 | Solidity | RBACMixin | contract RBACMixin {
/// @notice Constant string message to throw on lack of access
string constant FORBIDDEN = "Haven't enough right to access";
/// @notice Public map of owners
mapping (address => bool) public owners;
/// @notice Public map of minters
mapping (address => bool) public minters;
/// @notice The event indicates the addition of a new owner
/// @param who is address of added owner
event AddOwner(address indexed who);
/// @notice The event indicates the deletion of an owner
/// @param who is address of deleted owner
event DeleteOwner(address indexed who);
/// @notice The event indicates the addition of a new minter
/// @param who is address of added minter
event AddMinter(address indexed who);
/// @notice The event indicates the deletion of a minter
/// @param who is address of deleted minter
event DeleteMinter(address indexed who);
constructor () public {
_setOwner(msg.sender, true);
}
/// @notice The functional modifier rejects the interaction of senders who are not owners
modifier onlyOwner() {
require(isOwner(msg.sender), FORBIDDEN);
_;
}
/// @notice Functional modifier for rejecting the interaction of senders that are not minters
modifier onlyMinter() {
require(isMinter(msg.sender), FORBIDDEN);
_;
}
/// @notice Look up for the owner role on providen address
/// @param _who is address to look up
/// @return A boolean of owner role
function isOwner(address _who) public view returns (bool) {
return owners[_who];
}
/// @notice Look up for the minter role on providen address
/// @param _who is address to look up
/// @return A boolean of minter role
function isMinter(address _who) public view returns (bool) {
return minters[_who];
}
/// @notice Adds the owner role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to add role
/// @return A boolean that indicates if the operation was successful.
function addOwner(address _who) public onlyOwner returns (bool) {
_setOwner(_who, true);
}
/// @notice Deletes the owner role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to delete role
/// @return A boolean that indicates if the operation was successful.
function deleteOwner(address _who) public onlyOwner returns (bool) {
_setOwner(_who, false);
}
/// @notice Adds the minter role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to add role
/// @return A boolean that indicates if the operation was successful.
function addMinter(address _who) public onlyOwner returns (bool) {
_setMinter(_who, true);
}
/// @notice Deletes the minter role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to delete role
/// @return A boolean that indicates if the operation was successful.
function deleteMinter(address _who) public onlyOwner returns (bool) {
_setMinter(_who, false);
}
/// @notice Changes the owner role to provided address
/// @param _who is address to change role
/// @param _flag is next role status after success
/// @return A boolean that indicates if the operation was successful.
function _setOwner(address _who, bool _flag) private returns (bool) {
require(owners[_who] != _flag);
owners[_who] = _flag;
if (_flag) {
emit AddOwner(_who);
} else {
emit DeleteOwner(_who);
}
return true;
}
/// @notice Changes the minter role to provided address
/// @param _who is address to change role
/// @param _flag is next role status after success
/// @return A boolean that indicates if the operation was successful.
function _setMinter(address _who, bool _flag) private returns (bool) {
require(minters[_who] != _flag);
minters[_who] = _flag;
if (_flag) {
emit AddMinter(_who);
} else {
emit DeleteMinter(_who);
}
return true;
}
} | /// @title Role based access control mixin for Rasmart Platform
/// @author Abha Mai <[email protected]>
/// @dev Ignore DRY approach to achieve readability | NatSpecSingleLine | deleteMinter | function deleteMinter(address _who) public onlyOwner returns (bool) {
_setMinter(_who, false);
}
| /// @notice Deletes the minter role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to delete role
/// @return A boolean that indicates if the operation was successful. | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e8222a9f0fd59b8113ff1346a3cba13133854607afc7942535e47e52ed741f17 | {
"func_code_index": [
3020,
3127
]
} | 9,470 |
|
PlatformBucket | PlatformBucket.sol | 0xa8550944706f8c6dc51a71f6b8ee29826468c0a9 | Solidity | RBACMixin | contract RBACMixin {
/// @notice Constant string message to throw on lack of access
string constant FORBIDDEN = "Haven't enough right to access";
/// @notice Public map of owners
mapping (address => bool) public owners;
/// @notice Public map of minters
mapping (address => bool) public minters;
/// @notice The event indicates the addition of a new owner
/// @param who is address of added owner
event AddOwner(address indexed who);
/// @notice The event indicates the deletion of an owner
/// @param who is address of deleted owner
event DeleteOwner(address indexed who);
/// @notice The event indicates the addition of a new minter
/// @param who is address of added minter
event AddMinter(address indexed who);
/// @notice The event indicates the deletion of a minter
/// @param who is address of deleted minter
event DeleteMinter(address indexed who);
constructor () public {
_setOwner(msg.sender, true);
}
/// @notice The functional modifier rejects the interaction of senders who are not owners
modifier onlyOwner() {
require(isOwner(msg.sender), FORBIDDEN);
_;
}
/// @notice Functional modifier for rejecting the interaction of senders that are not minters
modifier onlyMinter() {
require(isMinter(msg.sender), FORBIDDEN);
_;
}
/// @notice Look up for the owner role on providen address
/// @param _who is address to look up
/// @return A boolean of owner role
function isOwner(address _who) public view returns (bool) {
return owners[_who];
}
/// @notice Look up for the minter role on providen address
/// @param _who is address to look up
/// @return A boolean of minter role
function isMinter(address _who) public view returns (bool) {
return minters[_who];
}
/// @notice Adds the owner role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to add role
/// @return A boolean that indicates if the operation was successful.
function addOwner(address _who) public onlyOwner returns (bool) {
_setOwner(_who, true);
}
/// @notice Deletes the owner role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to delete role
/// @return A boolean that indicates if the operation was successful.
function deleteOwner(address _who) public onlyOwner returns (bool) {
_setOwner(_who, false);
}
/// @notice Adds the minter role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to add role
/// @return A boolean that indicates if the operation was successful.
function addMinter(address _who) public onlyOwner returns (bool) {
_setMinter(_who, true);
}
/// @notice Deletes the minter role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to delete role
/// @return A boolean that indicates if the operation was successful.
function deleteMinter(address _who) public onlyOwner returns (bool) {
_setMinter(_who, false);
}
/// @notice Changes the owner role to provided address
/// @param _who is address to change role
/// @param _flag is next role status after success
/// @return A boolean that indicates if the operation was successful.
function _setOwner(address _who, bool _flag) private returns (bool) {
require(owners[_who] != _flag);
owners[_who] = _flag;
if (_flag) {
emit AddOwner(_who);
} else {
emit DeleteOwner(_who);
}
return true;
}
/// @notice Changes the minter role to provided address
/// @param _who is address to change role
/// @param _flag is next role status after success
/// @return A boolean that indicates if the operation was successful.
function _setMinter(address _who, bool _flag) private returns (bool) {
require(minters[_who] != _flag);
minters[_who] = _flag;
if (_flag) {
emit AddMinter(_who);
} else {
emit DeleteMinter(_who);
}
return true;
}
} | /// @title Role based access control mixin for Rasmart Platform
/// @author Abha Mai <[email protected]>
/// @dev Ignore DRY approach to achieve readability | NatSpecSingleLine | _setOwner | function _setOwner(address _who, bool _flag) private returns (bool) {
require(owners[_who] != _flag);
owners[_who] = _flag;
if (_flag) {
emit AddOwner(_who);
} else {
emit DeleteOwner(_who);
}
return true;
}
| /// @notice Changes the owner role to provided address
/// @param _who is address to change role
/// @param _flag is next role status after success
/// @return A boolean that indicates if the operation was successful. | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e8222a9f0fd59b8113ff1346a3cba13133854607afc7942535e47e52ed741f17 | {
"func_code_index": [
3360,
3617
]
} | 9,471 |
|
PlatformBucket | PlatformBucket.sol | 0xa8550944706f8c6dc51a71f6b8ee29826468c0a9 | Solidity | RBACMixin | contract RBACMixin {
/// @notice Constant string message to throw on lack of access
string constant FORBIDDEN = "Haven't enough right to access";
/// @notice Public map of owners
mapping (address => bool) public owners;
/// @notice Public map of minters
mapping (address => bool) public minters;
/// @notice The event indicates the addition of a new owner
/// @param who is address of added owner
event AddOwner(address indexed who);
/// @notice The event indicates the deletion of an owner
/// @param who is address of deleted owner
event DeleteOwner(address indexed who);
/// @notice The event indicates the addition of a new minter
/// @param who is address of added minter
event AddMinter(address indexed who);
/// @notice The event indicates the deletion of a minter
/// @param who is address of deleted minter
event DeleteMinter(address indexed who);
constructor () public {
_setOwner(msg.sender, true);
}
/// @notice The functional modifier rejects the interaction of senders who are not owners
modifier onlyOwner() {
require(isOwner(msg.sender), FORBIDDEN);
_;
}
/// @notice Functional modifier for rejecting the interaction of senders that are not minters
modifier onlyMinter() {
require(isMinter(msg.sender), FORBIDDEN);
_;
}
/// @notice Look up for the owner role on providen address
/// @param _who is address to look up
/// @return A boolean of owner role
function isOwner(address _who) public view returns (bool) {
return owners[_who];
}
/// @notice Look up for the minter role on providen address
/// @param _who is address to look up
/// @return A boolean of minter role
function isMinter(address _who) public view returns (bool) {
return minters[_who];
}
/// @notice Adds the owner role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to add role
/// @return A boolean that indicates if the operation was successful.
function addOwner(address _who) public onlyOwner returns (bool) {
_setOwner(_who, true);
}
/// @notice Deletes the owner role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to delete role
/// @return A boolean that indicates if the operation was successful.
function deleteOwner(address _who) public onlyOwner returns (bool) {
_setOwner(_who, false);
}
/// @notice Adds the minter role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to add role
/// @return A boolean that indicates if the operation was successful.
function addMinter(address _who) public onlyOwner returns (bool) {
_setMinter(_who, true);
}
/// @notice Deletes the minter role to provided address
/// @dev Requires owner role to interact
/// @param _who is address to delete role
/// @return A boolean that indicates if the operation was successful.
function deleteMinter(address _who) public onlyOwner returns (bool) {
_setMinter(_who, false);
}
/// @notice Changes the owner role to provided address
/// @param _who is address to change role
/// @param _flag is next role status after success
/// @return A boolean that indicates if the operation was successful.
function _setOwner(address _who, bool _flag) private returns (bool) {
require(owners[_who] != _flag);
owners[_who] = _flag;
if (_flag) {
emit AddOwner(_who);
} else {
emit DeleteOwner(_who);
}
return true;
}
/// @notice Changes the minter role to provided address
/// @param _who is address to change role
/// @param _flag is next role status after success
/// @return A boolean that indicates if the operation was successful.
function _setMinter(address _who, bool _flag) private returns (bool) {
require(minters[_who] != _flag);
minters[_who] = _flag;
if (_flag) {
emit AddMinter(_who);
} else {
emit DeleteMinter(_who);
}
return true;
}
} | /// @title Role based access control mixin for Rasmart Platform
/// @author Abha Mai <[email protected]>
/// @dev Ignore DRY approach to achieve readability | NatSpecSingleLine | _setMinter | function _setMinter(address _who, bool _flag) private returns (bool) {
require(minters[_who] != _flag);
minters[_who] = _flag;
if (_flag) {
emit AddMinter(_who);
} else {
emit DeleteMinter(_who);
}
return true;
}
| /// @notice Changes the minter role to provided address
/// @param _who is address to change role
/// @param _flag is next role status after success
/// @return A boolean that indicates if the operation was successful. | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e8222a9f0fd59b8113ff1346a3cba13133854607afc7942535e47e52ed741f17 | {
"func_code_index": [
3851,
4113
]
} | 9,472 |
|
PlatformBucket | PlatformBucket.sol | 0xa8550944706f8c6dc51a71f6b8ee29826468c0a9 | Solidity | PlatformBucket | contract PlatformBucket is RBACMixin, IMintableToken {
using SafeMath for uint;
/// @notice Limit maximum amount of available for minting tokens when bucket is full
/// @dev Should be enough to mint tokens with proper speed but less enough to prevent overminting in case of losing pkey
uint256 public size;
/// @notice Bucket refill rate
/// @dev Tokens per second (based on block.timestamp). Amount without decimals (in smallest part of token)
uint256 public rate;
/// @notice Stored time of latest minting
/// @dev Each successful call of minting function will update field with call timestamp
uint256 public lastMintTime;
/// @notice Left tokens in bucket on time of latest minting
uint256 public leftOnLastMint;
/// @notice Reference of Mintable token
/// @dev Setup in contructor phase and never change in future
IMintableToken public token;
/// @notice Token Bucket leak event fires on each minting
/// @param to is address of target tokens holder
/// @param left is amount of tokens available in bucket after leak
event Leak(address indexed to, uint256 left);
/// @param _token is address of Mintable token
/// @param _size initial size of token bucket
/// @param _rate initial refill rate (tokens/sec)
constructor (address _token, uint256 _size, uint256 _rate) public {
token = IMintableToken(_token);
size = _size;
rate = _rate;
leftOnLastMint = _size;
}
/// @notice Change size of bucket
/// @dev Require owner role to call
/// @param _size is new size of bucket
/// @return A boolean that indicates if the operation was successful.
function setSize(uint256 _size) public onlyOwner returns (bool) {
size = _size;
return true;
}
/// @notice Change refill rate of bucket
/// @dev Require owner role to call
/// @param _rate is new refill rate of bucket
/// @return A boolean that indicates if the operation was successful.
function setRate(uint256 _rate) public onlyOwner returns (bool) {
rate = _rate;
return true;
}
/// @notice Change size and refill rate of bucket
/// @dev Require owner role to call
/// @param _size is new size of bucket
/// @param _rate is new refill rate of bucket
/// @return A boolean that indicates if the operation was successful.
function setSizeAndRate(uint256 _size, uint256 _rate) public onlyOwner returns (bool) {
return setSize(_size) && setRate(_rate);
}
/// @notice 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 onlyMinter returns (bool) {
uint256 available = availableTokens();
require(_amount <= available);
leftOnLastMint = available.sub(_amount);
lastMintTime = now; // solium-disable-line security/no-block-members
require(token.mint(_to, _amount));
return true;
}
/// @notice Function to calculate and get available in bucket tokens
/// @return An amount of available tokens in bucket
function availableTokens() public view returns (uint) {
// solium-disable-next-line security/no-block-members
uint256 timeAfterMint = now.sub(lastMintTime);
uint256 refillAmount = rate.mul(timeAfterMint).add(leftOnLastMint);
return size < refillAmount ? size : refillAmount;
}
} | /// @title Very simplified implementation of Token Bucket Algorithm to secure token minting
/// @author Abha Mai <[email protected]>
/// @notice Works with tokens implemented Mintable interface
/// @dev Transfer ownership/minting role to contract and execute mint over PlatformBucket proxy to secure | NatSpecSingleLine | setSize | function setSize(uint256 _size) public onlyOwner returns (bool) {
size = _size;
return true;
}
| /// @notice Change size of bucket
/// @dev Require owner role to call
/// @param _size is new size of bucket
/// @return A boolean that indicates if the operation was successful. | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e8222a9f0fd59b8113ff1346a3cba13133854607afc7942535e47e52ed741f17 | {
"func_code_index": [
1658,
1768
]
} | 9,473 |
|
PlatformBucket | PlatformBucket.sol | 0xa8550944706f8c6dc51a71f6b8ee29826468c0a9 | Solidity | PlatformBucket | contract PlatformBucket is RBACMixin, IMintableToken {
using SafeMath for uint;
/// @notice Limit maximum amount of available for minting tokens when bucket is full
/// @dev Should be enough to mint tokens with proper speed but less enough to prevent overminting in case of losing pkey
uint256 public size;
/// @notice Bucket refill rate
/// @dev Tokens per second (based on block.timestamp). Amount without decimals (in smallest part of token)
uint256 public rate;
/// @notice Stored time of latest minting
/// @dev Each successful call of minting function will update field with call timestamp
uint256 public lastMintTime;
/// @notice Left tokens in bucket on time of latest minting
uint256 public leftOnLastMint;
/// @notice Reference of Mintable token
/// @dev Setup in contructor phase and never change in future
IMintableToken public token;
/// @notice Token Bucket leak event fires on each minting
/// @param to is address of target tokens holder
/// @param left is amount of tokens available in bucket after leak
event Leak(address indexed to, uint256 left);
/// @param _token is address of Mintable token
/// @param _size initial size of token bucket
/// @param _rate initial refill rate (tokens/sec)
constructor (address _token, uint256 _size, uint256 _rate) public {
token = IMintableToken(_token);
size = _size;
rate = _rate;
leftOnLastMint = _size;
}
/// @notice Change size of bucket
/// @dev Require owner role to call
/// @param _size is new size of bucket
/// @return A boolean that indicates if the operation was successful.
function setSize(uint256 _size) public onlyOwner returns (bool) {
size = _size;
return true;
}
/// @notice Change refill rate of bucket
/// @dev Require owner role to call
/// @param _rate is new refill rate of bucket
/// @return A boolean that indicates if the operation was successful.
function setRate(uint256 _rate) public onlyOwner returns (bool) {
rate = _rate;
return true;
}
/// @notice Change size and refill rate of bucket
/// @dev Require owner role to call
/// @param _size is new size of bucket
/// @param _rate is new refill rate of bucket
/// @return A boolean that indicates if the operation was successful.
function setSizeAndRate(uint256 _size, uint256 _rate) public onlyOwner returns (bool) {
return setSize(_size) && setRate(_rate);
}
/// @notice 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 onlyMinter returns (bool) {
uint256 available = availableTokens();
require(_amount <= available);
leftOnLastMint = available.sub(_amount);
lastMintTime = now; // solium-disable-line security/no-block-members
require(token.mint(_to, _amount));
return true;
}
/// @notice Function to calculate and get available in bucket tokens
/// @return An amount of available tokens in bucket
function availableTokens() public view returns (uint) {
// solium-disable-next-line security/no-block-members
uint256 timeAfterMint = now.sub(lastMintTime);
uint256 refillAmount = rate.mul(timeAfterMint).add(leftOnLastMint);
return size < refillAmount ? size : refillAmount;
}
} | /// @title Very simplified implementation of Token Bucket Algorithm to secure token minting
/// @author Abha Mai <[email protected]>
/// @notice Works with tokens implemented Mintable interface
/// @dev Transfer ownership/minting role to contract and execute mint over PlatformBucket proxy to secure | NatSpecSingleLine | setRate | function setRate(uint256 _rate) public onlyOwner returns (bool) {
rate = _rate;
return true;
}
| /// @notice Change refill rate of bucket
/// @dev Require owner role to call
/// @param _rate is new refill rate of bucket
/// @return A boolean that indicates if the operation was successful. | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e8222a9f0fd59b8113ff1346a3cba13133854607afc7942535e47e52ed741f17 | {
"func_code_index": [
1976,
2086
]
} | 9,474 |
|
PlatformBucket | PlatformBucket.sol | 0xa8550944706f8c6dc51a71f6b8ee29826468c0a9 | Solidity | PlatformBucket | contract PlatformBucket is RBACMixin, IMintableToken {
using SafeMath for uint;
/// @notice Limit maximum amount of available for minting tokens when bucket is full
/// @dev Should be enough to mint tokens with proper speed but less enough to prevent overminting in case of losing pkey
uint256 public size;
/// @notice Bucket refill rate
/// @dev Tokens per second (based on block.timestamp). Amount without decimals (in smallest part of token)
uint256 public rate;
/// @notice Stored time of latest minting
/// @dev Each successful call of minting function will update field with call timestamp
uint256 public lastMintTime;
/// @notice Left tokens in bucket on time of latest minting
uint256 public leftOnLastMint;
/// @notice Reference of Mintable token
/// @dev Setup in contructor phase and never change in future
IMintableToken public token;
/// @notice Token Bucket leak event fires on each minting
/// @param to is address of target tokens holder
/// @param left is amount of tokens available in bucket after leak
event Leak(address indexed to, uint256 left);
/// @param _token is address of Mintable token
/// @param _size initial size of token bucket
/// @param _rate initial refill rate (tokens/sec)
constructor (address _token, uint256 _size, uint256 _rate) public {
token = IMintableToken(_token);
size = _size;
rate = _rate;
leftOnLastMint = _size;
}
/// @notice Change size of bucket
/// @dev Require owner role to call
/// @param _size is new size of bucket
/// @return A boolean that indicates if the operation was successful.
function setSize(uint256 _size) public onlyOwner returns (bool) {
size = _size;
return true;
}
/// @notice Change refill rate of bucket
/// @dev Require owner role to call
/// @param _rate is new refill rate of bucket
/// @return A boolean that indicates if the operation was successful.
function setRate(uint256 _rate) public onlyOwner returns (bool) {
rate = _rate;
return true;
}
/// @notice Change size and refill rate of bucket
/// @dev Require owner role to call
/// @param _size is new size of bucket
/// @param _rate is new refill rate of bucket
/// @return A boolean that indicates if the operation was successful.
function setSizeAndRate(uint256 _size, uint256 _rate) public onlyOwner returns (bool) {
return setSize(_size) && setRate(_rate);
}
/// @notice 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 onlyMinter returns (bool) {
uint256 available = availableTokens();
require(_amount <= available);
leftOnLastMint = available.sub(_amount);
lastMintTime = now; // solium-disable-line security/no-block-members
require(token.mint(_to, _amount));
return true;
}
/// @notice Function to calculate and get available in bucket tokens
/// @return An amount of available tokens in bucket
function availableTokens() public view returns (uint) {
// solium-disable-next-line security/no-block-members
uint256 timeAfterMint = now.sub(lastMintTime);
uint256 refillAmount = rate.mul(timeAfterMint).add(leftOnLastMint);
return size < refillAmount ? size : refillAmount;
}
} | /// @title Very simplified implementation of Token Bucket Algorithm to secure token minting
/// @author Abha Mai <[email protected]>
/// @notice Works with tokens implemented Mintable interface
/// @dev Transfer ownership/minting role to contract and execute mint over PlatformBucket proxy to secure | NatSpecSingleLine | setSizeAndRate | function setSizeAndRate(uint256 _size, uint256 _rate) public onlyOwner returns (bool) {
return setSize(_size) && setRate(_rate);
}
| /// @notice Change size and refill rate of bucket
/// @dev Require owner role to call
/// @param _size is new size of bucket
/// @param _rate is new refill rate of bucket
/// @return A boolean that indicates if the operation was successful. | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e8222a9f0fd59b8113ff1346a3cba13133854607afc7942535e47e52ed741f17 | {
"func_code_index": [
2345,
2486
]
} | 9,475 |
|
PlatformBucket | PlatformBucket.sol | 0xa8550944706f8c6dc51a71f6b8ee29826468c0a9 | Solidity | PlatformBucket | contract PlatformBucket is RBACMixin, IMintableToken {
using SafeMath for uint;
/// @notice Limit maximum amount of available for minting tokens when bucket is full
/// @dev Should be enough to mint tokens with proper speed but less enough to prevent overminting in case of losing pkey
uint256 public size;
/// @notice Bucket refill rate
/// @dev Tokens per second (based on block.timestamp). Amount without decimals (in smallest part of token)
uint256 public rate;
/// @notice Stored time of latest minting
/// @dev Each successful call of minting function will update field with call timestamp
uint256 public lastMintTime;
/// @notice Left tokens in bucket on time of latest minting
uint256 public leftOnLastMint;
/// @notice Reference of Mintable token
/// @dev Setup in contructor phase and never change in future
IMintableToken public token;
/// @notice Token Bucket leak event fires on each minting
/// @param to is address of target tokens holder
/// @param left is amount of tokens available in bucket after leak
event Leak(address indexed to, uint256 left);
/// @param _token is address of Mintable token
/// @param _size initial size of token bucket
/// @param _rate initial refill rate (tokens/sec)
constructor (address _token, uint256 _size, uint256 _rate) public {
token = IMintableToken(_token);
size = _size;
rate = _rate;
leftOnLastMint = _size;
}
/// @notice Change size of bucket
/// @dev Require owner role to call
/// @param _size is new size of bucket
/// @return A boolean that indicates if the operation was successful.
function setSize(uint256 _size) public onlyOwner returns (bool) {
size = _size;
return true;
}
/// @notice Change refill rate of bucket
/// @dev Require owner role to call
/// @param _rate is new refill rate of bucket
/// @return A boolean that indicates if the operation was successful.
function setRate(uint256 _rate) public onlyOwner returns (bool) {
rate = _rate;
return true;
}
/// @notice Change size and refill rate of bucket
/// @dev Require owner role to call
/// @param _size is new size of bucket
/// @param _rate is new refill rate of bucket
/// @return A boolean that indicates if the operation was successful.
function setSizeAndRate(uint256 _size, uint256 _rate) public onlyOwner returns (bool) {
return setSize(_size) && setRate(_rate);
}
/// @notice 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 onlyMinter returns (bool) {
uint256 available = availableTokens();
require(_amount <= available);
leftOnLastMint = available.sub(_amount);
lastMintTime = now; // solium-disable-line security/no-block-members
require(token.mint(_to, _amount));
return true;
}
/// @notice Function to calculate and get available in bucket tokens
/// @return An amount of available tokens in bucket
function availableTokens() public view returns (uint) {
// solium-disable-next-line security/no-block-members
uint256 timeAfterMint = now.sub(lastMintTime);
uint256 refillAmount = rate.mul(timeAfterMint).add(leftOnLastMint);
return size < refillAmount ? size : refillAmount;
}
} | /// @title Very simplified implementation of Token Bucket Algorithm to secure token minting
/// @author Abha Mai <[email protected]>
/// @notice Works with tokens implemented Mintable interface
/// @dev Transfer ownership/minting role to contract and execute mint over PlatformBucket proxy to secure | NatSpecSingleLine | mint | function mint(address _to, uint256 _amount) public onlyMinter returns (bool) {
uint256 available = availableTokens();
require(_amount <= available);
leftOnLastMint = available.sub(_amount);
lastMintTime = now; // solium-disable-line security/no-block-members
require(token.mint(_to, _amount));
return true;
}
| /// @notice 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. | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e8222a9f0fd59b8113ff1346a3cba13133854607afc7942535e47e52ed741f17 | {
"func_code_index": [
2720,
3064
]
} | 9,476 |
|
PlatformBucket | PlatformBucket.sol | 0xa8550944706f8c6dc51a71f6b8ee29826468c0a9 | Solidity | PlatformBucket | contract PlatformBucket is RBACMixin, IMintableToken {
using SafeMath for uint;
/// @notice Limit maximum amount of available for minting tokens when bucket is full
/// @dev Should be enough to mint tokens with proper speed but less enough to prevent overminting in case of losing pkey
uint256 public size;
/// @notice Bucket refill rate
/// @dev Tokens per second (based on block.timestamp). Amount without decimals (in smallest part of token)
uint256 public rate;
/// @notice Stored time of latest minting
/// @dev Each successful call of minting function will update field with call timestamp
uint256 public lastMintTime;
/// @notice Left tokens in bucket on time of latest minting
uint256 public leftOnLastMint;
/// @notice Reference of Mintable token
/// @dev Setup in contructor phase and never change in future
IMintableToken public token;
/// @notice Token Bucket leak event fires on each minting
/// @param to is address of target tokens holder
/// @param left is amount of tokens available in bucket after leak
event Leak(address indexed to, uint256 left);
/// @param _token is address of Mintable token
/// @param _size initial size of token bucket
/// @param _rate initial refill rate (tokens/sec)
constructor (address _token, uint256 _size, uint256 _rate) public {
token = IMintableToken(_token);
size = _size;
rate = _rate;
leftOnLastMint = _size;
}
/// @notice Change size of bucket
/// @dev Require owner role to call
/// @param _size is new size of bucket
/// @return A boolean that indicates if the operation was successful.
function setSize(uint256 _size) public onlyOwner returns (bool) {
size = _size;
return true;
}
/// @notice Change refill rate of bucket
/// @dev Require owner role to call
/// @param _rate is new refill rate of bucket
/// @return A boolean that indicates if the operation was successful.
function setRate(uint256 _rate) public onlyOwner returns (bool) {
rate = _rate;
return true;
}
/// @notice Change size and refill rate of bucket
/// @dev Require owner role to call
/// @param _size is new size of bucket
/// @param _rate is new refill rate of bucket
/// @return A boolean that indicates if the operation was successful.
function setSizeAndRate(uint256 _size, uint256 _rate) public onlyOwner returns (bool) {
return setSize(_size) && setRate(_rate);
}
/// @notice 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 onlyMinter returns (bool) {
uint256 available = availableTokens();
require(_amount <= available);
leftOnLastMint = available.sub(_amount);
lastMintTime = now; // solium-disable-line security/no-block-members
require(token.mint(_to, _amount));
return true;
}
/// @notice Function to calculate and get available in bucket tokens
/// @return An amount of available tokens in bucket
function availableTokens() public view returns (uint) {
// solium-disable-next-line security/no-block-members
uint256 timeAfterMint = now.sub(lastMintTime);
uint256 refillAmount = rate.mul(timeAfterMint).add(leftOnLastMint);
return size < refillAmount ? size : refillAmount;
}
} | /// @title Very simplified implementation of Token Bucket Algorithm to secure token minting
/// @author Abha Mai <[email protected]>
/// @notice Works with tokens implemented Mintable interface
/// @dev Transfer ownership/minting role to contract and execute mint over PlatformBucket proxy to secure | NatSpecSingleLine | availableTokens | function availableTokens() public view returns (uint) {
// solium-disable-next-line security/no-block-members
uint256 timeAfterMint = now.sub(lastMintTime);
uint256 refillAmount = rate.mul(timeAfterMint).add(leftOnLastMint);
return size < refillAmount ? size : refillAmount;
}
| /// @notice Function to calculate and get available in bucket tokens
/// @return An amount of available tokens in bucket | NatSpecSingleLine | v0.4.25+commit.59dbf8f1 | bzzr://e8222a9f0fd59b8113ff1346a3cba13133854607afc7942535e47e52ed741f17 | {
"func_code_index": [
3194,
3497
]
} | 9,477 |
|
OnliCoinToken | OnliCoinToken.sol | 0xd6658bc6b09286a298f4367c951f9ad1da8141d9 | Solidity | OnliCoinToken | contract OnliCoinToken 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 OnliCoinToken() public {
symbol = "OCT";
name = "OnliCoin Token";
decimals = 18;
_totalSupply = 88888888000000000000000000;
balances[0x9455680b53FbF52f59Cc199122ad8a586878186E] = _totalSupply;
Transfer(address(0), 0x9455680b53FbF52f59Cc199122ad8a586878186E, _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);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | OnliCoinToken | function OnliCoinToken() public {
symbol = "OCT";
name = "OnliCoin Token";
decimals = 18;
_totalSupply = 88888888000000000000000000;
balances[0x9455680b53FbF52f59Cc199122ad8a586878186E] = _totalSupply;
Transfer(address(0), 0x9455680b53FbF52f59Cc199122ad8a586878186E, _totalSupply);
}
| // ------------------------------------------------------------------------
// Constructor
// ------------------------------------------------------------------------ | LineComment | v0.4.23-nightly.2018.4.19+commit.ae834e3d | bzzr://17bef0c3a8a22ba191c68a6c9da070994cec6db19665f813e728c9fb3cd58f80 | {
"func_code_index": [
460,
807
]
} | 9,478 |
|
OnliCoinToken | OnliCoinToken.sol | 0xd6658bc6b09286a298f4367c951f9ad1da8141d9 | Solidity | OnliCoinToken | contract OnliCoinToken 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 OnliCoinToken() public {
symbol = "OCT";
name = "OnliCoin Token";
decimals = 18;
_totalSupply = 88888888000000000000000000;
balances[0x9455680b53FbF52f59Cc199122ad8a586878186E] = _totalSupply;
Transfer(address(0), 0x9455680b53FbF52f59Cc199122ad8a586878186E, _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);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | totalSupply | function totalSupply() public constant returns (uint) {
return _totalSupply - balances[address(0)];
}
| // ------------------------------------------------------------------------
// Total supply
// ------------------------------------------------------------------------ | LineComment | v0.4.23-nightly.2018.4.19+commit.ae834e3d | bzzr://17bef0c3a8a22ba191c68a6c9da070994cec6db19665f813e728c9fb3cd58f80 | {
"func_code_index": [
995,
1116
]
} | 9,479 |
|
OnliCoinToken | OnliCoinToken.sol | 0xd6658bc6b09286a298f4367c951f9ad1da8141d9 | Solidity | OnliCoinToken | contract OnliCoinToken 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 OnliCoinToken() public {
symbol = "OCT";
name = "OnliCoin Token";
decimals = 18;
_totalSupply = 88888888000000000000000000;
balances[0x9455680b53FbF52f59Cc199122ad8a586878186E] = _totalSupply;
Transfer(address(0), 0x9455680b53FbF52f59Cc199122ad8a586878186E, _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);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | balanceOf | function balanceOf(address tokenOwner) public constant returns (uint balance) {
return balances[tokenOwner];
}
| // ------------------------------------------------------------------------
// Get the token balance for account tokenOwner
// ------------------------------------------------------------------------ | LineComment | v0.4.23-nightly.2018.4.19+commit.ae834e3d | bzzr://17bef0c3a8a22ba191c68a6c9da070994cec6db19665f813e728c9fb3cd58f80 | {
"func_code_index": [
1336,
1465
]
} | 9,480 |
|
OnliCoinToken | OnliCoinToken.sol | 0xd6658bc6b09286a298f4367c951f9ad1da8141d9 | Solidity | OnliCoinToken | contract OnliCoinToken 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 OnliCoinToken() public {
symbol = "OCT";
name = "OnliCoin Token";
decimals = 18;
_totalSupply = 88888888000000000000000000;
balances[0x9455680b53FbF52f59Cc199122ad8a586878186E] = _totalSupply;
Transfer(address(0), 0x9455680b53FbF52f59Cc199122ad8a586878186E, _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);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | transfer | 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;
}
| // ------------------------------------------------------------------------
// 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
// ------------------------------------------------------------------------ | LineComment | v0.4.23-nightly.2018.4.19+commit.ae834e3d | bzzr://17bef0c3a8a22ba191c68a6c9da070994cec6db19665f813e728c9fb3cd58f80 | {
"func_code_index": [
1809,
2086
]
} | 9,481 |
|
OnliCoinToken | OnliCoinToken.sol | 0xd6658bc6b09286a298f4367c951f9ad1da8141d9 | Solidity | OnliCoinToken | contract OnliCoinToken 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 OnliCoinToken() public {
symbol = "OCT";
name = "OnliCoin Token";
decimals = 18;
_totalSupply = 88888888000000000000000000;
balances[0x9455680b53FbF52f59Cc199122ad8a586878186E] = _totalSupply;
Transfer(address(0), 0x9455680b53FbF52f59Cc199122ad8a586878186E, _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);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | approve | function approve(address spender, uint tokens) public returns (bool success) {
allowed[msg.sender][spender] = tokens;
Approval(msg.sender, spender, 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
// ------------------------------------------------------------------------ | LineComment | v0.4.23-nightly.2018.4.19+commit.ae834e3d | bzzr://17bef0c3a8a22ba191c68a6c9da070994cec6db19665f813e728c9fb3cd58f80 | {
"func_code_index": [
2594,
2802
]
} | 9,482 |
|
OnliCoinToken | OnliCoinToken.sol | 0xd6658bc6b09286a298f4367c951f9ad1da8141d9 | Solidity | OnliCoinToken | contract OnliCoinToken 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 OnliCoinToken() public {
symbol = "OCT";
name = "OnliCoin Token";
decimals = 18;
_totalSupply = 88888888000000000000000000;
balances[0x9455680b53FbF52f59Cc199122ad8a586878186E] = _totalSupply;
Transfer(address(0), 0x9455680b53FbF52f59Cc199122ad8a586878186E, _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);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | transferFrom | 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;
}
| // ------------------------------------------------------------------------
// 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
// ------------------------------------------------------------------------ | LineComment | v0.4.23-nightly.2018.4.19+commit.ae834e3d | bzzr://17bef0c3a8a22ba191c68a6c9da070994cec6db19665f813e728c9fb3cd58f80 | {
"func_code_index": [
3333,
3691
]
} | 9,483 |
|
OnliCoinToken | OnliCoinToken.sol | 0xd6658bc6b09286a298f4367c951f9ad1da8141d9 | Solidity | OnliCoinToken | contract OnliCoinToken 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 OnliCoinToken() public {
symbol = "OCT";
name = "OnliCoin Token";
decimals = 18;
_totalSupply = 88888888000000000000000000;
balances[0x9455680b53FbF52f59Cc199122ad8a586878186E] = _totalSupply;
Transfer(address(0), 0x9455680b53FbF52f59Cc199122ad8a586878186E, _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);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | allowance | function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
return allowed[tokenOwner][spender];
}
| // ------------------------------------------------------------------------
// Returns the amount of tokens approved by the owner that can be
// transferred to the spender's account
// ------------------------------------------------------------------------ | LineComment | v0.4.23-nightly.2018.4.19+commit.ae834e3d | bzzr://17bef0c3a8a22ba191c68a6c9da070994cec6db19665f813e728c9fb3cd58f80 | {
"func_code_index": [
3974,
4130
]
} | 9,484 |
|
OnliCoinToken | OnliCoinToken.sol | 0xd6658bc6b09286a298f4367c951f9ad1da8141d9 | Solidity | OnliCoinToken | contract OnliCoinToken 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 OnliCoinToken() public {
symbol = "OCT";
name = "OnliCoin Token";
decimals = 18;
_totalSupply = 88888888000000000000000000;
balances[0x9455680b53FbF52f59Cc199122ad8a586878186E] = _totalSupply;
Transfer(address(0), 0x9455680b53FbF52f59Cc199122ad8a586878186E, _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);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | approveAndCall | 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;
}
| // ------------------------------------------------------------------------
// Token owner can approve for spender to transferFrom(...) tokens
// from the token owner's account. The spender contract function
// receiveApproval(...) is then executed
// ------------------------------------------------------------------------ | LineComment | v0.4.23-nightly.2018.4.19+commit.ae834e3d | bzzr://17bef0c3a8a22ba191c68a6c9da070994cec6db19665f813e728c9fb3cd58f80 | {
"func_code_index": [
4485,
4802
]
} | 9,485 |
|
OnliCoinToken | OnliCoinToken.sol | 0xd6658bc6b09286a298f4367c951f9ad1da8141d9 | Solidity | OnliCoinToken | contract OnliCoinToken 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 OnliCoinToken() public {
symbol = "OCT";
name = "OnliCoin Token";
decimals = 18;
_totalSupply = 88888888000000000000000000;
balances[0x9455680b53FbF52f59Cc199122ad8a586878186E] = _totalSupply;
Transfer(address(0), 0x9455680b53FbF52f59Cc199122ad8a586878186E, _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);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | function () public payable {
revert();
}
| // ------------------------------------------------------------------------
// Don't accept ETH
// ------------------------------------------------------------------------ | LineComment | v0.4.23-nightly.2018.4.19+commit.ae834e3d | bzzr://17bef0c3a8a22ba191c68a6c9da070994cec6db19665f813e728c9fb3cd58f80 | {
"func_code_index": [
4994,
5053
]
} | 9,486 |
||
OnliCoinToken | OnliCoinToken.sol | 0xd6658bc6b09286a298f4367c951f9ad1da8141d9 | Solidity | OnliCoinToken | contract OnliCoinToken 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 OnliCoinToken() public {
symbol = "OCT";
name = "OnliCoin Token";
decimals = 18;
_totalSupply = 88888888000000000000000000;
balances[0x9455680b53FbF52f59Cc199122ad8a586878186E] = _totalSupply;
Transfer(address(0), 0x9455680b53FbF52f59Cc199122ad8a586878186E, _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);
}
} | // ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ---------------------------------------------------------------------------- | LineComment | transferAnyERC20Token | function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
return ERC20Interface(tokenAddress).transfer(owner, tokens);
}
| // ------------------------------------------------------------------------
// Owner can transfer out any accidentally sent ERC20 tokens
// ------------------------------------------------------------------------ | LineComment | v0.4.23-nightly.2018.4.19+commit.ae834e3d | bzzr://17bef0c3a8a22ba191c68a6c9da070994cec6db19665f813e728c9fb3cd58f80 | {
"func_code_index": [
5286,
5475
]
} | 9,487 |
|
PrePaid | @animoca/ethereum-contracts-core_library/contracts/access/WhitelistedOperators.sol | 0x590df9dc51ea5e1c7a93e61f1a973cea1fc730b8 | Solidity | WhitelistedOperators | contract WhitelistedOperators is Ownable {
mapping(address => bool) internal _whitelistedOperators;
event WhitelistedOperator(address operator, bool enabled);
/// @notice Enable or disable address operator access
/// @param operator address that will be given/removed operator right.
/// @param enabled set whether the operator is enabled or disabled.
function whitelistOperator(address operator, bool enabled) external onlyOwner {
_whitelistedOperators[operator] = enabled;
emit WhitelistedOperator(operator, enabled);
}
/// @notice check whether address `who` is given operator rights.
/// @param who The address to query.
/// @return whether the address is whitelisted operator
function isOperator(address who) public view returns (bool) {
return _whitelistedOperators[who];
}
} | whitelistOperator | function whitelistOperator(address operator, bool enabled) external onlyOwner {
_whitelistedOperators[operator] = enabled;
emit WhitelistedOperator(operator, enabled);
}
| /// @notice Enable or disable address operator access
/// @param operator address that will be given/removed operator right.
/// @param enabled set whether the operator is enabled or disabled. | NatSpecSingleLine | v0.6.8+commit.0bbfe453 | MIT | ipfs://76837e53ae3de2f335dc63db9411b9cee342d7b69eed8996a4928ce505ae018d | {
"func_code_index": [
384,
581
]
} | 9,488 |
||
PrePaid | @animoca/ethereum-contracts-core_library/contracts/access/WhitelistedOperators.sol | 0x590df9dc51ea5e1c7a93e61f1a973cea1fc730b8 | Solidity | WhitelistedOperators | contract WhitelistedOperators is Ownable {
mapping(address => bool) internal _whitelistedOperators;
event WhitelistedOperator(address operator, bool enabled);
/// @notice Enable or disable address operator access
/// @param operator address that will be given/removed operator right.
/// @param enabled set whether the operator is enabled or disabled.
function whitelistOperator(address operator, bool enabled) external onlyOwner {
_whitelistedOperators[operator] = enabled;
emit WhitelistedOperator(operator, enabled);
}
/// @notice check whether address `who` is given operator rights.
/// @param who The address to query.
/// @return whether the address is whitelisted operator
function isOperator(address who) public view returns (bool) {
return _whitelistedOperators[who];
}
} | isOperator | function isOperator(address who) public view returns (bool) {
return _whitelistedOperators[who];
}
| /// @notice check whether address `who` is given operator rights.
/// @param who The address to query.
/// @return whether the address is whitelisted operator | NatSpecSingleLine | v0.6.8+commit.0bbfe453 | MIT | ipfs://76837e53ae3de2f335dc63db9411b9cee342d7b69eed8996a4928ce505ae018d | {
"func_code_index": [
758,
875
]
} | 9,489 |
||
PrePaid | @animoca/ethereum-contracts-erc20_base/contracts/token/ERC20/IERC20.sol | 0x590df9dc51ea5e1c7a93e61f1a973cea1fc730b8 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(
address indexed _from,
address indexed _to,
uint256 _value
);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _value
);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.6.8+commit.0bbfe453 | MIT | ipfs://76837e53ae3de2f335dc63db9411b9cee342d7b69eed8996a4928ce505ae018d | {
"func_code_index": [
662,
722
]
} | 9,490 |
PrePaid | @animoca/ethereum-contracts-erc20_base/contracts/token/ERC20/IERC20.sol | 0x590df9dc51ea5e1c7a93e61f1a973cea1fc730b8 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(
address indexed _from,
address indexed _to,
uint256 _value
);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _value
);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.6.8+commit.0bbfe453 | MIT | ipfs://76837e53ae3de2f335dc63db9411b9cee342d7b69eed8996a4928ce505ae018d | {
"func_code_index": [
805,
878
]
} | 9,491 |
PrePaid | @animoca/ethereum-contracts-erc20_base/contracts/token/ERC20/IERC20.sol | 0x590df9dc51ea5e1c7a93e61f1a973cea1fc730b8 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(
address indexed _from,
address indexed _to,
uint256 _value
);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _value
);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | transfer | function transfer(address recipient, uint256 amount) external returns (bool);
| /**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/ | NatSpecMultiLine | v0.6.8+commit.0bbfe453 | MIT | ipfs://76837e53ae3de2f335dc63db9411b9cee342d7b69eed8996a4928ce505ae018d | {
"func_code_index": [
1102,
1184
]
} | 9,492 |
PrePaid | @animoca/ethereum-contracts-erc20_base/contracts/token/ERC20/IERC20.sol | 0x590df9dc51ea5e1c7a93e61f1a973cea1fc730b8 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(
address indexed _from,
address indexed _to,
uint256 _value
);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _value
);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | allowance | function allowance(address owner, address spender) external view returns (uint256);
| /**
* @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.
*/ | NatSpecMultiLine | v0.6.8+commit.0bbfe453 | MIT | ipfs://76837e53ae3de2f335dc63db9411b9cee342d7b69eed8996a4928ce505ae018d | {
"func_code_index": [
1463,
1551
]
} | 9,493 |
PrePaid | @animoca/ethereum-contracts-erc20_base/contracts/token/ERC20/IERC20.sol | 0x590df9dc51ea5e1c7a93e61f1a973cea1fc730b8 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(
address indexed _from,
address indexed _to,
uint256 _value
);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _value
);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | approve | function approve(address spender, uint256 amount) external returns (bool);
| /**
* @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.
*/ | NatSpecMultiLine | v0.6.8+commit.0bbfe453 | MIT | ipfs://76837e53ae3de2f335dc63db9411b9cee342d7b69eed8996a4928ce505ae018d | {
"func_code_index": [
2215,
2294
]
} | 9,494 |
PrePaid | @animoca/ethereum-contracts-erc20_base/contracts/token/ERC20/IERC20.sol | 0x590df9dc51ea5e1c7a93e61f1a973cea1fc730b8 | Solidity | IERC20 | interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(
address indexed _from,
address indexed _to,
uint256 _value
);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(
address indexed _owner,
address indexed _spender,
uint256 _value
);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
} | /**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/ | NatSpecMultiLine | transferFrom | function transferFrom(address sender, address recipient, 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.
*/ | NatSpecMultiLine | v0.6.8+commit.0bbfe453 | MIT | ipfs://76837e53ae3de2f335dc63db9411b9cee342d7b69eed8996a4928ce505ae018d | {
"func_code_index": [
2607,
2709
]
} | 9,495 |
ovatel | ovatel.sol | 0x22581e0198ed6ea34d438148a106903f5fb846c0 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | totalSupply | function totalSupply() constant returns (uint256 supply) {}
| /// @return total amount of tokens | NatSpecSingleLine | v0.4.24+commit.e67f0147 | bzzr://1843f3b3f57f4c854536dd3b78bc5e57d051cfa15f97a983dd71a0ac4c79a2d0 | {
"func_code_index": [
60,
124
]
} | 9,496 |
|||
ovatel | ovatel.sol | 0x22581e0198ed6ea34d438148a106903f5fb846c0 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | balanceOf | function balanceOf(address _owner) constant returns (uint256 balance) {}
| /// @param _owner The address from which the balance will be retrieved
/// @return The balance | NatSpecSingleLine | v0.4.24+commit.e67f0147 | bzzr://1843f3b3f57f4c854536dd3b78bc5e57d051cfa15f97a983dd71a0ac4c79a2d0 | {
"func_code_index": [
232,
309
]
} | 9,497 |
|||
ovatel | ovatel.sol | 0x22581e0198ed6ea34d438148a106903f5fb846c0 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | transfer | function transfer(address _to, uint256 _value) returns (bool success) {}
| /// @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 | NatSpecSingleLine | v0.4.24+commit.e67f0147 | bzzr://1843f3b3f57f4c854536dd3b78bc5e57d051cfa15f97a983dd71a0ac4c79a2d0 | {
"func_code_index": [
546,
623
]
} | 9,498 |
|||
ovatel | ovatel.sol | 0x22581e0198ed6ea34d438148a106903f5fb846c0 | Solidity | Token | contract Token {
/// @return total amount of tokens
function totalSupply() constant returns (uint256 supply) {}
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant returns (uint256 balance) {}
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) returns (bool success) {}
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) returns (bool success) {}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
} | transferFrom | function transferFrom(address _from, 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 | NatSpecSingleLine | v0.4.24+commit.e67f0147 | bzzr://1843f3b3f57f4c854536dd3b78bc5e57d051cfa15f97a983dd71a0ac4c79a2d0 | {
"func_code_index": [
946,
1042
]
} | 9,499 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.