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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | 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);
/**
* @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);
} | totalSupply | function totalSupply() external view returns (uint256);
| /**
* @dev Returns the amount of tokens in existence.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
104,
168
]
} | 700 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | 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);
/**
* @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);
} | balanceOf | function balanceOf(address account) external view returns (uint256);
| /**
* @dev Returns the amount of tokens owned by `account`.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
261,
338
]
} | 701 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | 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);
/**
* @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);
} | 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.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
584,
670
]
} | 702 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | 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);
/**
* @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);
} | 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.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
971,
1063
]
} | 703 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | 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);
/**
* @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);
} | 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.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
1770,
1853
]
} | 704 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | 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);
/**
* @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);
} | 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.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
2194,
2300
]
} | 705 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | 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.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
290,
496
]
} | 706 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | 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.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
805,
958
]
} | 707 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | 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.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
1287,
1504
]
} | 708 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | 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.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
1789,
2309
]
} | 709 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | 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.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
2817,
2966
]
} | 710 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | div | function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
| /**
* @dev Returns the 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.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
3494,
3801
]
} | 711 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | 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.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
4298,
4445
]
} | 712 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | SafeMath | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
/**
* @dev Returns the integer division of two unsigned integers. Reverts with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* Reverts with custom message when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
} | 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.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
4962,
5149
]
} | 713 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | isContract | function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
| /**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
658,
1322
]
} | 714 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | sendValue | function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
| /**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
2301,
2727
]
} | 715 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | functionCall | function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
| /**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
3538,
3726
]
} | 716 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | functionCall | function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
3970,
4183
]
} | 717 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
| /**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
4587,
4830
]
} | 718 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | Address | library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
} | functionCallWithValue | function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
| /**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
5100,
5437
]
} | 719 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | Ownable | contract Ownable is Context {
address private _owner;
address private _previousOwner;
uint256 private _lockTime;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
function geUnlockTime() public view returns (uint256) {
return _lockTime;
}
//Locks the contract for owner for the amount of time provided
function lock(uint256 time) public virtual onlyOwner {
_previousOwner = _owner;
_owner = address(0);
_lockTime = now + time;
emit OwnershipTransferred(_owner, address(0));
}
//Unlocks the contract for owner when _lockTime is exceeds
function unlock() public virtual {
require(_previousOwner == msg.sender, "You don't have permission to unlock");
require(now > _lockTime , "Contract is locked until 7 days");
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
}
} | owner | function owner() public view returns (address) {
return _owner;
}
| /**
* @dev Returns the address of the current owner.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
622,
718
]
} | 720 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | Ownable | contract Ownable is Context {
address private _owner;
address private _previousOwner;
uint256 private _lockTime;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
function geUnlockTime() public view returns (uint256) {
return _lockTime;
}
//Locks the contract for owner for the amount of time provided
function lock(uint256 time) public virtual onlyOwner {
_previousOwner = _owner;
_owner = address(0);
_lockTime = now + time;
emit OwnershipTransferred(_owner, address(0));
}
//Unlocks the contract for owner when _lockTime is exceeds
function unlock() public virtual {
require(_previousOwner == msg.sender, "You don't have permission to unlock");
require(now > _lockTime , "Contract is locked until 7 days");
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
}
} | renounceOwnership | function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = 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.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
1324,
1493
]
} | 721 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | Ownable | contract Ownable is Context {
address private _owner;
address private _previousOwner;
uint256 private _lockTime;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
function geUnlockTime() public view returns (uint256) {
return _lockTime;
}
//Locks the contract for owner for the amount of time provided
function lock(uint256 time) public virtual onlyOwner {
_previousOwner = _owner;
_owner = address(0);
_lockTime = now + time;
emit OwnershipTransferred(_owner, address(0));
}
//Unlocks the contract for owner when _lockTime is exceeds
function unlock() public virtual {
require(_previousOwner == msg.sender, "You don't have permission to unlock");
require(now > _lockTime , "Contract is locked until 7 days");
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
}
} | transferOwnership | function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
| /**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/ | NatSpecMultiLine | v0.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
1656,
1925
]
} | 722 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | Ownable | contract Ownable is Context {
address private _owner;
address private _previousOwner;
uint256 private _lockTime;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
function geUnlockTime() public view returns (uint256) {
return _lockTime;
}
//Locks the contract for owner for the amount of time provided
function lock(uint256 time) public virtual onlyOwner {
_previousOwner = _owner;
_owner = address(0);
_lockTime = now + time;
emit OwnershipTransferred(_owner, address(0));
}
//Unlocks the contract for owner when _lockTime is exceeds
function unlock() public virtual {
require(_previousOwner == msg.sender, "You don't have permission to unlock");
require(now > _lockTime , "Contract is locked until 7 days");
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
}
} | lock | function lock(uint256 time) public virtual onlyOwner {
_previousOwner = _owner;
_owner = address(0);
_lockTime = now + time;
emit OwnershipTransferred(_owner, address(0));
}
| //Locks the contract for owner for the amount of time provided | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
2109,
2352
]
} | 723 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | Ownable | contract Ownable is Context {
address private _owner;
address private _previousOwner;
uint256 private _lockTime;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
function geUnlockTime() public view returns (uint256) {
return _lockTime;
}
//Locks the contract for owner for the amount of time provided
function lock(uint256 time) public virtual onlyOwner {
_previousOwner = _owner;
_owner = address(0);
_lockTime = now + time;
emit OwnershipTransferred(_owner, address(0));
}
//Unlocks the contract for owner when _lockTime is exceeds
function unlock() public virtual {
require(_previousOwner == msg.sender, "You don't have permission to unlock");
require(now > _lockTime , "Contract is locked until 7 days");
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
}
} | unlock | function unlock() public virtual {
require(_previousOwner == msg.sender, "You don't have permission to unlock");
require(now > _lockTime , "Contract is locked until 7 days");
emit OwnershipTransferred(_owner, _previousOwner);
_owner = _previousOwner;
}
| //Unlocks the contract for owner when _lockTime is exceeds | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
2431,
2753
]
} | 724 |
||
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | RangikuInu | contract RangikuInu is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 1000000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'Rangiku Inu';
string private _symbol = 'Rangiku';
uint8 private _decimals = 9;
// Tax and development fees will start at 0 so we don't have a big impact when deploying to Uniswap
// development wallet address is null but the method to set the address is exposed
uint256 private _taxFee = 2;
uint256 private _MarketingFee = 4;
uint256 private _previousTaxFee = _taxFee;
uint256 private _previousMarketingFee = _MarketingFee;
address payable public _MarketingWalletAddress;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwap = false;
bool public swapEnabled = true;
uint256 private _maxTxAmount = 100000000000000e9;
// We will set a minimum amount of tokens to be swaped => 5M
uint256 private _numOfTokensToExchangeForMarketing = 5 * 10**3 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapEnabledUpdated(bool enabled);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor (address payable MarketingWalletAddress) public {
_MarketingWalletAddress = MarketingWalletAddress;
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); //
//IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); //
// Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
// set the rest of the contract variables
uniswapV2Router = _uniswapV2Router;
// Exclude owner and this contract from fee
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_MarketingWalletAddress] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function isExcluded(address account) public view returns (bool) {
return _isExcluded[account];
}
function setExcludeFromFee(address account, bool excluded) external onlyOwner() {
_isExcludedFromFee[account] = excluded;
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function deliver(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount,,,,,) = _getValues(tAmount);
return rAmount;
} else {
(,uint256 rTransferAmount,,,,) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function excludeAccount(address account) external onlyOwner() {
require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.');
require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
}
function includeAccount(address account) external onlyOwner() {
require(_isExcluded[account], "Account is already excluded");
for (uint256 i = 0; i < _excluded.length; i++) {
if (_excluded[i] == account) {
_excluded[i] = _excluded[_excluded.length - 1];
_tOwned[account] = 0;
_isExcluded[account] = false;
_excluded.pop();
break;
}
}
}
function removeAllFee() private {
if(_taxFee == 0 && _MarketingFee == 0) return;
_previousTaxFee = _taxFee;
_previousMarketingFee = _MarketingFee;
_taxFee = 0;
_MarketingFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_MarketingFee = _previousMarketingFee;
}
function isExcludedFromFee(address account) public view returns(bool) {
return _isExcludedFromFee[account];
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address sender, address recipient, uint256 amount) private {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if(sender != owner() && recipient != owner())
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
// is the token balance of this contract address over the min number of
// tokens that we need to initiate a swap?
// also, don't get caught in a circular development event.
// also, don't swap if sender is uniswap pair.
uint256 contractTokenBalance = balanceOf(address(this));
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForMarketing;
if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) {
// We need to swap the current tokens to ETH and send to the development wallet
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToMarketing(address(this).balance);
}
}
//indicates if fee should be deducted from transfer
bool takeFee = true;
//if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){
takeFee = false;
}
//transfer amount, it will take tax and development fee
_tokenTransfer(sender,recipient,amount,takeFee);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap{
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function sendETHToMarketing(uint256 amount) private {
_MarketingWalletAddress.transfer(amount.mul(2).div(6));
}
// We are exposing these functions to be able to manual swap and send
// in case the token is highly valued and 5M becomes too much
function manualSwap() external onlyOwner() {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualSend() external onlyOwner() {
uint256 contractETHBalance = address(this).balance;
sendETHToMarketing(contractETHBalance);
}
function setSwapEnabled(bool enabled) external onlyOwner(){
swapEnabled = enabled;
}
function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private {
if(!takeFee)
removeAllFee();
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
_transferStandard(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
if(!takeFee)
restoreAllFee();
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketing(tMarketing);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketing(tMarketing);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketing(tMarketing);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketing(tMarketing);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeMarketing(uint256 tMarketing) private {
uint256 currentRate = _getRate();
uint256 rMarketing = tMarketing.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rMarketing);
if(_isExcluded[address(this)])
_tOwned[address(this)] = _tOwned[address(this)].add(tMarketing);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
//to recieve ETH from uniswapV2Router when swaping
receive() external payable {}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getTValues(tAmount, _taxFee, _MarketingFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tMarketing);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 MarketingFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tMarketing = tAmount.mul(MarketingFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tMarketing);
return (tTransferAmount, tFee, tMarketing);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function _getTaxFee() private view returns(uint256) {
return _taxFee;
}
function _getMaxTxAmount() private view returns(uint256) {
return _maxTxAmount;
}
function _getETHBalance() public view returns(uint256 balance) {
return address(this).balance;
}
function _setTaxFee(uint256 taxFee) external onlyOwner() {
require(taxFee >= 0 && taxFee <= 25, 'taxFee should be in 0 - 25');
_taxFee = taxFee;
}
function _setMarketingFee(uint256 MarketingFee) external onlyOwner() {
require(MarketingFee >= 1 && MarketingFee <= 25, 'MarketingFee should be in 1 - 25');
_MarketingFee = MarketingFee;
}
function _setMarketingWallet(address payable MarketingWalletAddress) external onlyOwner() {
_MarketingWalletAddress = MarketingWalletAddress;
}
function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() {
_maxTxAmount = maxTxAmount;
}
} | // Contract implementation | LineComment | manualSwap | function manualSwap() external onlyOwner() {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
| // We are exposing these functions to be able to manual swap and send
// in case the token is highly valued and 5M becomes too much | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
11714,
11891
]
} | 725 |
RangikuInu | RangikuInu.sol | 0x8608deb942ca8dfaf02f0e3a152224f2b9bb1c3b | Solidity | RangikuInu | contract RangikuInu is Context, IERC20, Ownable {
using SafeMath for uint256;
using Address for address;
mapping (address => uint256) private _rOwned;
mapping (address => uint256) private _tOwned;
mapping (address => mapping (address => uint256)) private _allowances;
mapping (address => bool) private _isExcludedFromFee;
mapping (address => bool) private _isExcluded;
address[] private _excluded;
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 1000000000000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
string private _name = 'Rangiku Inu';
string private _symbol = 'Rangiku';
uint8 private _decimals = 9;
// Tax and development fees will start at 0 so we don't have a big impact when deploying to Uniswap
// development wallet address is null but the method to set the address is exposed
uint256 private _taxFee = 2;
uint256 private _MarketingFee = 4;
uint256 private _previousTaxFee = _taxFee;
uint256 private _previousMarketingFee = _MarketingFee;
address payable public _MarketingWalletAddress;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
bool inSwap = false;
bool public swapEnabled = true;
uint256 private _maxTxAmount = 100000000000000e9;
// We will set a minimum amount of tokens to be swaped => 5M
uint256 private _numOfTokensToExchangeForMarketing = 5 * 10**3 * 10**9;
event MinTokensBeforeSwapUpdated(uint256 minTokensBeforeSwap);
event SwapEnabledUpdated(bool enabled);
modifier lockTheSwap {
inSwap = true;
_;
inSwap = false;
}
constructor (address payable MarketingWalletAddress) public {
_MarketingWalletAddress = MarketingWalletAddress;
_rOwned[_msgSender()] = _rTotal;
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); //
//IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D); //
// Create a uniswap pair for this new token
uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
// set the rest of the contract variables
uniswapV2Router = _uniswapV2Router;
// Exclude owner and this contract from fee
_isExcludedFromFee[owner()] = true;
_isExcludedFromFee[address(this)] = true;
_isExcludedFromFee[_MarketingWalletAddress] = true;
emit Transfer(address(0), _msgSender(), _tTotal);
}
function name() public view returns (string memory) {
return _name;
}
function symbol() public view returns (string memory) {
return _symbol;
}
function decimals() public view returns (uint8) {
return _decimals;
}
function totalSupply() public view override returns (uint256) {
return _tTotal;
}
function balanceOf(address account) public view override returns (uint256) {
if (_isExcluded[account]) return _tOwned[account];
return tokenFromReflection(_rOwned[account]);
}
function transfer(address recipient, uint256 amount) public override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
function allowance(address owner, address spender) public view override returns (uint256) {
return _allowances[owner][spender];
}
function approve(address spender, uint256 amount) public override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero"));
return true;
}
function isExcluded(address account) public view returns (bool) {
return _isExcluded[account];
}
function setExcludeFromFee(address account, bool excluded) external onlyOwner() {
_isExcludedFromFee[account] = excluded;
}
function totalFees() public view returns (uint256) {
return _tFeeTotal;
}
function deliver(uint256 tAmount) public {
address sender = _msgSender();
require(!_isExcluded[sender], "Excluded addresses cannot call this function");
(uint256 rAmount,,,,,) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rTotal = _rTotal.sub(rAmount);
_tFeeTotal = _tFeeTotal.add(tAmount);
}
function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) {
require(tAmount <= _tTotal, "Amount must be less than supply");
if (!deductTransferFee) {
(uint256 rAmount,,,,,) = _getValues(tAmount);
return rAmount;
} else {
(,uint256 rTransferAmount,,,,) = _getValues(tAmount);
return rTransferAmount;
}
}
function tokenFromReflection(uint256 rAmount) public view returns(uint256) {
require(rAmount <= _rTotal, "Amount must be less than total reflections");
uint256 currentRate = _getRate();
return rAmount.div(currentRate);
}
function excludeAccount(address account) external onlyOwner() {
require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.');
require(!_isExcluded[account], "Account is already excluded");
if(_rOwned[account] > 0) {
_tOwned[account] = tokenFromReflection(_rOwned[account]);
}
_isExcluded[account] = true;
_excluded.push(account);
}
function includeAccount(address account) external onlyOwner() {
require(_isExcluded[account], "Account is already excluded");
for (uint256 i = 0; i < _excluded.length; i++) {
if (_excluded[i] == account) {
_excluded[i] = _excluded[_excluded.length - 1];
_tOwned[account] = 0;
_isExcluded[account] = false;
_excluded.pop();
break;
}
}
}
function removeAllFee() private {
if(_taxFee == 0 && _MarketingFee == 0) return;
_previousTaxFee = _taxFee;
_previousMarketingFee = _MarketingFee;
_taxFee = 0;
_MarketingFee = 0;
}
function restoreAllFee() private {
_taxFee = _previousTaxFee;
_MarketingFee = _previousMarketingFee;
}
function isExcludedFromFee(address account) public view returns(bool) {
return _isExcludedFromFee[account];
}
function _approve(address owner, address spender, uint256 amount) private {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _transfer(address sender, address recipient, uint256 amount) private {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
require(amount > 0, "Transfer amount must be greater than zero");
if(sender != owner() && recipient != owner())
require(amount <= _maxTxAmount, "Transfer amount exceeds the maxTxAmount.");
// is the token balance of this contract address over the min number of
// tokens that we need to initiate a swap?
// also, don't get caught in a circular development event.
// also, don't swap if sender is uniswap pair.
uint256 contractTokenBalance = balanceOf(address(this));
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
bool overMinTokenBalance = contractTokenBalance >= _numOfTokensToExchangeForMarketing;
if (!inSwap && swapEnabled && overMinTokenBalance && sender != uniswapV2Pair) {
// We need to swap the current tokens to ETH and send to the development wallet
swapTokensForEth(contractTokenBalance);
uint256 contractETHBalance = address(this).balance;
if(contractETHBalance > 0) {
sendETHToMarketing(address(this).balance);
}
}
//indicates if fee should be deducted from transfer
bool takeFee = true;
//if any account belongs to _isExcludedFromFee account then remove the fee
if(_isExcludedFromFee[sender] || _isExcludedFromFee[recipient]){
takeFee = false;
}
//transfer amount, it will take tax and development fee
_tokenTransfer(sender,recipient,amount,takeFee);
}
function swapTokensForEth(uint256 tokenAmount) private lockTheSwap{
// generate the uniswap pair path of token -> weth
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
// make the swap
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount,
0, // accept any amount of ETH
path,
address(this),
block.timestamp
);
}
function sendETHToMarketing(uint256 amount) private {
_MarketingWalletAddress.transfer(amount.mul(2).div(6));
}
// We are exposing these functions to be able to manual swap and send
// in case the token is highly valued and 5M becomes too much
function manualSwap() external onlyOwner() {
uint256 contractBalance = balanceOf(address(this));
swapTokensForEth(contractBalance);
}
function manualSend() external onlyOwner() {
uint256 contractETHBalance = address(this).balance;
sendETHToMarketing(contractETHBalance);
}
function setSwapEnabled(bool enabled) external onlyOwner(){
swapEnabled = enabled;
}
function _tokenTransfer(address sender, address recipient, uint256 amount, bool takeFee) private {
if(!takeFee)
removeAllFee();
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
_transferToExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && !_isExcluded[recipient]) {
_transferStandard(sender, recipient, amount);
} else if (_isExcluded[sender] && _isExcluded[recipient]) {
_transferBothExcluded(sender, recipient, amount);
} else {
_transferStandard(sender, recipient, amount);
}
if(!takeFee)
restoreAllFee();
}
function _transferStandard(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketing(tMarketing);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferToExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketing(tMarketing);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferFromExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketing(tMarketing);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _transferBothExcluded(address sender, address recipient, uint256 tAmount) private {
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee, uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getValues(tAmount);
_tOwned[sender] = _tOwned[sender].sub(tAmount);
_rOwned[sender] = _rOwned[sender].sub(rAmount);
_tOwned[recipient] = _tOwned[recipient].add(tTransferAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
_takeMarketing(tMarketing);
_reflectFee(rFee, tFee);
emit Transfer(sender, recipient, tTransferAmount);
}
function _takeMarketing(uint256 tMarketing) private {
uint256 currentRate = _getRate();
uint256 rMarketing = tMarketing.mul(currentRate);
_rOwned[address(this)] = _rOwned[address(this)].add(rMarketing);
if(_isExcluded[address(this)])
_tOwned[address(this)] = _tOwned[address(this)].add(tMarketing);
}
function _reflectFee(uint256 rFee, uint256 tFee) private {
_rTotal = _rTotal.sub(rFee);
_tFeeTotal = _tFeeTotal.add(tFee);
}
//to recieve ETH from uniswapV2Router when swaping
receive() external payable {}
function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) {
(uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getTValues(tAmount, _taxFee, _MarketingFee);
uint256 currentRate = _getRate();
(uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, currentRate);
return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tMarketing);
}
function _getTValues(uint256 tAmount, uint256 taxFee, uint256 MarketingFee) private pure returns (uint256, uint256, uint256) {
uint256 tFee = tAmount.mul(taxFee).div(100);
uint256 tMarketing = tAmount.mul(MarketingFee).div(100);
uint256 tTransferAmount = tAmount.sub(tFee).sub(tMarketing);
return (tTransferAmount, tFee, tMarketing);
}
function _getRValues(uint256 tAmount, uint256 tFee, uint256 currentRate) private pure returns (uint256, uint256, uint256) {
uint256 rAmount = tAmount.mul(currentRate);
uint256 rFee = tFee.mul(currentRate);
uint256 rTransferAmount = rAmount.sub(rFee);
return (rAmount, rTransferAmount, rFee);
}
function _getRate() private view returns(uint256) {
(uint256 rSupply, uint256 tSupply) = _getCurrentSupply();
return rSupply.div(tSupply);
}
function _getCurrentSupply() private view returns(uint256, uint256) {
uint256 rSupply = _rTotal;
uint256 tSupply = _tTotal;
for (uint256 i = 0; i < _excluded.length; i++) {
if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal);
rSupply = rSupply.sub(_rOwned[_excluded[i]]);
tSupply = tSupply.sub(_tOwned[_excluded[i]]);
}
if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal);
return (rSupply, tSupply);
}
function _getTaxFee() private view returns(uint256) {
return _taxFee;
}
function _getMaxTxAmount() private view returns(uint256) {
return _maxTxAmount;
}
function _getETHBalance() public view returns(uint256 balance) {
return address(this).balance;
}
function _setTaxFee(uint256 taxFee) external onlyOwner() {
require(taxFee >= 0 && taxFee <= 25, 'taxFee should be in 0 - 25');
_taxFee = taxFee;
}
function _setMarketingFee(uint256 MarketingFee) external onlyOwner() {
require(MarketingFee >= 1 && MarketingFee <= 25, 'MarketingFee should be in 1 - 25');
_MarketingFee = MarketingFee;
}
function _setMarketingWallet(address payable MarketingWalletAddress) external onlyOwner() {
_MarketingWalletAddress = MarketingWalletAddress;
}
function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() {
_maxTxAmount = maxTxAmount;
}
} | // Contract implementation | LineComment | //to recieve ETH from uniswapV2Router when swaping | LineComment | v0.6.12+commit.27d51765 | MIT | ipfs://c5e7269e0826b349706b321a902fde15dbc22b9e5af4bf5e2575db812f66f9c8 | {
"func_code_index": [
16214,
16252
]
} | 726 |
||
PhunkyFungi | PhunkyFungi.sol | 0xdf0e921f7e5a837805bfbe02012db648a12d72cc | Solidity | PhunkyFungi | contract PhunkyFungi is ERC721A, MultisigOwnable {
using Strings for uint256;
address private immutable _revenueRecipient;
bytes32 private _presaleMerkleRoot;
bytes32 private _collabMerkleRoot;
mapping(address=>uint) private _presaleClaimed;
mapping(address=>bool) private _collabClaimed;
string private _baseUri;
string private _placeholderURI;
bool public listsFinalized = false;
bool public metadataFinalized = false;
bool public timesFinalized = false;
bool public airdropped = false;
bool public revealed = false;
bool private _overrideCollab = false;
bool private _overridePresale = false;
bool private _overridePublic = false;
uint public constant PRESALE_LIMIT = 3;
uint public constant PUBLIC_LIMIT = 5;
uint public constant COLLECTION_SIZE = 9200;
uint public constant PRESALE_PRICE = 0.098 ether;
uint public constant PUBLIC_PRICE = 0.125 ether;
uint public constant TEAM_AIRDROP_LIMIT = 100;
uint public presaleStart = 1647097200; // 2022-03-12 10:00am EST
uint public presaleEnd = 1647104400; // 2022-03-12 12:00pm EST
uint public collabStart = 1647099000; // 2022-03-12 10:30am EST
uint public collabEnd = 1647104400; // 2022-03-12 12:00pm EST
uint public publicStart = 1647104400; // 2022-03-12 12:00pm EST
constructor(
address revenueRecipient,
bytes32 presaleMerkleRoot,
bytes32 collabMerkleRoot,
string memory placeholderURI
)
ERC721A("PhunkyFungi", "PF")
{
_revenueRecipient = revenueRecipient;
_presaleMerkleRoot = presaleMerkleRoot;
_collabMerkleRoot = collabMerkleRoot;
_placeholderURI = placeholderURI;
}
/// @notice the initial 100 tokens will be minted to the team vault for use in giveaways and collaborations.
function airdrop(address to, uint quantity) external onlyOwner {
require(airdropped == false, "ALREADY_AIRDROPPED");
require(quantity <= TEAM_AIRDROP_LIMIT, "EXCEEDS_AIRDROP_LIMIT");
airdropped = true;
_safeMint(to, quantity);
}
function isCollabSaleActive() public view returns(bool){
if(_overrideCollab){
return true;
}
return block.timestamp > collabStart && block.timestamp < collabEnd;
}
function isPresaleActive() public view returns(bool){
if(_overridePresale){
return true;
}
return block.timestamp > presaleStart && block.timestamp < presaleEnd;
}
function isPublicSaleActive() public view returns(bool){
if(_overridePublic){
return true;
}
return block.timestamp > publicStart;
}
function setPresaleMerkleRoot(bytes32 root) external onlyOwner {
require(listsFinalized == false, "LIST_FINALIZED");
_presaleMerkleRoot = root;
}
function setCollabMerkleRoot(bytes32 root) external onlyOwner {
require(listsFinalized == false, "LIST_FINALIZED");
_collabMerkleRoot = root;
}
function setPresaleTimes(
uint _presaleStartTime,
uint _presaleEndTime
) onlyOwner external {
require(timesFinalized == false, "TIMES_FINALIZED");
presaleStart = _presaleStartTime;
presaleEnd = _presaleEndTime;
}
function setCollabSaleTimes(
uint _collabStartTime,
uint _collabEndTime
) onlyOwner external {
require(timesFinalized == false, "TIMES_FINALIZED");
collabStart = _collabStartTime;
collabEnd = _collabEndTime;
}
function setPublicSaleTimes(
uint _publicStartTime
) onlyOwner external {
require(timesFinalized == false, "TIMES_FINALIZED");
publicStart = _publicStartTime;
}
function toggleReveal() external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
revealed = !revealed;
}
function toggleCollab() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
_overrideCollab = !_overrideCollab;
}
function togglePresale() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
_overridePresale = !_overridePresale;
}
function togglePublic() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
_overridePublic = !_overridePublic;
}
function finalizeMetadata() external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
metadataFinalized = true;
}
function finalizeTimes() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
timesFinalized = true;
}
function finalizeLists() external onlyOwner {
require(listsFinalized == false, "LIST_FINALIZED");
listsFinalized = true;
}
function setBaseURI(string memory baseUri) external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
_baseUri = baseUri;
}
function setPlaceholderURI(string memory placeholderUri) external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
_placeholderURI = placeholderUri;
}
/// @dev override base uri. It will be combined with token ID
function _baseURI() internal view override returns (string memory) {
return _baseUri;
}
/// @notice Withdraw's contract's balance to the withdrawal address
function withdraw() external {
uint256 balance = address(this).balance;
require(balance > 0, "NO_BALANCE");
(bool success, ) = payable(_revenueRecipient).call{ value: balance }("");
require(success, "WITHDRAW_FAILED");
}
function _verifyList(bytes32[] calldata _merkleProof, bytes32 root, address addr) internal view returns(bool) {
return (MerkleProof.verify(_merkleProof, root, keccak256(abi.encodePacked(addr))) == true);
}
function verifyPresale(bytes32[] calldata _merkleProof, address addr) public view returns(bool) {
return _verifyList(_merkleProof, _presaleMerkleRoot, addr);
}
function verifyCollab(bytes32[] calldata _merkleProof, address addr) public view returns(bool) {
return _verifyList(_merkleProof, _collabMerkleRoot, addr);
}
/// @notice each address on the collaboration list may mint 1 token at the collab sale price
function collabMint(bytes32[] calldata _merkleProof) external payable {
require(isCollabSaleActive(), "COLLAB_SALE_INACTIVE");
require(_collabClaimed[msg.sender] == false, "1_TOKEN_LIMIT");
require(totalSupply() < COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
require(verifyCollab(_merkleProof, msg.sender), "COLLAB_NOT_VERIFIED");
require(msg.value >= PRESALE_PRICE, "VALUE_TOO_LOW");
_collabClaimed[msg.sender] = true;
_safeMint(msg.sender, 1);
}
/// @notice each address on the presale list may mint up to 3 tokens at the presale price
function presaleMint(bytes32[] calldata _merkleProof, uint quantity) external payable {
require(isPresaleActive(), "PRESALE_INACTIVE");
require(verifyPresale(_merkleProof, msg.sender), "PRESALE_NOT_VERIFIED");
require(totalSupply() + quantity <= COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
require(_presaleClaimed[msg.sender] + quantity <= PRESALE_LIMIT, "3_TOKEN_LIMIT");
uint cost;
cost = quantity * PRESALE_PRICE;
require(msg.value >= cost, "VALUE_TOO_LOW");
_presaleClaimed[msg.sender] += quantity;
_safeMint(msg.sender, quantity);
}
/// @notice may mint up to 5 tokens per transaction at the public sale price.
function mint(uint quantity) external payable {
require(isPublicSaleActive(), "PUBLIC_SALE_INACTIVE");
require(quantity <= PUBLIC_LIMIT, "5_TOKEN_LIMIT");
require(totalSupply() + quantity <= COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
uint cost;
cost = quantity * PUBLIC_PRICE;
require(msg.value >= cost, "VALUE_TOO_LOW");
_safeMint(msg.sender, quantity);
}
function tokenURI(uint256 id) public view override returns (string memory) {
require(_exists(id), "INVALID_ID");
return revealed
? string(abi.encodePacked(_baseURI(), id.toString(), ".json"))
: _placeholderURI;
}
} | airdrop | function airdrop(address to, uint quantity) external onlyOwner {
require(airdropped == false, "ALREADY_AIRDROPPED");
require(quantity <= TEAM_AIRDROP_LIMIT, "EXCEEDS_AIRDROP_LIMIT");
airdropped = true;
_safeMint(to, quantity);
}
| /// @notice the initial 100 tokens will be minted to the team vault for use in giveaways and collaborations. | NatSpecSingleLine | v0.8.9+commit.e5eed63a | {
"func_code_index": [
1901,
2169
]
} | 727 |
||||
PhunkyFungi | PhunkyFungi.sol | 0xdf0e921f7e5a837805bfbe02012db648a12d72cc | Solidity | PhunkyFungi | contract PhunkyFungi is ERC721A, MultisigOwnable {
using Strings for uint256;
address private immutable _revenueRecipient;
bytes32 private _presaleMerkleRoot;
bytes32 private _collabMerkleRoot;
mapping(address=>uint) private _presaleClaimed;
mapping(address=>bool) private _collabClaimed;
string private _baseUri;
string private _placeholderURI;
bool public listsFinalized = false;
bool public metadataFinalized = false;
bool public timesFinalized = false;
bool public airdropped = false;
bool public revealed = false;
bool private _overrideCollab = false;
bool private _overridePresale = false;
bool private _overridePublic = false;
uint public constant PRESALE_LIMIT = 3;
uint public constant PUBLIC_LIMIT = 5;
uint public constant COLLECTION_SIZE = 9200;
uint public constant PRESALE_PRICE = 0.098 ether;
uint public constant PUBLIC_PRICE = 0.125 ether;
uint public constant TEAM_AIRDROP_LIMIT = 100;
uint public presaleStart = 1647097200; // 2022-03-12 10:00am EST
uint public presaleEnd = 1647104400; // 2022-03-12 12:00pm EST
uint public collabStart = 1647099000; // 2022-03-12 10:30am EST
uint public collabEnd = 1647104400; // 2022-03-12 12:00pm EST
uint public publicStart = 1647104400; // 2022-03-12 12:00pm EST
constructor(
address revenueRecipient,
bytes32 presaleMerkleRoot,
bytes32 collabMerkleRoot,
string memory placeholderURI
)
ERC721A("PhunkyFungi", "PF")
{
_revenueRecipient = revenueRecipient;
_presaleMerkleRoot = presaleMerkleRoot;
_collabMerkleRoot = collabMerkleRoot;
_placeholderURI = placeholderURI;
}
/// @notice the initial 100 tokens will be minted to the team vault for use in giveaways and collaborations.
function airdrop(address to, uint quantity) external onlyOwner {
require(airdropped == false, "ALREADY_AIRDROPPED");
require(quantity <= TEAM_AIRDROP_LIMIT, "EXCEEDS_AIRDROP_LIMIT");
airdropped = true;
_safeMint(to, quantity);
}
function isCollabSaleActive() public view returns(bool){
if(_overrideCollab){
return true;
}
return block.timestamp > collabStart && block.timestamp < collabEnd;
}
function isPresaleActive() public view returns(bool){
if(_overridePresale){
return true;
}
return block.timestamp > presaleStart && block.timestamp < presaleEnd;
}
function isPublicSaleActive() public view returns(bool){
if(_overridePublic){
return true;
}
return block.timestamp > publicStart;
}
function setPresaleMerkleRoot(bytes32 root) external onlyOwner {
require(listsFinalized == false, "LIST_FINALIZED");
_presaleMerkleRoot = root;
}
function setCollabMerkleRoot(bytes32 root) external onlyOwner {
require(listsFinalized == false, "LIST_FINALIZED");
_collabMerkleRoot = root;
}
function setPresaleTimes(
uint _presaleStartTime,
uint _presaleEndTime
) onlyOwner external {
require(timesFinalized == false, "TIMES_FINALIZED");
presaleStart = _presaleStartTime;
presaleEnd = _presaleEndTime;
}
function setCollabSaleTimes(
uint _collabStartTime,
uint _collabEndTime
) onlyOwner external {
require(timesFinalized == false, "TIMES_FINALIZED");
collabStart = _collabStartTime;
collabEnd = _collabEndTime;
}
function setPublicSaleTimes(
uint _publicStartTime
) onlyOwner external {
require(timesFinalized == false, "TIMES_FINALIZED");
publicStart = _publicStartTime;
}
function toggleReveal() external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
revealed = !revealed;
}
function toggleCollab() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
_overrideCollab = !_overrideCollab;
}
function togglePresale() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
_overridePresale = !_overridePresale;
}
function togglePublic() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
_overridePublic = !_overridePublic;
}
function finalizeMetadata() external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
metadataFinalized = true;
}
function finalizeTimes() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
timesFinalized = true;
}
function finalizeLists() external onlyOwner {
require(listsFinalized == false, "LIST_FINALIZED");
listsFinalized = true;
}
function setBaseURI(string memory baseUri) external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
_baseUri = baseUri;
}
function setPlaceholderURI(string memory placeholderUri) external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
_placeholderURI = placeholderUri;
}
/// @dev override base uri. It will be combined with token ID
function _baseURI() internal view override returns (string memory) {
return _baseUri;
}
/// @notice Withdraw's contract's balance to the withdrawal address
function withdraw() external {
uint256 balance = address(this).balance;
require(balance > 0, "NO_BALANCE");
(bool success, ) = payable(_revenueRecipient).call{ value: balance }("");
require(success, "WITHDRAW_FAILED");
}
function _verifyList(bytes32[] calldata _merkleProof, bytes32 root, address addr) internal view returns(bool) {
return (MerkleProof.verify(_merkleProof, root, keccak256(abi.encodePacked(addr))) == true);
}
function verifyPresale(bytes32[] calldata _merkleProof, address addr) public view returns(bool) {
return _verifyList(_merkleProof, _presaleMerkleRoot, addr);
}
function verifyCollab(bytes32[] calldata _merkleProof, address addr) public view returns(bool) {
return _verifyList(_merkleProof, _collabMerkleRoot, addr);
}
/// @notice each address on the collaboration list may mint 1 token at the collab sale price
function collabMint(bytes32[] calldata _merkleProof) external payable {
require(isCollabSaleActive(), "COLLAB_SALE_INACTIVE");
require(_collabClaimed[msg.sender] == false, "1_TOKEN_LIMIT");
require(totalSupply() < COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
require(verifyCollab(_merkleProof, msg.sender), "COLLAB_NOT_VERIFIED");
require(msg.value >= PRESALE_PRICE, "VALUE_TOO_LOW");
_collabClaimed[msg.sender] = true;
_safeMint(msg.sender, 1);
}
/// @notice each address on the presale list may mint up to 3 tokens at the presale price
function presaleMint(bytes32[] calldata _merkleProof, uint quantity) external payable {
require(isPresaleActive(), "PRESALE_INACTIVE");
require(verifyPresale(_merkleProof, msg.sender), "PRESALE_NOT_VERIFIED");
require(totalSupply() + quantity <= COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
require(_presaleClaimed[msg.sender] + quantity <= PRESALE_LIMIT, "3_TOKEN_LIMIT");
uint cost;
cost = quantity * PRESALE_PRICE;
require(msg.value >= cost, "VALUE_TOO_LOW");
_presaleClaimed[msg.sender] += quantity;
_safeMint(msg.sender, quantity);
}
/// @notice may mint up to 5 tokens per transaction at the public sale price.
function mint(uint quantity) external payable {
require(isPublicSaleActive(), "PUBLIC_SALE_INACTIVE");
require(quantity <= PUBLIC_LIMIT, "5_TOKEN_LIMIT");
require(totalSupply() + quantity <= COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
uint cost;
cost = quantity * PUBLIC_PRICE;
require(msg.value >= cost, "VALUE_TOO_LOW");
_safeMint(msg.sender, quantity);
}
function tokenURI(uint256 id) public view override returns (string memory) {
require(_exists(id), "INVALID_ID");
return revealed
? string(abi.encodePacked(_baseURI(), id.toString(), ".json"))
: _placeholderURI;
}
} | _baseURI | function _baseURI() internal view override returns (string memory) {
return _baseUri;
}
| /// @dev override base uri. It will be combined with token ID | NatSpecSingleLine | v0.8.9+commit.e5eed63a | {
"func_code_index": [
5377,
5480
]
} | 728 |
||||
PhunkyFungi | PhunkyFungi.sol | 0xdf0e921f7e5a837805bfbe02012db648a12d72cc | Solidity | PhunkyFungi | contract PhunkyFungi is ERC721A, MultisigOwnable {
using Strings for uint256;
address private immutable _revenueRecipient;
bytes32 private _presaleMerkleRoot;
bytes32 private _collabMerkleRoot;
mapping(address=>uint) private _presaleClaimed;
mapping(address=>bool) private _collabClaimed;
string private _baseUri;
string private _placeholderURI;
bool public listsFinalized = false;
bool public metadataFinalized = false;
bool public timesFinalized = false;
bool public airdropped = false;
bool public revealed = false;
bool private _overrideCollab = false;
bool private _overridePresale = false;
bool private _overridePublic = false;
uint public constant PRESALE_LIMIT = 3;
uint public constant PUBLIC_LIMIT = 5;
uint public constant COLLECTION_SIZE = 9200;
uint public constant PRESALE_PRICE = 0.098 ether;
uint public constant PUBLIC_PRICE = 0.125 ether;
uint public constant TEAM_AIRDROP_LIMIT = 100;
uint public presaleStart = 1647097200; // 2022-03-12 10:00am EST
uint public presaleEnd = 1647104400; // 2022-03-12 12:00pm EST
uint public collabStart = 1647099000; // 2022-03-12 10:30am EST
uint public collabEnd = 1647104400; // 2022-03-12 12:00pm EST
uint public publicStart = 1647104400; // 2022-03-12 12:00pm EST
constructor(
address revenueRecipient,
bytes32 presaleMerkleRoot,
bytes32 collabMerkleRoot,
string memory placeholderURI
)
ERC721A("PhunkyFungi", "PF")
{
_revenueRecipient = revenueRecipient;
_presaleMerkleRoot = presaleMerkleRoot;
_collabMerkleRoot = collabMerkleRoot;
_placeholderURI = placeholderURI;
}
/// @notice the initial 100 tokens will be minted to the team vault for use in giveaways and collaborations.
function airdrop(address to, uint quantity) external onlyOwner {
require(airdropped == false, "ALREADY_AIRDROPPED");
require(quantity <= TEAM_AIRDROP_LIMIT, "EXCEEDS_AIRDROP_LIMIT");
airdropped = true;
_safeMint(to, quantity);
}
function isCollabSaleActive() public view returns(bool){
if(_overrideCollab){
return true;
}
return block.timestamp > collabStart && block.timestamp < collabEnd;
}
function isPresaleActive() public view returns(bool){
if(_overridePresale){
return true;
}
return block.timestamp > presaleStart && block.timestamp < presaleEnd;
}
function isPublicSaleActive() public view returns(bool){
if(_overridePublic){
return true;
}
return block.timestamp > publicStart;
}
function setPresaleMerkleRoot(bytes32 root) external onlyOwner {
require(listsFinalized == false, "LIST_FINALIZED");
_presaleMerkleRoot = root;
}
function setCollabMerkleRoot(bytes32 root) external onlyOwner {
require(listsFinalized == false, "LIST_FINALIZED");
_collabMerkleRoot = root;
}
function setPresaleTimes(
uint _presaleStartTime,
uint _presaleEndTime
) onlyOwner external {
require(timesFinalized == false, "TIMES_FINALIZED");
presaleStart = _presaleStartTime;
presaleEnd = _presaleEndTime;
}
function setCollabSaleTimes(
uint _collabStartTime,
uint _collabEndTime
) onlyOwner external {
require(timesFinalized == false, "TIMES_FINALIZED");
collabStart = _collabStartTime;
collabEnd = _collabEndTime;
}
function setPublicSaleTimes(
uint _publicStartTime
) onlyOwner external {
require(timesFinalized == false, "TIMES_FINALIZED");
publicStart = _publicStartTime;
}
function toggleReveal() external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
revealed = !revealed;
}
function toggleCollab() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
_overrideCollab = !_overrideCollab;
}
function togglePresale() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
_overridePresale = !_overridePresale;
}
function togglePublic() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
_overridePublic = !_overridePublic;
}
function finalizeMetadata() external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
metadataFinalized = true;
}
function finalizeTimes() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
timesFinalized = true;
}
function finalizeLists() external onlyOwner {
require(listsFinalized == false, "LIST_FINALIZED");
listsFinalized = true;
}
function setBaseURI(string memory baseUri) external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
_baseUri = baseUri;
}
function setPlaceholderURI(string memory placeholderUri) external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
_placeholderURI = placeholderUri;
}
/// @dev override base uri. It will be combined with token ID
function _baseURI() internal view override returns (string memory) {
return _baseUri;
}
/// @notice Withdraw's contract's balance to the withdrawal address
function withdraw() external {
uint256 balance = address(this).balance;
require(balance > 0, "NO_BALANCE");
(bool success, ) = payable(_revenueRecipient).call{ value: balance }("");
require(success, "WITHDRAW_FAILED");
}
function _verifyList(bytes32[] calldata _merkleProof, bytes32 root, address addr) internal view returns(bool) {
return (MerkleProof.verify(_merkleProof, root, keccak256(abi.encodePacked(addr))) == true);
}
function verifyPresale(bytes32[] calldata _merkleProof, address addr) public view returns(bool) {
return _verifyList(_merkleProof, _presaleMerkleRoot, addr);
}
function verifyCollab(bytes32[] calldata _merkleProof, address addr) public view returns(bool) {
return _verifyList(_merkleProof, _collabMerkleRoot, addr);
}
/// @notice each address on the collaboration list may mint 1 token at the collab sale price
function collabMint(bytes32[] calldata _merkleProof) external payable {
require(isCollabSaleActive(), "COLLAB_SALE_INACTIVE");
require(_collabClaimed[msg.sender] == false, "1_TOKEN_LIMIT");
require(totalSupply() < COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
require(verifyCollab(_merkleProof, msg.sender), "COLLAB_NOT_VERIFIED");
require(msg.value >= PRESALE_PRICE, "VALUE_TOO_LOW");
_collabClaimed[msg.sender] = true;
_safeMint(msg.sender, 1);
}
/// @notice each address on the presale list may mint up to 3 tokens at the presale price
function presaleMint(bytes32[] calldata _merkleProof, uint quantity) external payable {
require(isPresaleActive(), "PRESALE_INACTIVE");
require(verifyPresale(_merkleProof, msg.sender), "PRESALE_NOT_VERIFIED");
require(totalSupply() + quantity <= COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
require(_presaleClaimed[msg.sender] + quantity <= PRESALE_LIMIT, "3_TOKEN_LIMIT");
uint cost;
cost = quantity * PRESALE_PRICE;
require(msg.value >= cost, "VALUE_TOO_LOW");
_presaleClaimed[msg.sender] += quantity;
_safeMint(msg.sender, quantity);
}
/// @notice may mint up to 5 tokens per transaction at the public sale price.
function mint(uint quantity) external payable {
require(isPublicSaleActive(), "PUBLIC_SALE_INACTIVE");
require(quantity <= PUBLIC_LIMIT, "5_TOKEN_LIMIT");
require(totalSupply() + quantity <= COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
uint cost;
cost = quantity * PUBLIC_PRICE;
require(msg.value >= cost, "VALUE_TOO_LOW");
_safeMint(msg.sender, quantity);
}
function tokenURI(uint256 id) public view override returns (string memory) {
require(_exists(id), "INVALID_ID");
return revealed
? string(abi.encodePacked(_baseURI(), id.toString(), ".json"))
: _placeholderURI;
}
} | withdraw | function withdraw() external {
uint256 balance = address(this).balance;
require(balance > 0, "NO_BALANCE");
(bool success, ) = payable(_revenueRecipient).call{ value: balance }("");
require(success, "WITHDRAW_FAILED");
}
| /// @notice Withdraw's contract's balance to the withdrawal address | NatSpecSingleLine | v0.8.9+commit.e5eed63a | {
"func_code_index": [
5554,
5815
]
} | 729 |
||||
PhunkyFungi | PhunkyFungi.sol | 0xdf0e921f7e5a837805bfbe02012db648a12d72cc | Solidity | PhunkyFungi | contract PhunkyFungi is ERC721A, MultisigOwnable {
using Strings for uint256;
address private immutable _revenueRecipient;
bytes32 private _presaleMerkleRoot;
bytes32 private _collabMerkleRoot;
mapping(address=>uint) private _presaleClaimed;
mapping(address=>bool) private _collabClaimed;
string private _baseUri;
string private _placeholderURI;
bool public listsFinalized = false;
bool public metadataFinalized = false;
bool public timesFinalized = false;
bool public airdropped = false;
bool public revealed = false;
bool private _overrideCollab = false;
bool private _overridePresale = false;
bool private _overridePublic = false;
uint public constant PRESALE_LIMIT = 3;
uint public constant PUBLIC_LIMIT = 5;
uint public constant COLLECTION_SIZE = 9200;
uint public constant PRESALE_PRICE = 0.098 ether;
uint public constant PUBLIC_PRICE = 0.125 ether;
uint public constant TEAM_AIRDROP_LIMIT = 100;
uint public presaleStart = 1647097200; // 2022-03-12 10:00am EST
uint public presaleEnd = 1647104400; // 2022-03-12 12:00pm EST
uint public collabStart = 1647099000; // 2022-03-12 10:30am EST
uint public collabEnd = 1647104400; // 2022-03-12 12:00pm EST
uint public publicStart = 1647104400; // 2022-03-12 12:00pm EST
constructor(
address revenueRecipient,
bytes32 presaleMerkleRoot,
bytes32 collabMerkleRoot,
string memory placeholderURI
)
ERC721A("PhunkyFungi", "PF")
{
_revenueRecipient = revenueRecipient;
_presaleMerkleRoot = presaleMerkleRoot;
_collabMerkleRoot = collabMerkleRoot;
_placeholderURI = placeholderURI;
}
/// @notice the initial 100 tokens will be minted to the team vault for use in giveaways and collaborations.
function airdrop(address to, uint quantity) external onlyOwner {
require(airdropped == false, "ALREADY_AIRDROPPED");
require(quantity <= TEAM_AIRDROP_LIMIT, "EXCEEDS_AIRDROP_LIMIT");
airdropped = true;
_safeMint(to, quantity);
}
function isCollabSaleActive() public view returns(bool){
if(_overrideCollab){
return true;
}
return block.timestamp > collabStart && block.timestamp < collabEnd;
}
function isPresaleActive() public view returns(bool){
if(_overridePresale){
return true;
}
return block.timestamp > presaleStart && block.timestamp < presaleEnd;
}
function isPublicSaleActive() public view returns(bool){
if(_overridePublic){
return true;
}
return block.timestamp > publicStart;
}
function setPresaleMerkleRoot(bytes32 root) external onlyOwner {
require(listsFinalized == false, "LIST_FINALIZED");
_presaleMerkleRoot = root;
}
function setCollabMerkleRoot(bytes32 root) external onlyOwner {
require(listsFinalized == false, "LIST_FINALIZED");
_collabMerkleRoot = root;
}
function setPresaleTimes(
uint _presaleStartTime,
uint _presaleEndTime
) onlyOwner external {
require(timesFinalized == false, "TIMES_FINALIZED");
presaleStart = _presaleStartTime;
presaleEnd = _presaleEndTime;
}
function setCollabSaleTimes(
uint _collabStartTime,
uint _collabEndTime
) onlyOwner external {
require(timesFinalized == false, "TIMES_FINALIZED");
collabStart = _collabStartTime;
collabEnd = _collabEndTime;
}
function setPublicSaleTimes(
uint _publicStartTime
) onlyOwner external {
require(timesFinalized == false, "TIMES_FINALIZED");
publicStart = _publicStartTime;
}
function toggleReveal() external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
revealed = !revealed;
}
function toggleCollab() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
_overrideCollab = !_overrideCollab;
}
function togglePresale() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
_overridePresale = !_overridePresale;
}
function togglePublic() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
_overridePublic = !_overridePublic;
}
function finalizeMetadata() external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
metadataFinalized = true;
}
function finalizeTimes() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
timesFinalized = true;
}
function finalizeLists() external onlyOwner {
require(listsFinalized == false, "LIST_FINALIZED");
listsFinalized = true;
}
function setBaseURI(string memory baseUri) external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
_baseUri = baseUri;
}
function setPlaceholderURI(string memory placeholderUri) external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
_placeholderURI = placeholderUri;
}
/// @dev override base uri. It will be combined with token ID
function _baseURI() internal view override returns (string memory) {
return _baseUri;
}
/// @notice Withdraw's contract's balance to the withdrawal address
function withdraw() external {
uint256 balance = address(this).balance;
require(balance > 0, "NO_BALANCE");
(bool success, ) = payable(_revenueRecipient).call{ value: balance }("");
require(success, "WITHDRAW_FAILED");
}
function _verifyList(bytes32[] calldata _merkleProof, bytes32 root, address addr) internal view returns(bool) {
return (MerkleProof.verify(_merkleProof, root, keccak256(abi.encodePacked(addr))) == true);
}
function verifyPresale(bytes32[] calldata _merkleProof, address addr) public view returns(bool) {
return _verifyList(_merkleProof, _presaleMerkleRoot, addr);
}
function verifyCollab(bytes32[] calldata _merkleProof, address addr) public view returns(bool) {
return _verifyList(_merkleProof, _collabMerkleRoot, addr);
}
/// @notice each address on the collaboration list may mint 1 token at the collab sale price
function collabMint(bytes32[] calldata _merkleProof) external payable {
require(isCollabSaleActive(), "COLLAB_SALE_INACTIVE");
require(_collabClaimed[msg.sender] == false, "1_TOKEN_LIMIT");
require(totalSupply() < COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
require(verifyCollab(_merkleProof, msg.sender), "COLLAB_NOT_VERIFIED");
require(msg.value >= PRESALE_PRICE, "VALUE_TOO_LOW");
_collabClaimed[msg.sender] = true;
_safeMint(msg.sender, 1);
}
/// @notice each address on the presale list may mint up to 3 tokens at the presale price
function presaleMint(bytes32[] calldata _merkleProof, uint quantity) external payable {
require(isPresaleActive(), "PRESALE_INACTIVE");
require(verifyPresale(_merkleProof, msg.sender), "PRESALE_NOT_VERIFIED");
require(totalSupply() + quantity <= COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
require(_presaleClaimed[msg.sender] + quantity <= PRESALE_LIMIT, "3_TOKEN_LIMIT");
uint cost;
cost = quantity * PRESALE_PRICE;
require(msg.value >= cost, "VALUE_TOO_LOW");
_presaleClaimed[msg.sender] += quantity;
_safeMint(msg.sender, quantity);
}
/// @notice may mint up to 5 tokens per transaction at the public sale price.
function mint(uint quantity) external payable {
require(isPublicSaleActive(), "PUBLIC_SALE_INACTIVE");
require(quantity <= PUBLIC_LIMIT, "5_TOKEN_LIMIT");
require(totalSupply() + quantity <= COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
uint cost;
cost = quantity * PUBLIC_PRICE;
require(msg.value >= cost, "VALUE_TOO_LOW");
_safeMint(msg.sender, quantity);
}
function tokenURI(uint256 id) public view override returns (string memory) {
require(_exists(id), "INVALID_ID");
return revealed
? string(abi.encodePacked(_baseURI(), id.toString(), ".json"))
: _placeholderURI;
}
} | collabMint | function collabMint(bytes32[] calldata _merkleProof) external payable {
require(isCollabSaleActive(), "COLLAB_SALE_INACTIVE");
require(_collabClaimed[msg.sender] == false, "1_TOKEN_LIMIT");
require(totalSupply() < COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
require(verifyCollab(_merkleProof, msg.sender), "COLLAB_NOT_VERIFIED");
require(msg.value >= PRESALE_PRICE, "VALUE_TOO_LOW");
_collabClaimed[msg.sender] = true;
_safeMint(msg.sender, 1);
}
| /// @notice each address on the collaboration list may mint 1 token at the collab sale price | NatSpecSingleLine | v0.8.9+commit.e5eed63a | {
"func_code_index": [
6491,
7003
]
} | 730 |
||||
PhunkyFungi | PhunkyFungi.sol | 0xdf0e921f7e5a837805bfbe02012db648a12d72cc | Solidity | PhunkyFungi | contract PhunkyFungi is ERC721A, MultisigOwnable {
using Strings for uint256;
address private immutable _revenueRecipient;
bytes32 private _presaleMerkleRoot;
bytes32 private _collabMerkleRoot;
mapping(address=>uint) private _presaleClaimed;
mapping(address=>bool) private _collabClaimed;
string private _baseUri;
string private _placeholderURI;
bool public listsFinalized = false;
bool public metadataFinalized = false;
bool public timesFinalized = false;
bool public airdropped = false;
bool public revealed = false;
bool private _overrideCollab = false;
bool private _overridePresale = false;
bool private _overridePublic = false;
uint public constant PRESALE_LIMIT = 3;
uint public constant PUBLIC_LIMIT = 5;
uint public constant COLLECTION_SIZE = 9200;
uint public constant PRESALE_PRICE = 0.098 ether;
uint public constant PUBLIC_PRICE = 0.125 ether;
uint public constant TEAM_AIRDROP_LIMIT = 100;
uint public presaleStart = 1647097200; // 2022-03-12 10:00am EST
uint public presaleEnd = 1647104400; // 2022-03-12 12:00pm EST
uint public collabStart = 1647099000; // 2022-03-12 10:30am EST
uint public collabEnd = 1647104400; // 2022-03-12 12:00pm EST
uint public publicStart = 1647104400; // 2022-03-12 12:00pm EST
constructor(
address revenueRecipient,
bytes32 presaleMerkleRoot,
bytes32 collabMerkleRoot,
string memory placeholderURI
)
ERC721A("PhunkyFungi", "PF")
{
_revenueRecipient = revenueRecipient;
_presaleMerkleRoot = presaleMerkleRoot;
_collabMerkleRoot = collabMerkleRoot;
_placeholderURI = placeholderURI;
}
/// @notice the initial 100 tokens will be minted to the team vault for use in giveaways and collaborations.
function airdrop(address to, uint quantity) external onlyOwner {
require(airdropped == false, "ALREADY_AIRDROPPED");
require(quantity <= TEAM_AIRDROP_LIMIT, "EXCEEDS_AIRDROP_LIMIT");
airdropped = true;
_safeMint(to, quantity);
}
function isCollabSaleActive() public view returns(bool){
if(_overrideCollab){
return true;
}
return block.timestamp > collabStart && block.timestamp < collabEnd;
}
function isPresaleActive() public view returns(bool){
if(_overridePresale){
return true;
}
return block.timestamp > presaleStart && block.timestamp < presaleEnd;
}
function isPublicSaleActive() public view returns(bool){
if(_overridePublic){
return true;
}
return block.timestamp > publicStart;
}
function setPresaleMerkleRoot(bytes32 root) external onlyOwner {
require(listsFinalized == false, "LIST_FINALIZED");
_presaleMerkleRoot = root;
}
function setCollabMerkleRoot(bytes32 root) external onlyOwner {
require(listsFinalized == false, "LIST_FINALIZED");
_collabMerkleRoot = root;
}
function setPresaleTimes(
uint _presaleStartTime,
uint _presaleEndTime
) onlyOwner external {
require(timesFinalized == false, "TIMES_FINALIZED");
presaleStart = _presaleStartTime;
presaleEnd = _presaleEndTime;
}
function setCollabSaleTimes(
uint _collabStartTime,
uint _collabEndTime
) onlyOwner external {
require(timesFinalized == false, "TIMES_FINALIZED");
collabStart = _collabStartTime;
collabEnd = _collabEndTime;
}
function setPublicSaleTimes(
uint _publicStartTime
) onlyOwner external {
require(timesFinalized == false, "TIMES_FINALIZED");
publicStart = _publicStartTime;
}
function toggleReveal() external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
revealed = !revealed;
}
function toggleCollab() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
_overrideCollab = !_overrideCollab;
}
function togglePresale() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
_overridePresale = !_overridePresale;
}
function togglePublic() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
_overridePublic = !_overridePublic;
}
function finalizeMetadata() external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
metadataFinalized = true;
}
function finalizeTimes() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
timesFinalized = true;
}
function finalizeLists() external onlyOwner {
require(listsFinalized == false, "LIST_FINALIZED");
listsFinalized = true;
}
function setBaseURI(string memory baseUri) external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
_baseUri = baseUri;
}
function setPlaceholderURI(string memory placeholderUri) external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
_placeholderURI = placeholderUri;
}
/// @dev override base uri. It will be combined with token ID
function _baseURI() internal view override returns (string memory) {
return _baseUri;
}
/// @notice Withdraw's contract's balance to the withdrawal address
function withdraw() external {
uint256 balance = address(this).balance;
require(balance > 0, "NO_BALANCE");
(bool success, ) = payable(_revenueRecipient).call{ value: balance }("");
require(success, "WITHDRAW_FAILED");
}
function _verifyList(bytes32[] calldata _merkleProof, bytes32 root, address addr) internal view returns(bool) {
return (MerkleProof.verify(_merkleProof, root, keccak256(abi.encodePacked(addr))) == true);
}
function verifyPresale(bytes32[] calldata _merkleProof, address addr) public view returns(bool) {
return _verifyList(_merkleProof, _presaleMerkleRoot, addr);
}
function verifyCollab(bytes32[] calldata _merkleProof, address addr) public view returns(bool) {
return _verifyList(_merkleProof, _collabMerkleRoot, addr);
}
/// @notice each address on the collaboration list may mint 1 token at the collab sale price
function collabMint(bytes32[] calldata _merkleProof) external payable {
require(isCollabSaleActive(), "COLLAB_SALE_INACTIVE");
require(_collabClaimed[msg.sender] == false, "1_TOKEN_LIMIT");
require(totalSupply() < COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
require(verifyCollab(_merkleProof, msg.sender), "COLLAB_NOT_VERIFIED");
require(msg.value >= PRESALE_PRICE, "VALUE_TOO_LOW");
_collabClaimed[msg.sender] = true;
_safeMint(msg.sender, 1);
}
/// @notice each address on the presale list may mint up to 3 tokens at the presale price
function presaleMint(bytes32[] calldata _merkleProof, uint quantity) external payable {
require(isPresaleActive(), "PRESALE_INACTIVE");
require(verifyPresale(_merkleProof, msg.sender), "PRESALE_NOT_VERIFIED");
require(totalSupply() + quantity <= COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
require(_presaleClaimed[msg.sender] + quantity <= PRESALE_LIMIT, "3_TOKEN_LIMIT");
uint cost;
cost = quantity * PRESALE_PRICE;
require(msg.value >= cost, "VALUE_TOO_LOW");
_presaleClaimed[msg.sender] += quantity;
_safeMint(msg.sender, quantity);
}
/// @notice may mint up to 5 tokens per transaction at the public sale price.
function mint(uint quantity) external payable {
require(isPublicSaleActive(), "PUBLIC_SALE_INACTIVE");
require(quantity <= PUBLIC_LIMIT, "5_TOKEN_LIMIT");
require(totalSupply() + quantity <= COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
uint cost;
cost = quantity * PUBLIC_PRICE;
require(msg.value >= cost, "VALUE_TOO_LOW");
_safeMint(msg.sender, quantity);
}
function tokenURI(uint256 id) public view override returns (string memory) {
require(_exists(id), "INVALID_ID");
return revealed
? string(abi.encodePacked(_baseURI(), id.toString(), ".json"))
: _placeholderURI;
}
} | presaleMint | function presaleMint(bytes32[] calldata _merkleProof, uint quantity) external payable {
require(isPresaleActive(), "PRESALE_INACTIVE");
require(verifyPresale(_merkleProof, msg.sender), "PRESALE_NOT_VERIFIED");
require(totalSupply() + quantity <= COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
require(_presaleClaimed[msg.sender] + quantity <= PRESALE_LIMIT, "3_TOKEN_LIMIT");
uint cost;
cost = quantity * PRESALE_PRICE;
require(msg.value >= cost, "VALUE_TOO_LOW");
_presaleClaimed[msg.sender] += quantity;
_safeMint(msg.sender, quantity);
}
| /// @notice each address on the presale list may mint up to 3 tokens at the presale price | NatSpecSingleLine | v0.8.9+commit.e5eed63a | {
"func_code_index": [
7103,
7722
]
} | 731 |
||||
PhunkyFungi | PhunkyFungi.sol | 0xdf0e921f7e5a837805bfbe02012db648a12d72cc | Solidity | PhunkyFungi | contract PhunkyFungi is ERC721A, MultisigOwnable {
using Strings for uint256;
address private immutable _revenueRecipient;
bytes32 private _presaleMerkleRoot;
bytes32 private _collabMerkleRoot;
mapping(address=>uint) private _presaleClaimed;
mapping(address=>bool) private _collabClaimed;
string private _baseUri;
string private _placeholderURI;
bool public listsFinalized = false;
bool public metadataFinalized = false;
bool public timesFinalized = false;
bool public airdropped = false;
bool public revealed = false;
bool private _overrideCollab = false;
bool private _overridePresale = false;
bool private _overridePublic = false;
uint public constant PRESALE_LIMIT = 3;
uint public constant PUBLIC_LIMIT = 5;
uint public constant COLLECTION_SIZE = 9200;
uint public constant PRESALE_PRICE = 0.098 ether;
uint public constant PUBLIC_PRICE = 0.125 ether;
uint public constant TEAM_AIRDROP_LIMIT = 100;
uint public presaleStart = 1647097200; // 2022-03-12 10:00am EST
uint public presaleEnd = 1647104400; // 2022-03-12 12:00pm EST
uint public collabStart = 1647099000; // 2022-03-12 10:30am EST
uint public collabEnd = 1647104400; // 2022-03-12 12:00pm EST
uint public publicStart = 1647104400; // 2022-03-12 12:00pm EST
constructor(
address revenueRecipient,
bytes32 presaleMerkleRoot,
bytes32 collabMerkleRoot,
string memory placeholderURI
)
ERC721A("PhunkyFungi", "PF")
{
_revenueRecipient = revenueRecipient;
_presaleMerkleRoot = presaleMerkleRoot;
_collabMerkleRoot = collabMerkleRoot;
_placeholderURI = placeholderURI;
}
/// @notice the initial 100 tokens will be minted to the team vault for use in giveaways and collaborations.
function airdrop(address to, uint quantity) external onlyOwner {
require(airdropped == false, "ALREADY_AIRDROPPED");
require(quantity <= TEAM_AIRDROP_LIMIT, "EXCEEDS_AIRDROP_LIMIT");
airdropped = true;
_safeMint(to, quantity);
}
function isCollabSaleActive() public view returns(bool){
if(_overrideCollab){
return true;
}
return block.timestamp > collabStart && block.timestamp < collabEnd;
}
function isPresaleActive() public view returns(bool){
if(_overridePresale){
return true;
}
return block.timestamp > presaleStart && block.timestamp < presaleEnd;
}
function isPublicSaleActive() public view returns(bool){
if(_overridePublic){
return true;
}
return block.timestamp > publicStart;
}
function setPresaleMerkleRoot(bytes32 root) external onlyOwner {
require(listsFinalized == false, "LIST_FINALIZED");
_presaleMerkleRoot = root;
}
function setCollabMerkleRoot(bytes32 root) external onlyOwner {
require(listsFinalized == false, "LIST_FINALIZED");
_collabMerkleRoot = root;
}
function setPresaleTimes(
uint _presaleStartTime,
uint _presaleEndTime
) onlyOwner external {
require(timesFinalized == false, "TIMES_FINALIZED");
presaleStart = _presaleStartTime;
presaleEnd = _presaleEndTime;
}
function setCollabSaleTimes(
uint _collabStartTime,
uint _collabEndTime
) onlyOwner external {
require(timesFinalized == false, "TIMES_FINALIZED");
collabStart = _collabStartTime;
collabEnd = _collabEndTime;
}
function setPublicSaleTimes(
uint _publicStartTime
) onlyOwner external {
require(timesFinalized == false, "TIMES_FINALIZED");
publicStart = _publicStartTime;
}
function toggleReveal() external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
revealed = !revealed;
}
function toggleCollab() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
_overrideCollab = !_overrideCollab;
}
function togglePresale() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
_overridePresale = !_overridePresale;
}
function togglePublic() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
_overridePublic = !_overridePublic;
}
function finalizeMetadata() external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
metadataFinalized = true;
}
function finalizeTimes() external onlyOwner {
require(timesFinalized == false, "TIMES_FINALIZED");
timesFinalized = true;
}
function finalizeLists() external onlyOwner {
require(listsFinalized == false, "LIST_FINALIZED");
listsFinalized = true;
}
function setBaseURI(string memory baseUri) external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
_baseUri = baseUri;
}
function setPlaceholderURI(string memory placeholderUri) external onlyOwner {
require(metadataFinalized == false, "METADATA_FINALIZED");
_placeholderURI = placeholderUri;
}
/// @dev override base uri. It will be combined with token ID
function _baseURI() internal view override returns (string memory) {
return _baseUri;
}
/// @notice Withdraw's contract's balance to the withdrawal address
function withdraw() external {
uint256 balance = address(this).balance;
require(balance > 0, "NO_BALANCE");
(bool success, ) = payable(_revenueRecipient).call{ value: balance }("");
require(success, "WITHDRAW_FAILED");
}
function _verifyList(bytes32[] calldata _merkleProof, bytes32 root, address addr) internal view returns(bool) {
return (MerkleProof.verify(_merkleProof, root, keccak256(abi.encodePacked(addr))) == true);
}
function verifyPresale(bytes32[] calldata _merkleProof, address addr) public view returns(bool) {
return _verifyList(_merkleProof, _presaleMerkleRoot, addr);
}
function verifyCollab(bytes32[] calldata _merkleProof, address addr) public view returns(bool) {
return _verifyList(_merkleProof, _collabMerkleRoot, addr);
}
/// @notice each address on the collaboration list may mint 1 token at the collab sale price
function collabMint(bytes32[] calldata _merkleProof) external payable {
require(isCollabSaleActive(), "COLLAB_SALE_INACTIVE");
require(_collabClaimed[msg.sender] == false, "1_TOKEN_LIMIT");
require(totalSupply() < COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
require(verifyCollab(_merkleProof, msg.sender), "COLLAB_NOT_VERIFIED");
require(msg.value >= PRESALE_PRICE, "VALUE_TOO_LOW");
_collabClaimed[msg.sender] = true;
_safeMint(msg.sender, 1);
}
/// @notice each address on the presale list may mint up to 3 tokens at the presale price
function presaleMint(bytes32[] calldata _merkleProof, uint quantity) external payable {
require(isPresaleActive(), "PRESALE_INACTIVE");
require(verifyPresale(_merkleProof, msg.sender), "PRESALE_NOT_VERIFIED");
require(totalSupply() + quantity <= COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
require(_presaleClaimed[msg.sender] + quantity <= PRESALE_LIMIT, "3_TOKEN_LIMIT");
uint cost;
cost = quantity * PRESALE_PRICE;
require(msg.value >= cost, "VALUE_TOO_LOW");
_presaleClaimed[msg.sender] += quantity;
_safeMint(msg.sender, quantity);
}
/// @notice may mint up to 5 tokens per transaction at the public sale price.
function mint(uint quantity) external payable {
require(isPublicSaleActive(), "PUBLIC_SALE_INACTIVE");
require(quantity <= PUBLIC_LIMIT, "5_TOKEN_LIMIT");
require(totalSupply() + quantity <= COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
uint cost;
cost = quantity * PUBLIC_PRICE;
require(msg.value >= cost, "VALUE_TOO_LOW");
_safeMint(msg.sender, quantity);
}
function tokenURI(uint256 id) public view override returns (string memory) {
require(_exists(id), "INVALID_ID");
return revealed
? string(abi.encodePacked(_baseURI(), id.toString(), ".json"))
: _placeholderURI;
}
} | mint | function mint(uint quantity) external payable {
require(isPublicSaleActive(), "PUBLIC_SALE_INACTIVE");
require(quantity <= PUBLIC_LIMIT, "5_TOKEN_LIMIT");
require(totalSupply() + quantity <= COLLECTION_SIZE, "EXCEEDS_COLLECTION_SIZE");
uint cost;
cost = quantity * PUBLIC_PRICE;
require(msg.value >= cost, "VALUE_TOO_LOW");
_safeMint(msg.sender, quantity);
}
| /// @notice may mint up to 5 tokens per transaction at the public sale price. | NatSpecSingleLine | v0.8.9+commit.e5eed63a | {
"func_code_index": [
7806,
8229
]
} | 732 |
||||
CVXStrategy | /contracts/main/strategies/CVXStrategy.sol | 0x228ef81476fa6eeb48be28a35bb11e9282f31c89 | Solidity | CVXStrategy | contract CVXStrategy is ClaimableStrategy {
ICVXRewards public cvxRewards;
function configure(
address _wantAddress,
address _controllerAddress,
address _governance,
address _cvxRewards
) public onlyOwner initializer {
_configure(_wantAddress, _controllerAddress, _governance);
cvxRewards = ICVXRewards(_cvxRewards);
}
/// @dev Function that controller calls
function deposit() external override onlyController {
IERC20 wantToken = IERC20(_want);
uint256 _amount = wantToken.balanceOf(address(this));
if (wantToken.allowance(address(this), address(cvxRewards)) == 0) {
wantToken.approve(address(cvxRewards), uint256(-1));
}
cvxRewards.stake(_amount);
}
function getRewards() external override {
cvxRewards.getReward(false);
}
function _withdrawSome(uint256 _amount)
internal
override
returns (uint256)
{
cvxRewards.withdraw(_amount, true);
return _amount;
}
} | /// @title CVXStrategy
/// @notice CVXVault strategy: in CVX out cvxCRV | NatSpecSingleLine | deposit | function deposit() external override onlyController {
IERC20 wantToken = IERC20(_want);
uint256 _amount = wantToken.balanceOf(address(this));
if (wantToken.allowance(address(this), address(cvxRewards)) == 0) {
wantToken.approve(address(cvxRewards), uint256(-1));
}
cvxRewards.stake(_amount);
}
| /// @dev Function that controller calls | NatSpecSingleLine | v0.6.6+commit.6c089d02 | {
"func_code_index": [
429,
782
]
} | 733 |
||
GrowthLockContract | GrowthLockContract.sol | 0x33729ec887c974cc6f692646c28137d22517b03f | Solidity | GrowthLockContract | contract GrowthLockContract {
address private owner;
address private safe;
address private mike;
address private ghost;
address private dev;
uint256 public time;
uint private constant devAmount = 4166.66 * 1 ether;
uint private constant managementAmount = 1388.88 * 1 ether;
//2629743 = 30 days.
uint public constant locktime = 2629743;
//0x09e64c2B61a5f1690Ee6fbeD9baf5D6990F8dFd0 is Growth Token address
ERC20Interface private constant token = ERC20Interface(0x09e64c2B61a5f1690Ee6fbeD9baf5D6990F8dFd0);
constructor () {
owner = msg.sender;
time = block.timestamp;
mike = 0x70F5FB6BE943162545a496eD120495B05dC5ce07;
ghost = 0x6811101D884557Eba52DF3Ea0417A3036D5b9FCd;
safe = 0xC4faC8CA576B9c8B971fA36916aEE062d84b4901;
dev = 0xB0632a01ee778E09625BcE2a257e221b49E79696;
}
//Modifier to prevent everyone except owner from using contract.
modifier onlyOwner(){
require(msg.sender == owner, "Unauthorized to call. ");
_;
}
//Admin can deposit the initial vested amount. You can only use this function once.
function depositToken(uint amount) public onlyOwner {
require(amount > 0, "Amount must be greater than zero");
require(token.transferFrom(msg.sender, address(this), amount) == true, "Inefficient balance or Unauthorized to pay. ");
}
//Admin pays dev and management team.
function payToken() public onlyOwner {
//check if it's past the next payperiod.
require(block.timestamp >= (time + locktime), "Period not reached yet. ");
//Sends dev payment.
require(token.transfer(dev, devAmount) == true, "You don't have enough in balance. ");
//sends management payments.
require(token.transfer(safe, managementAmount) == true, "You don't have enough in balance. ");
require(token.transfer(mike, managementAmount) == true, "You don't have enough in balance. ");
require(token.transfer(ghost, managementAmount) == true, "You don't have enough in balance. ");
time += locktime;
}
//Used to check contract balance.
function getBalance() view public returns (uint) {
return token.balanceOf(address(this));
}
///Updates the owner of the contract
function updateOwner(address newOwner) public onlyOwner {
owner = newOwner;
}
//Used incase management teams lost their wallet and needs to updated.
function updateManagement(address _mike, address _ghost, address _safe, address _dev) public onlyOwner {
mike = _mike;
ghost = _ghost;
safe = _safe;
dev = _dev;
}
//Check who owner is.
function getOwner() view public returns (address) {
return owner;
}
} | ///Contract that vests 200K GRO then payout after every month for the next 24 months. | NatSpecSingleLine | depositToken | function depositToken(uint amount) public onlyOwner {
require(amount > 0, "Amount must be greater than zero");
require(token.transferFrom(msg.sender, address(this), amount) == true, "Inefficient balance or Unauthorized to pay. ");
}
| //Admin can deposit the initial vested amount. You can only use this function once. | LineComment | v0.7.1+commit.f4a555be | MIT | ipfs://7be7aab06df9eea6ee52941d5a089f2daa3fa716cbffcaa4f8025405372d76cf | {
"func_code_index": [
1267,
1539
]
} | 734 |
GrowthLockContract | GrowthLockContract.sol | 0x33729ec887c974cc6f692646c28137d22517b03f | Solidity | GrowthLockContract | contract GrowthLockContract {
address private owner;
address private safe;
address private mike;
address private ghost;
address private dev;
uint256 public time;
uint private constant devAmount = 4166.66 * 1 ether;
uint private constant managementAmount = 1388.88 * 1 ether;
//2629743 = 30 days.
uint public constant locktime = 2629743;
//0x09e64c2B61a5f1690Ee6fbeD9baf5D6990F8dFd0 is Growth Token address
ERC20Interface private constant token = ERC20Interface(0x09e64c2B61a5f1690Ee6fbeD9baf5D6990F8dFd0);
constructor () {
owner = msg.sender;
time = block.timestamp;
mike = 0x70F5FB6BE943162545a496eD120495B05dC5ce07;
ghost = 0x6811101D884557Eba52DF3Ea0417A3036D5b9FCd;
safe = 0xC4faC8CA576B9c8B971fA36916aEE062d84b4901;
dev = 0xB0632a01ee778E09625BcE2a257e221b49E79696;
}
//Modifier to prevent everyone except owner from using contract.
modifier onlyOwner(){
require(msg.sender == owner, "Unauthorized to call. ");
_;
}
//Admin can deposit the initial vested amount. You can only use this function once.
function depositToken(uint amount) public onlyOwner {
require(amount > 0, "Amount must be greater than zero");
require(token.transferFrom(msg.sender, address(this), amount) == true, "Inefficient balance or Unauthorized to pay. ");
}
//Admin pays dev and management team.
function payToken() public onlyOwner {
//check if it's past the next payperiod.
require(block.timestamp >= (time + locktime), "Period not reached yet. ");
//Sends dev payment.
require(token.transfer(dev, devAmount) == true, "You don't have enough in balance. ");
//sends management payments.
require(token.transfer(safe, managementAmount) == true, "You don't have enough in balance. ");
require(token.transfer(mike, managementAmount) == true, "You don't have enough in balance. ");
require(token.transfer(ghost, managementAmount) == true, "You don't have enough in balance. ");
time += locktime;
}
//Used to check contract balance.
function getBalance() view public returns (uint) {
return token.balanceOf(address(this));
}
///Updates the owner of the contract
function updateOwner(address newOwner) public onlyOwner {
owner = newOwner;
}
//Used incase management teams lost their wallet and needs to updated.
function updateManagement(address _mike, address _ghost, address _safe, address _dev) public onlyOwner {
mike = _mike;
ghost = _ghost;
safe = _safe;
dev = _dev;
}
//Check who owner is.
function getOwner() view public returns (address) {
return owner;
}
} | ///Contract that vests 200K GRO then payout after every month for the next 24 months. | NatSpecSingleLine | payToken | function payToken() public onlyOwner {
//check if it's past the next payperiod.
require(block.timestamp >= (time + locktime), "Period not reached yet. ");
//Sends dev payment.
require(token.transfer(dev, devAmount) == true, "You don't have enough in balance. ");
//sends management payments.
require(token.transfer(safe, managementAmount) == true, "You don't have enough in balance. ");
require(token.transfer(mike, managementAmount) == true, "You don't have enough in balance. ");
require(token.transfer(ghost, managementAmount) == true, "You don't have enough in balance. ");
time += locktime;
}
| //Admin pays dev and management team. | LineComment | v0.7.1+commit.f4a555be | MIT | ipfs://7be7aab06df9eea6ee52941d5a089f2daa3fa716cbffcaa4f8025405372d76cf | {
"func_code_index": [
1595,
2329
]
} | 735 |
GrowthLockContract | GrowthLockContract.sol | 0x33729ec887c974cc6f692646c28137d22517b03f | Solidity | GrowthLockContract | contract GrowthLockContract {
address private owner;
address private safe;
address private mike;
address private ghost;
address private dev;
uint256 public time;
uint private constant devAmount = 4166.66 * 1 ether;
uint private constant managementAmount = 1388.88 * 1 ether;
//2629743 = 30 days.
uint public constant locktime = 2629743;
//0x09e64c2B61a5f1690Ee6fbeD9baf5D6990F8dFd0 is Growth Token address
ERC20Interface private constant token = ERC20Interface(0x09e64c2B61a5f1690Ee6fbeD9baf5D6990F8dFd0);
constructor () {
owner = msg.sender;
time = block.timestamp;
mike = 0x70F5FB6BE943162545a496eD120495B05dC5ce07;
ghost = 0x6811101D884557Eba52DF3Ea0417A3036D5b9FCd;
safe = 0xC4faC8CA576B9c8B971fA36916aEE062d84b4901;
dev = 0xB0632a01ee778E09625BcE2a257e221b49E79696;
}
//Modifier to prevent everyone except owner from using contract.
modifier onlyOwner(){
require(msg.sender == owner, "Unauthorized to call. ");
_;
}
//Admin can deposit the initial vested amount. You can only use this function once.
function depositToken(uint amount) public onlyOwner {
require(amount > 0, "Amount must be greater than zero");
require(token.transferFrom(msg.sender, address(this), amount) == true, "Inefficient balance or Unauthorized to pay. ");
}
//Admin pays dev and management team.
function payToken() public onlyOwner {
//check if it's past the next payperiod.
require(block.timestamp >= (time + locktime), "Period not reached yet. ");
//Sends dev payment.
require(token.transfer(dev, devAmount) == true, "You don't have enough in balance. ");
//sends management payments.
require(token.transfer(safe, managementAmount) == true, "You don't have enough in balance. ");
require(token.transfer(mike, managementAmount) == true, "You don't have enough in balance. ");
require(token.transfer(ghost, managementAmount) == true, "You don't have enough in balance. ");
time += locktime;
}
//Used to check contract balance.
function getBalance() view public returns (uint) {
return token.balanceOf(address(this));
}
///Updates the owner of the contract
function updateOwner(address newOwner) public onlyOwner {
owner = newOwner;
}
//Used incase management teams lost their wallet and needs to updated.
function updateManagement(address _mike, address _ghost, address _safe, address _dev) public onlyOwner {
mike = _mike;
ghost = _ghost;
safe = _safe;
dev = _dev;
}
//Check who owner is.
function getOwner() view public returns (address) {
return owner;
}
} | ///Contract that vests 200K GRO then payout after every month for the next 24 months. | NatSpecSingleLine | getBalance | function getBalance() view public returns (uint) {
return token.balanceOf(address(this));
}
| //Used to check contract balance. | LineComment | v0.7.1+commit.f4a555be | MIT | ipfs://7be7aab06df9eea6ee52941d5a089f2daa3fa716cbffcaa4f8025405372d76cf | {
"func_code_index": [
2382,
2492
]
} | 736 |
GrowthLockContract | GrowthLockContract.sol | 0x33729ec887c974cc6f692646c28137d22517b03f | Solidity | GrowthLockContract | contract GrowthLockContract {
address private owner;
address private safe;
address private mike;
address private ghost;
address private dev;
uint256 public time;
uint private constant devAmount = 4166.66 * 1 ether;
uint private constant managementAmount = 1388.88 * 1 ether;
//2629743 = 30 days.
uint public constant locktime = 2629743;
//0x09e64c2B61a5f1690Ee6fbeD9baf5D6990F8dFd0 is Growth Token address
ERC20Interface private constant token = ERC20Interface(0x09e64c2B61a5f1690Ee6fbeD9baf5D6990F8dFd0);
constructor () {
owner = msg.sender;
time = block.timestamp;
mike = 0x70F5FB6BE943162545a496eD120495B05dC5ce07;
ghost = 0x6811101D884557Eba52DF3Ea0417A3036D5b9FCd;
safe = 0xC4faC8CA576B9c8B971fA36916aEE062d84b4901;
dev = 0xB0632a01ee778E09625BcE2a257e221b49E79696;
}
//Modifier to prevent everyone except owner from using contract.
modifier onlyOwner(){
require(msg.sender == owner, "Unauthorized to call. ");
_;
}
//Admin can deposit the initial vested amount. You can only use this function once.
function depositToken(uint amount) public onlyOwner {
require(amount > 0, "Amount must be greater than zero");
require(token.transferFrom(msg.sender, address(this), amount) == true, "Inefficient balance or Unauthorized to pay. ");
}
//Admin pays dev and management team.
function payToken() public onlyOwner {
//check if it's past the next payperiod.
require(block.timestamp >= (time + locktime), "Period not reached yet. ");
//Sends dev payment.
require(token.transfer(dev, devAmount) == true, "You don't have enough in balance. ");
//sends management payments.
require(token.transfer(safe, managementAmount) == true, "You don't have enough in balance. ");
require(token.transfer(mike, managementAmount) == true, "You don't have enough in balance. ");
require(token.transfer(ghost, managementAmount) == true, "You don't have enough in balance. ");
time += locktime;
}
//Used to check contract balance.
function getBalance() view public returns (uint) {
return token.balanceOf(address(this));
}
///Updates the owner of the contract
function updateOwner(address newOwner) public onlyOwner {
owner = newOwner;
}
//Used incase management teams lost their wallet and needs to updated.
function updateManagement(address _mike, address _ghost, address _safe, address _dev) public onlyOwner {
mike = _mike;
ghost = _ghost;
safe = _safe;
dev = _dev;
}
//Check who owner is.
function getOwner() view public returns (address) {
return owner;
}
} | ///Contract that vests 200K GRO then payout after every month for the next 24 months. | NatSpecSingleLine | updateOwner | function updateOwner(address newOwner) public onlyOwner {
owner = newOwner;
}
| ///Updates the owner of the contract | NatSpecSingleLine | v0.7.1+commit.f4a555be | MIT | ipfs://7be7aab06df9eea6ee52941d5a089f2daa3fa716cbffcaa4f8025405372d76cf | {
"func_code_index": [
2541,
2640
]
} | 737 |
GrowthLockContract | GrowthLockContract.sol | 0x33729ec887c974cc6f692646c28137d22517b03f | Solidity | GrowthLockContract | contract GrowthLockContract {
address private owner;
address private safe;
address private mike;
address private ghost;
address private dev;
uint256 public time;
uint private constant devAmount = 4166.66 * 1 ether;
uint private constant managementAmount = 1388.88 * 1 ether;
//2629743 = 30 days.
uint public constant locktime = 2629743;
//0x09e64c2B61a5f1690Ee6fbeD9baf5D6990F8dFd0 is Growth Token address
ERC20Interface private constant token = ERC20Interface(0x09e64c2B61a5f1690Ee6fbeD9baf5D6990F8dFd0);
constructor () {
owner = msg.sender;
time = block.timestamp;
mike = 0x70F5FB6BE943162545a496eD120495B05dC5ce07;
ghost = 0x6811101D884557Eba52DF3Ea0417A3036D5b9FCd;
safe = 0xC4faC8CA576B9c8B971fA36916aEE062d84b4901;
dev = 0xB0632a01ee778E09625BcE2a257e221b49E79696;
}
//Modifier to prevent everyone except owner from using contract.
modifier onlyOwner(){
require(msg.sender == owner, "Unauthorized to call. ");
_;
}
//Admin can deposit the initial vested amount. You can only use this function once.
function depositToken(uint amount) public onlyOwner {
require(amount > 0, "Amount must be greater than zero");
require(token.transferFrom(msg.sender, address(this), amount) == true, "Inefficient balance or Unauthorized to pay. ");
}
//Admin pays dev and management team.
function payToken() public onlyOwner {
//check if it's past the next payperiod.
require(block.timestamp >= (time + locktime), "Period not reached yet. ");
//Sends dev payment.
require(token.transfer(dev, devAmount) == true, "You don't have enough in balance. ");
//sends management payments.
require(token.transfer(safe, managementAmount) == true, "You don't have enough in balance. ");
require(token.transfer(mike, managementAmount) == true, "You don't have enough in balance. ");
require(token.transfer(ghost, managementAmount) == true, "You don't have enough in balance. ");
time += locktime;
}
//Used to check contract balance.
function getBalance() view public returns (uint) {
return token.balanceOf(address(this));
}
///Updates the owner of the contract
function updateOwner(address newOwner) public onlyOwner {
owner = newOwner;
}
//Used incase management teams lost their wallet and needs to updated.
function updateManagement(address _mike, address _ghost, address _safe, address _dev) public onlyOwner {
mike = _mike;
ghost = _ghost;
safe = _safe;
dev = _dev;
}
//Check who owner is.
function getOwner() view public returns (address) {
return owner;
}
} | ///Contract that vests 200K GRO then payout after every month for the next 24 months. | NatSpecSingleLine | updateManagement | function updateManagement(address _mike, address _ghost, address _safe, address _dev) public onlyOwner {
mike = _mike;
ghost = _ghost;
safe = _safe;
dev = _dev;
}
| //Used incase management teams lost their wallet and needs to updated. | LineComment | v0.7.1+commit.f4a555be | MIT | ipfs://7be7aab06df9eea6ee52941d5a089f2daa3fa716cbffcaa4f8025405372d76cf | {
"func_code_index": [
2725,
2935
]
} | 738 |
GrowthLockContract | GrowthLockContract.sol | 0x33729ec887c974cc6f692646c28137d22517b03f | Solidity | GrowthLockContract | contract GrowthLockContract {
address private owner;
address private safe;
address private mike;
address private ghost;
address private dev;
uint256 public time;
uint private constant devAmount = 4166.66 * 1 ether;
uint private constant managementAmount = 1388.88 * 1 ether;
//2629743 = 30 days.
uint public constant locktime = 2629743;
//0x09e64c2B61a5f1690Ee6fbeD9baf5D6990F8dFd0 is Growth Token address
ERC20Interface private constant token = ERC20Interface(0x09e64c2B61a5f1690Ee6fbeD9baf5D6990F8dFd0);
constructor () {
owner = msg.sender;
time = block.timestamp;
mike = 0x70F5FB6BE943162545a496eD120495B05dC5ce07;
ghost = 0x6811101D884557Eba52DF3Ea0417A3036D5b9FCd;
safe = 0xC4faC8CA576B9c8B971fA36916aEE062d84b4901;
dev = 0xB0632a01ee778E09625BcE2a257e221b49E79696;
}
//Modifier to prevent everyone except owner from using contract.
modifier onlyOwner(){
require(msg.sender == owner, "Unauthorized to call. ");
_;
}
//Admin can deposit the initial vested amount. You can only use this function once.
function depositToken(uint amount) public onlyOwner {
require(amount > 0, "Amount must be greater than zero");
require(token.transferFrom(msg.sender, address(this), amount) == true, "Inefficient balance or Unauthorized to pay. ");
}
//Admin pays dev and management team.
function payToken() public onlyOwner {
//check if it's past the next payperiod.
require(block.timestamp >= (time + locktime), "Period not reached yet. ");
//Sends dev payment.
require(token.transfer(dev, devAmount) == true, "You don't have enough in balance. ");
//sends management payments.
require(token.transfer(safe, managementAmount) == true, "You don't have enough in balance. ");
require(token.transfer(mike, managementAmount) == true, "You don't have enough in balance. ");
require(token.transfer(ghost, managementAmount) == true, "You don't have enough in balance. ");
time += locktime;
}
//Used to check contract balance.
function getBalance() view public returns (uint) {
return token.balanceOf(address(this));
}
///Updates the owner of the contract
function updateOwner(address newOwner) public onlyOwner {
owner = newOwner;
}
//Used incase management teams lost their wallet and needs to updated.
function updateManagement(address _mike, address _ghost, address _safe, address _dev) public onlyOwner {
mike = _mike;
ghost = _ghost;
safe = _safe;
dev = _dev;
}
//Check who owner is.
function getOwner() view public returns (address) {
return owner;
}
} | ///Contract that vests 200K GRO then payout after every month for the next 24 months. | NatSpecSingleLine | getOwner | function getOwner() view public returns (address) {
return owner;
}
| //Check who owner is. | LineComment | v0.7.1+commit.f4a555be | MIT | ipfs://7be7aab06df9eea6ee52941d5a089f2daa3fa716cbffcaa4f8025405372d76cf | {
"func_code_index": [
2970,
3057
]
} | 739 |
EmblemVault | browser/github/0xcert/ethereum-erc721/src/contracts/utils/supports-interface.sol | 0x82c7a8f707110f5fbb16184a5933e9f78a34c6ab | Solidity | SupportsInterface | contract SupportsInterface is
ERC165
{
/**
* @dev Mapping of supported intefraces.
* @notice You must not set element 0xffffffff to true.
*/
mapping(bytes4 => bool) internal supportedInterfaces;
/**
* @dev Contract constructor.
*/
constructor()
public
{
supportedInterfaces[0x01ffc9a7] = true; // ERC165
}
/**
* @dev Function to check which interfaces are suported by this contract.
* @param _interfaceID Id of the interface.
* @return True if _interfaceID is supported, false otherwise.
*/
function supportsInterface(
bytes4 _interfaceID
)
external
override
view
returns (bool)
{
return supportedInterfaces[_interfaceID];
}
} | /**
* @dev Implementation of standard for detect smart contract interfaces.
*/ | NatSpecMultiLine | supportsInterface | function supportsInterface(
bytes4 _interfaceID
)
external
override
view
returns (bool)
{
return supportedInterfaces[_interfaceID];
}
| /**
* @dev Function to check which interfaces are suported by this contract.
* @param _interfaceID Id of the interface.
* @return True if _interfaceID is supported, false otherwise.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://6626fd920334c84d658057cbe16dd3b47b41fc7475707238fefa241a53c0a511 | {
"func_code_index": [
569,
744
]
} | 740 |
EmblemVault | browser/github/0xcert/ethereum-erc721/src/contracts/tokens/erc721-token-receiver.sol | 0x82c7a8f707110f5fbb16184a5933e9f78a34c6ab | Solidity | ERC721TokenReceiver | interface ERC721TokenReceiver
{
/**
* @dev Handle the receipt of a NFT. The ERC721 smart contract calls this function on the
* recipient after a `transfer`. This function MAY throw to revert and reject the transfer. Return
* of other than the magic value MUST result in the transaction being reverted.
* Returns `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` unless throwing.
* @notice The contract address is always the message sender. A wallet/broker/auction application
* MUST implement the wallet interface if it will accept safe transfers.
* @param _operator The address which called `safeTransferFrom` function.
* @param _from The address which previously owned the token.
* @param _tokenId The NFT identifier which is being transferred.
* @param _data Additional data with no specified format.
* @return Returns `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`.
*/
function onERC721Received(
address _operator,
address _from,
uint256 _tokenId,
bytes calldata _data
)
external
returns(bytes4);
} | /**
* @dev ERC-721 interface for accepting safe transfers.
* See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md.
*/ | NatSpecMultiLine | onERC721Received | function onERC721Received(
address _operator,
address _from,
uint256 _tokenId,
bytes calldata _data
)
external
returns(bytes4);
| /**
* @dev Handle the receipt of a NFT. The ERC721 smart contract calls this function on the
* recipient after a `transfer`. This function MAY throw to revert and reject the transfer. Return
* of other than the magic value MUST result in the transaction being reverted.
* Returns `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))` unless throwing.
* @notice The contract address is always the message sender. A wallet/broker/auction application
* MUST implement the wallet interface if it will accept safe transfers.
* @param _operator The address which called `safeTransferFrom` function.
* @param _from The address which previously owned the token.
* @param _tokenId The NFT identifier which is being transferred.
* @param _data Additional data with no specified format.
* @return Returns `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://6626fd920334c84d658057cbe16dd3b47b41fc7475707238fefa241a53c0a511 | {
"func_code_index": [
973,
1136
]
} | 741 |
BoxTrade | BoxTrade.sol | 0xa64ea8089a4b0253edcae9c71ffcdb576988044a | 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.23+commit.124ca40d | bzzr://6ee808c1f3f66dd83e1917ab6984026984a6adfa57bca627495e144d8fac79c2 | {
"func_code_index": [
60,
124
]
} | 742 |
|||
BoxTrade | BoxTrade.sol | 0xa64ea8089a4b0253edcae9c71ffcdb576988044a | 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.23+commit.124ca40d | bzzr://6ee808c1f3f66dd83e1917ab6984026984a6adfa57bca627495e144d8fac79c2 | {
"func_code_index": [
232,
309
]
} | 743 |
|||
BoxTrade | BoxTrade.sol | 0xa64ea8089a4b0253edcae9c71ffcdb576988044a | 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.23+commit.124ca40d | bzzr://6ee808c1f3f66dd83e1917ab6984026984a6adfa57bca627495e144d8fac79c2 | {
"func_code_index": [
546,
623
]
} | 744 |
|||
BoxTrade | BoxTrade.sol | 0xa64ea8089a4b0253edcae9c71ffcdb576988044a | 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.23+commit.124ca40d | bzzr://6ee808c1f3f66dd83e1917ab6984026984a6adfa57bca627495e144d8fac79c2 | {
"func_code_index": [
946,
1042
]
} | 745 |
|||
BoxTrade | BoxTrade.sol | 0xa64ea8089a4b0253edcae9c71ffcdb576988044a | 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);
} | approve | function approve(address _spender, 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 | NatSpecSingleLine | v0.4.23+commit.124ca40d | bzzr://6ee808c1f3f66dd83e1917ab6984026984a6adfa57bca627495e144d8fac79c2 | {
"func_code_index": [
1326,
1407
]
} | 746 |
|||
BoxTrade | BoxTrade.sol | 0xa64ea8089a4b0253edcae9c71ffcdb576988044a | 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);
} | allowance | function allowance(address _owner, address _spender) constant returns (uint256 remaining) {}
| /// @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 | NatSpecSingleLine | v0.4.23+commit.124ca40d | bzzr://6ee808c1f3f66dd83e1917ab6984026984a6adfa57bca627495e144d8fac79c2 | {
"func_code_index": [
1615,
1712
]
} | 747 |
|||
BoxTrade | BoxTrade.sol | 0xa64ea8089a4b0253edcae9c71ffcdb576988044a | Solidity | BoxTrade | contract BoxTrade is StandardToken {
function () {
//if ether is sent to this address, send it back.
throw;
}
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'H1.0'; //human 0.1 standard. Just an arbitrary versioning scheme.
function BoxTrade(
) {
balances[msg.sender] = 100000000000000000;
totalSupply = 100000000000000000;
name = "BoxTrade"; // Set the name for display purposes
decimals = 5; // Amount of decimals for display purposes
symbol = "BOXY"; // Set the symbol for display purposes
}
/* Approves and then calls the receiving contract */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
} | //name this contract whatever you'd like | LineComment | BoxTrade | function BoxTrade(
) {
balances[msg.sender] = 100000000000000000;
totalSupply = 100000000000000000;
name = "BoxTrade"; // Set the name for display purposes
decimals = 5; // Amount of decimals for display purposes
symbol = "BOXY"; // Set the symbol for display purposes
}
| //human 0.1 standard. Just an arbitrary versioning scheme. | LineComment | v0.4.23+commit.124ca40d | bzzr://6ee808c1f3f66dd83e1917ab6984026984a6adfa57bca627495e144d8fac79c2 | {
"func_code_index": [
919,
1344
]
} | 748 |
|
BoxTrade | BoxTrade.sol | 0xa64ea8089a4b0253edcae9c71ffcdb576988044a | Solidity | BoxTrade | contract BoxTrade is StandardToken {
function () {
//if ether is sent to this address, send it back.
throw;
}
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'H1.0'; //human 0.1 standard. Just an arbitrary versioning scheme.
function BoxTrade(
) {
balances[msg.sender] = 100000000000000000;
totalSupply = 100000000000000000;
name = "BoxTrade"; // Set the name for display purposes
decimals = 5; // Amount of decimals for display purposes
symbol = "BOXY"; // Set the symbol for display purposes
}
/* Approves and then calls the receiving contract */
function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
} | //name this contract whatever you'd like | LineComment | approveAndCall | function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
//call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this.
//receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData)
//it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead.
if(!_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)) { throw; }
return true;
}
| /* Approves and then calls the receiving contract */ | Comment | v0.4.23+commit.124ca40d | bzzr://6ee808c1f3f66dd83e1917ab6984026984a6adfa57bca627495e144d8fac79c2 | {
"func_code_index": [
1405,
2210
]
} | 749 |
|
UinswapTaxedRouter | contracts/uniswap_routerV2.sol | 0xaf688dc793e75ba61694ce3e6167ab6072fbf7bd | Solidity | UniswapV2Router02 | contract UniswapV2Router02 is IUniswapV2Router02 {
using SafeMath for uint;
address public immutable override factory;
address public immutable override WETH;
modifier ensure(uint deadline) {
require(deadline >= block.timestamp, 'UniswapV2Router: EXPIRED');
_;
}
constructor(address _factory, address _WETH) public {
factory = _factory;
WETH = _WETH;
}
receive() external payable {
assert(msg.sender == WETH); // only accept ETH via fallback from the WETH contract
}
// **** ADD LIQUIDITY ****
function _addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin
) internal virtual returns (uint amountA, uint amountB) {
// create the pair if it doesn't exist yet
if (IUniswapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) {
IUniswapV2Factory(factory).createPair(tokenA, tokenB);
}
(uint reserveA, uint reserveB) = UniswapV2Library.getReserves(factory, tokenA, tokenB);
if (reserveA == 0 && reserveB == 0) {
(amountA, amountB) = (amountADesired, amountBDesired);
} else {
uint amountBOptimal = UniswapV2Library.quote(amountADesired, reserveA, reserveB);
if (amountBOptimal <= amountBDesired) {
require(amountBOptimal >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT');
(amountA, amountB) = (amountADesired, amountBOptimal);
} else {
uint amountAOptimal = UniswapV2Library.quote(amountBDesired, reserveB, reserveA);
assert(amountAOptimal <= amountADesired);
require(amountAOptimal >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT');
(amountA, amountB) = (amountAOptimal, amountBDesired);
}
}
}
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint amountA, uint amountB, uint liquidity) {
(amountA, amountB) = _addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin);
address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
TransferHelper.safeTransferFrom(tokenA, msg.sender, pair, amountA);
TransferHelper.safeTransferFrom(tokenB, msg.sender, pair, amountB);
liquidity = IUniswapV2Pair(pair).mint(to);
}
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external virtual override payable ensure(deadline) returns (uint amountToken, uint amountETH, uint liquidity) {
(amountToken, amountETH) = _addLiquidity(
token,
WETH,
amountTokenDesired,
msg.value,
amountTokenMin,
amountETHMin
);
address pair = UniswapV2Library.pairFor(factory, token, WETH);
TransferHelper.safeTransferFrom(token, msg.sender, pair, amountToken);
IWETH(WETH).deposit{value: amountETH}();
assert(IWETH(WETH).transfer(pair, amountETH));
liquidity = IUniswapV2Pair(pair).mint(to);
// refund dust eth, if any
if (msg.value > amountETH) TransferHelper.safeTransferETH(msg.sender, msg.value - amountETH);
}
// **** REMOVE LIQUIDITY ****
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountA, uint amountB) {
address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
IUniswapV2Pair(pair).transferFrom(msg.sender, pair, liquidity); // send liquidity to pair
(uint amount0, uint amount1) = IUniswapV2Pair(pair).burn(to);
(address token0,) = UniswapV2Library.sortTokens(tokenA, tokenB);
(amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0);
require(amountA >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT');
require(amountB >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT');
}
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountToken, uint amountETH) {
(amountToken, amountETH) = removeLiquidity(
token,
WETH,
liquidity,
amountTokenMin,
amountETHMin,
address(this),
deadline
);
TransferHelper.safeTransfer(token, to, amountToken);
IWETH(WETH).withdraw(amountETH);
TransferHelper.safeTransferETH(to, amountETH);
}
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountA, uint amountB) {
address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
uint value = approveMax ? uint(-1) : liquidity;
IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
(amountA, amountB) = removeLiquidity(tokenA, tokenB, liquidity, amountAMin, amountBMin, to, deadline);
}
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountToken, uint amountETH) {
address pair = UniswapV2Library.pairFor(factory, token, WETH);
uint value = approveMax ? uint(-1) : liquidity;
IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
(amountToken, amountETH) = removeLiquidityETH(token, liquidity, amountTokenMin, amountETHMin, to, deadline);
}
// **** REMOVE LIQUIDITY (supporting fee-on-transfer tokens) ****
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountETH) {
(, amountETH) = removeLiquidity(
token,
WETH,
liquidity,
amountTokenMin,
amountETHMin,
address(this),
deadline
);
TransferHelper.safeTransfer(token, to, IERC20(token).balanceOf(address(this)));
IWETH(WETH).withdraw(amountETH);
TransferHelper.safeTransferETH(to, amountETH);
}
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountETH) {
address pair = UniswapV2Library.pairFor(factory, token, WETH);
uint value = approveMax ? uint(-1) : liquidity;
IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
amountETH = removeLiquidityETHSupportingFeeOnTransferTokens(
token, liquidity, amountTokenMin, amountETHMin, to, deadline
);
}
// **** SWAP ****
// requires the initial amount to have already been sent to the first pair
function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual {
for (uint i; i < path.length - 1; i++) {
(address input, address output) = (path[i], path[i + 1]);
(address token0,) = UniswapV2Library.sortTokens(input, output);
uint amountOut = amounts[i + 1];
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0));
address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to;
IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output)).swap(
amount0Out, amount1Out, to, new bytes(0)
);
}
}
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint[] memory amounts) {
amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, to);
}
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint[] memory amounts) {
amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, to);
}
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
virtual
override
payable
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsOut(factory, msg.value, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
IWETH(WETH).deposit{value: amounts[0]}();
assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
_swap(amounts, path, to);
}
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
virtual
override
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, address(this));
IWETH(WETH).withdraw(amounts[amounts.length - 1]);
TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
}
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
virtual
override
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, address(this));
IWETH(WETH).withdraw(amounts[amounts.length - 1]);
TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
}
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
virtual
override
payable
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= msg.value, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
IWETH(WETH).deposit{value: amounts[0]}();
assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
_swap(amounts, path, to);
// refund dust eth, if any
if (msg.value > amounts[0]) TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0]);
}
// **** SWAP (supporting fee-on-transfer tokens) ****
// requires the initial amount to have already been sent to the first pair
function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual {
for (uint i; i < path.length - 1; i++) {
(address input, address output) = (path[i], path[i + 1]);
(address token0,) = UniswapV2Library.sortTokens(input, output);
IUniswapV2Pair pair = IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output));
uint amountInput;
uint amountOutput;
{ // scope to avoid stack too deep errors
(uint reserve0, uint reserve1,) = pair.getReserves();
(uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
amountInput = IERC20(input).balanceOf(address(pair)).sub(reserveInput);
amountOutput = UniswapV2Library.getAmountOut(amountInput, reserveInput, reserveOutput);
}
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0));
address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to;
pair.swap(amount0Out, amount1Out, to, new bytes(0));
}
}
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) {
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn
);
uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to);
_swapSupportingFeeOnTransferTokens(path, to);
require(
IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin,
'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'
);
}
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
)
external
virtual
override
payable
ensure(deadline)
{
require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
uint amountIn = msg.value;
IWETH(WETH).deposit{value: amountIn}();
assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn));
uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to);
_swapSupportingFeeOnTransferTokens(path, to);
require(
IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin,
'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'
);
}
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
)
external
virtual
override
ensure(deadline)
{
require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn
);
_swapSupportingFeeOnTransferTokens(path, address(this));
uint amountOut = IERC20(WETH).balanceOf(address(this));
require(amountOut >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
IWETH(WETH).withdraw(amountOut);
TransferHelper.safeTransferETH(to, amountOut);
}
// **** LIBRARY FUNCTIONS ****
function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) {
return UniswapV2Library.quote(amountA, reserveA, reserveB);
}
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut)
public
pure
virtual
override
returns (uint amountOut)
{
return UniswapV2Library.getAmountOut(amountIn, reserveIn, reserveOut);
}
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut)
public
pure
virtual
override
returns (uint amountIn)
{
return UniswapV2Library.getAmountIn(amountOut, reserveIn, reserveOut);
}
function getAmountsOut(uint amountIn, address[] memory path)
public
view
virtual
override
returns (uint[] memory amounts)
{
return UniswapV2Library.getAmountsOut(factory, amountIn, path);
}
function getAmountsIn(uint amountOut, address[] memory path)
public
view
virtual
override
returns (uint[] memory amounts)
{
return UniswapV2Library.getAmountsIn(factory, amountOut, path);
}
} | _addLiquidity | function _addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin
) internal virtual returns (uint amountA, uint amountB) {
// create the pair if it doesn't exist yet
if (IUniswapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) {
IUniswapV2Factory(factory).createPair(tokenA, tokenB);
}
(uint reserveA, uint reserveB) = UniswapV2Library.getReserves(factory, tokenA, tokenB);
if (reserveA == 0 && reserveB == 0) {
(amountA, amountB) = (amountADesired, amountBDesired);
} else {
uint amountBOptimal = UniswapV2Library.quote(amountADesired, reserveA, reserveB);
if (amountBOptimal <= amountBDesired) {
require(amountBOptimal >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT');
(amountA, amountB) = (amountADesired, amountBOptimal);
} else {
uint amountAOptimal = UniswapV2Library.quote(amountBDesired, reserveB, reserveA);
assert(amountAOptimal <= amountADesired);
require(amountAOptimal >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT');
(amountA, amountB) = (amountAOptimal, amountBDesired);
}
}
}
| // **** ADD LIQUIDITY **** | LineComment | v0.6.6+commit.6c089d02 | None | ipfs://b585757671d7273483129a977dcee7ec3d83292d8f01e8594c04b1ae6045d497 | {
"func_code_index": [
600,
1995
]
} | 750 |
||
UinswapTaxedRouter | contracts/uniswap_routerV2.sol | 0xaf688dc793e75ba61694ce3e6167ab6072fbf7bd | Solidity | UniswapV2Router02 | contract UniswapV2Router02 is IUniswapV2Router02 {
using SafeMath for uint;
address public immutable override factory;
address public immutable override WETH;
modifier ensure(uint deadline) {
require(deadline >= block.timestamp, 'UniswapV2Router: EXPIRED');
_;
}
constructor(address _factory, address _WETH) public {
factory = _factory;
WETH = _WETH;
}
receive() external payable {
assert(msg.sender == WETH); // only accept ETH via fallback from the WETH contract
}
// **** ADD LIQUIDITY ****
function _addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin
) internal virtual returns (uint amountA, uint amountB) {
// create the pair if it doesn't exist yet
if (IUniswapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) {
IUniswapV2Factory(factory).createPair(tokenA, tokenB);
}
(uint reserveA, uint reserveB) = UniswapV2Library.getReserves(factory, tokenA, tokenB);
if (reserveA == 0 && reserveB == 0) {
(amountA, amountB) = (amountADesired, amountBDesired);
} else {
uint amountBOptimal = UniswapV2Library.quote(amountADesired, reserveA, reserveB);
if (amountBOptimal <= amountBDesired) {
require(amountBOptimal >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT');
(amountA, amountB) = (amountADesired, amountBOptimal);
} else {
uint amountAOptimal = UniswapV2Library.quote(amountBDesired, reserveB, reserveA);
assert(amountAOptimal <= amountADesired);
require(amountAOptimal >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT');
(amountA, amountB) = (amountAOptimal, amountBDesired);
}
}
}
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint amountA, uint amountB, uint liquidity) {
(amountA, amountB) = _addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin);
address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
TransferHelper.safeTransferFrom(tokenA, msg.sender, pair, amountA);
TransferHelper.safeTransferFrom(tokenB, msg.sender, pair, amountB);
liquidity = IUniswapV2Pair(pair).mint(to);
}
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external virtual override payable ensure(deadline) returns (uint amountToken, uint amountETH, uint liquidity) {
(amountToken, amountETH) = _addLiquidity(
token,
WETH,
amountTokenDesired,
msg.value,
amountTokenMin,
amountETHMin
);
address pair = UniswapV2Library.pairFor(factory, token, WETH);
TransferHelper.safeTransferFrom(token, msg.sender, pair, amountToken);
IWETH(WETH).deposit{value: amountETH}();
assert(IWETH(WETH).transfer(pair, amountETH));
liquidity = IUniswapV2Pair(pair).mint(to);
// refund dust eth, if any
if (msg.value > amountETH) TransferHelper.safeTransferETH(msg.sender, msg.value - amountETH);
}
// **** REMOVE LIQUIDITY ****
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountA, uint amountB) {
address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
IUniswapV2Pair(pair).transferFrom(msg.sender, pair, liquidity); // send liquidity to pair
(uint amount0, uint amount1) = IUniswapV2Pair(pair).burn(to);
(address token0,) = UniswapV2Library.sortTokens(tokenA, tokenB);
(amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0);
require(amountA >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT');
require(amountB >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT');
}
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountToken, uint amountETH) {
(amountToken, amountETH) = removeLiquidity(
token,
WETH,
liquidity,
amountTokenMin,
amountETHMin,
address(this),
deadline
);
TransferHelper.safeTransfer(token, to, amountToken);
IWETH(WETH).withdraw(amountETH);
TransferHelper.safeTransferETH(to, amountETH);
}
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountA, uint amountB) {
address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
uint value = approveMax ? uint(-1) : liquidity;
IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
(amountA, amountB) = removeLiquidity(tokenA, tokenB, liquidity, amountAMin, amountBMin, to, deadline);
}
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountToken, uint amountETH) {
address pair = UniswapV2Library.pairFor(factory, token, WETH);
uint value = approveMax ? uint(-1) : liquidity;
IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
(amountToken, amountETH) = removeLiquidityETH(token, liquidity, amountTokenMin, amountETHMin, to, deadline);
}
// **** REMOVE LIQUIDITY (supporting fee-on-transfer tokens) ****
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountETH) {
(, amountETH) = removeLiquidity(
token,
WETH,
liquidity,
amountTokenMin,
amountETHMin,
address(this),
deadline
);
TransferHelper.safeTransfer(token, to, IERC20(token).balanceOf(address(this)));
IWETH(WETH).withdraw(amountETH);
TransferHelper.safeTransferETH(to, amountETH);
}
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountETH) {
address pair = UniswapV2Library.pairFor(factory, token, WETH);
uint value = approveMax ? uint(-1) : liquidity;
IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
amountETH = removeLiquidityETHSupportingFeeOnTransferTokens(
token, liquidity, amountTokenMin, amountETHMin, to, deadline
);
}
// **** SWAP ****
// requires the initial amount to have already been sent to the first pair
function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual {
for (uint i; i < path.length - 1; i++) {
(address input, address output) = (path[i], path[i + 1]);
(address token0,) = UniswapV2Library.sortTokens(input, output);
uint amountOut = amounts[i + 1];
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0));
address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to;
IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output)).swap(
amount0Out, amount1Out, to, new bytes(0)
);
}
}
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint[] memory amounts) {
amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, to);
}
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint[] memory amounts) {
amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, to);
}
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
virtual
override
payable
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsOut(factory, msg.value, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
IWETH(WETH).deposit{value: amounts[0]}();
assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
_swap(amounts, path, to);
}
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
virtual
override
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, address(this));
IWETH(WETH).withdraw(amounts[amounts.length - 1]);
TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
}
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
virtual
override
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, address(this));
IWETH(WETH).withdraw(amounts[amounts.length - 1]);
TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
}
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
virtual
override
payable
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= msg.value, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
IWETH(WETH).deposit{value: amounts[0]}();
assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
_swap(amounts, path, to);
// refund dust eth, if any
if (msg.value > amounts[0]) TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0]);
}
// **** SWAP (supporting fee-on-transfer tokens) ****
// requires the initial amount to have already been sent to the first pair
function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual {
for (uint i; i < path.length - 1; i++) {
(address input, address output) = (path[i], path[i + 1]);
(address token0,) = UniswapV2Library.sortTokens(input, output);
IUniswapV2Pair pair = IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output));
uint amountInput;
uint amountOutput;
{ // scope to avoid stack too deep errors
(uint reserve0, uint reserve1,) = pair.getReserves();
(uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
amountInput = IERC20(input).balanceOf(address(pair)).sub(reserveInput);
amountOutput = UniswapV2Library.getAmountOut(amountInput, reserveInput, reserveOutput);
}
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0));
address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to;
pair.swap(amount0Out, amount1Out, to, new bytes(0));
}
}
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) {
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn
);
uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to);
_swapSupportingFeeOnTransferTokens(path, to);
require(
IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin,
'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'
);
}
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
)
external
virtual
override
payable
ensure(deadline)
{
require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
uint amountIn = msg.value;
IWETH(WETH).deposit{value: amountIn}();
assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn));
uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to);
_swapSupportingFeeOnTransferTokens(path, to);
require(
IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin,
'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'
);
}
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
)
external
virtual
override
ensure(deadline)
{
require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn
);
_swapSupportingFeeOnTransferTokens(path, address(this));
uint amountOut = IERC20(WETH).balanceOf(address(this));
require(amountOut >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
IWETH(WETH).withdraw(amountOut);
TransferHelper.safeTransferETH(to, amountOut);
}
// **** LIBRARY FUNCTIONS ****
function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) {
return UniswapV2Library.quote(amountA, reserveA, reserveB);
}
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut)
public
pure
virtual
override
returns (uint amountOut)
{
return UniswapV2Library.getAmountOut(amountIn, reserveIn, reserveOut);
}
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut)
public
pure
virtual
override
returns (uint amountIn)
{
return UniswapV2Library.getAmountIn(amountOut, reserveIn, reserveOut);
}
function getAmountsOut(uint amountIn, address[] memory path)
public
view
virtual
override
returns (uint[] memory amounts)
{
return UniswapV2Library.getAmountsOut(factory, amountIn, path);
}
function getAmountsIn(uint amountOut, address[] memory path)
public
view
virtual
override
returns (uint[] memory amounts)
{
return UniswapV2Library.getAmountsIn(factory, amountOut, path);
}
} | removeLiquidity | function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountA, uint amountB) {
address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
IUniswapV2Pair(pair).transferFrom(msg.sender, pair, liquidity); // send liquidity to pair
(uint amount0, uint amount1) = IUniswapV2Pair(pair).burn(to);
(address token0,) = UniswapV2Library.sortTokens(tokenA, tokenB);
(amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0);
require(amountA >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT');
require(amountB >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT');
}
| // **** REMOVE LIQUIDITY **** | LineComment | v0.6.6+commit.6c089d02 | None | ipfs://b585757671d7273483129a977dcee7ec3d83292d8f01e8594c04b1ae6045d497 | {
"func_code_index": [
3757,
4627
]
} | 751 |
||
UinswapTaxedRouter | contracts/uniswap_routerV2.sol | 0xaf688dc793e75ba61694ce3e6167ab6072fbf7bd | Solidity | UniswapV2Router02 | contract UniswapV2Router02 is IUniswapV2Router02 {
using SafeMath for uint;
address public immutable override factory;
address public immutable override WETH;
modifier ensure(uint deadline) {
require(deadline >= block.timestamp, 'UniswapV2Router: EXPIRED');
_;
}
constructor(address _factory, address _WETH) public {
factory = _factory;
WETH = _WETH;
}
receive() external payable {
assert(msg.sender == WETH); // only accept ETH via fallback from the WETH contract
}
// **** ADD LIQUIDITY ****
function _addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin
) internal virtual returns (uint amountA, uint amountB) {
// create the pair if it doesn't exist yet
if (IUniswapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) {
IUniswapV2Factory(factory).createPair(tokenA, tokenB);
}
(uint reserveA, uint reserveB) = UniswapV2Library.getReserves(factory, tokenA, tokenB);
if (reserveA == 0 && reserveB == 0) {
(amountA, amountB) = (amountADesired, amountBDesired);
} else {
uint amountBOptimal = UniswapV2Library.quote(amountADesired, reserveA, reserveB);
if (amountBOptimal <= amountBDesired) {
require(amountBOptimal >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT');
(amountA, amountB) = (amountADesired, amountBOptimal);
} else {
uint amountAOptimal = UniswapV2Library.quote(amountBDesired, reserveB, reserveA);
assert(amountAOptimal <= amountADesired);
require(amountAOptimal >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT');
(amountA, amountB) = (amountAOptimal, amountBDesired);
}
}
}
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint amountA, uint amountB, uint liquidity) {
(amountA, amountB) = _addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin);
address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
TransferHelper.safeTransferFrom(tokenA, msg.sender, pair, amountA);
TransferHelper.safeTransferFrom(tokenB, msg.sender, pair, amountB);
liquidity = IUniswapV2Pair(pair).mint(to);
}
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external virtual override payable ensure(deadline) returns (uint amountToken, uint amountETH, uint liquidity) {
(amountToken, amountETH) = _addLiquidity(
token,
WETH,
amountTokenDesired,
msg.value,
amountTokenMin,
amountETHMin
);
address pair = UniswapV2Library.pairFor(factory, token, WETH);
TransferHelper.safeTransferFrom(token, msg.sender, pair, amountToken);
IWETH(WETH).deposit{value: amountETH}();
assert(IWETH(WETH).transfer(pair, amountETH));
liquidity = IUniswapV2Pair(pair).mint(to);
// refund dust eth, if any
if (msg.value > amountETH) TransferHelper.safeTransferETH(msg.sender, msg.value - amountETH);
}
// **** REMOVE LIQUIDITY ****
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountA, uint amountB) {
address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
IUniswapV2Pair(pair).transferFrom(msg.sender, pair, liquidity); // send liquidity to pair
(uint amount0, uint amount1) = IUniswapV2Pair(pair).burn(to);
(address token0,) = UniswapV2Library.sortTokens(tokenA, tokenB);
(amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0);
require(amountA >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT');
require(amountB >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT');
}
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountToken, uint amountETH) {
(amountToken, amountETH) = removeLiquidity(
token,
WETH,
liquidity,
amountTokenMin,
amountETHMin,
address(this),
deadline
);
TransferHelper.safeTransfer(token, to, amountToken);
IWETH(WETH).withdraw(amountETH);
TransferHelper.safeTransferETH(to, amountETH);
}
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountA, uint amountB) {
address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
uint value = approveMax ? uint(-1) : liquidity;
IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
(amountA, amountB) = removeLiquidity(tokenA, tokenB, liquidity, amountAMin, amountBMin, to, deadline);
}
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountToken, uint amountETH) {
address pair = UniswapV2Library.pairFor(factory, token, WETH);
uint value = approveMax ? uint(-1) : liquidity;
IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
(amountToken, amountETH) = removeLiquidityETH(token, liquidity, amountTokenMin, amountETHMin, to, deadline);
}
// **** REMOVE LIQUIDITY (supporting fee-on-transfer tokens) ****
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountETH) {
(, amountETH) = removeLiquidity(
token,
WETH,
liquidity,
amountTokenMin,
amountETHMin,
address(this),
deadline
);
TransferHelper.safeTransfer(token, to, IERC20(token).balanceOf(address(this)));
IWETH(WETH).withdraw(amountETH);
TransferHelper.safeTransferETH(to, amountETH);
}
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountETH) {
address pair = UniswapV2Library.pairFor(factory, token, WETH);
uint value = approveMax ? uint(-1) : liquidity;
IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
amountETH = removeLiquidityETHSupportingFeeOnTransferTokens(
token, liquidity, amountTokenMin, amountETHMin, to, deadline
);
}
// **** SWAP ****
// requires the initial amount to have already been sent to the first pair
function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual {
for (uint i; i < path.length - 1; i++) {
(address input, address output) = (path[i], path[i + 1]);
(address token0,) = UniswapV2Library.sortTokens(input, output);
uint amountOut = amounts[i + 1];
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0));
address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to;
IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output)).swap(
amount0Out, amount1Out, to, new bytes(0)
);
}
}
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint[] memory amounts) {
amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, to);
}
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint[] memory amounts) {
amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, to);
}
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
virtual
override
payable
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsOut(factory, msg.value, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
IWETH(WETH).deposit{value: amounts[0]}();
assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
_swap(amounts, path, to);
}
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
virtual
override
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, address(this));
IWETH(WETH).withdraw(amounts[amounts.length - 1]);
TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
}
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
virtual
override
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, address(this));
IWETH(WETH).withdraw(amounts[amounts.length - 1]);
TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
}
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
virtual
override
payable
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= msg.value, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
IWETH(WETH).deposit{value: amounts[0]}();
assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
_swap(amounts, path, to);
// refund dust eth, if any
if (msg.value > amounts[0]) TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0]);
}
// **** SWAP (supporting fee-on-transfer tokens) ****
// requires the initial amount to have already been sent to the first pair
function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual {
for (uint i; i < path.length - 1; i++) {
(address input, address output) = (path[i], path[i + 1]);
(address token0,) = UniswapV2Library.sortTokens(input, output);
IUniswapV2Pair pair = IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output));
uint amountInput;
uint amountOutput;
{ // scope to avoid stack too deep errors
(uint reserve0, uint reserve1,) = pair.getReserves();
(uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
amountInput = IERC20(input).balanceOf(address(pair)).sub(reserveInput);
amountOutput = UniswapV2Library.getAmountOut(amountInput, reserveInput, reserveOutput);
}
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0));
address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to;
pair.swap(amount0Out, amount1Out, to, new bytes(0));
}
}
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) {
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn
);
uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to);
_swapSupportingFeeOnTransferTokens(path, to);
require(
IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin,
'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'
);
}
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
)
external
virtual
override
payable
ensure(deadline)
{
require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
uint amountIn = msg.value;
IWETH(WETH).deposit{value: amountIn}();
assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn));
uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to);
_swapSupportingFeeOnTransferTokens(path, to);
require(
IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin,
'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'
);
}
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
)
external
virtual
override
ensure(deadline)
{
require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn
);
_swapSupportingFeeOnTransferTokens(path, address(this));
uint amountOut = IERC20(WETH).balanceOf(address(this));
require(amountOut >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
IWETH(WETH).withdraw(amountOut);
TransferHelper.safeTransferETH(to, amountOut);
}
// **** LIBRARY FUNCTIONS ****
function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) {
return UniswapV2Library.quote(amountA, reserveA, reserveB);
}
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut)
public
pure
virtual
override
returns (uint amountOut)
{
return UniswapV2Library.getAmountOut(amountIn, reserveIn, reserveOut);
}
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut)
public
pure
virtual
override
returns (uint amountIn)
{
return UniswapV2Library.getAmountIn(amountOut, reserveIn, reserveOut);
}
function getAmountsOut(uint amountIn, address[] memory path)
public
view
virtual
override
returns (uint[] memory amounts)
{
return UniswapV2Library.getAmountsOut(factory, amountIn, path);
}
function getAmountsIn(uint amountOut, address[] memory path)
public
view
virtual
override
returns (uint[] memory amounts)
{
return UniswapV2Library.getAmountsIn(factory, amountOut, path);
}
} | removeLiquidityETHSupportingFeeOnTransferTokens | function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountETH) {
(, amountETH) = removeLiquidity(
token,
WETH,
liquidity,
amountTokenMin,
amountETHMin,
address(this),
deadline
);
TransferHelper.safeTransfer(token, to, IERC20(token).balanceOf(address(this)));
IWETH(WETH).withdraw(amountETH);
TransferHelper.safeTransferETH(to, amountETH);
}
| // **** REMOVE LIQUIDITY (supporting fee-on-transfer tokens) **** | LineComment | v0.6.6+commit.6c089d02 | None | ipfs://b585757671d7273483129a977dcee7ec3d83292d8f01e8594c04b1ae6045d497 | {
"func_code_index": [
6738,
7443
]
} | 752 |
||
UinswapTaxedRouter | contracts/uniswap_routerV2.sol | 0xaf688dc793e75ba61694ce3e6167ab6072fbf7bd | Solidity | UniswapV2Router02 | contract UniswapV2Router02 is IUniswapV2Router02 {
using SafeMath for uint;
address public immutable override factory;
address public immutable override WETH;
modifier ensure(uint deadline) {
require(deadline >= block.timestamp, 'UniswapV2Router: EXPIRED');
_;
}
constructor(address _factory, address _WETH) public {
factory = _factory;
WETH = _WETH;
}
receive() external payable {
assert(msg.sender == WETH); // only accept ETH via fallback from the WETH contract
}
// **** ADD LIQUIDITY ****
function _addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin
) internal virtual returns (uint amountA, uint amountB) {
// create the pair if it doesn't exist yet
if (IUniswapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) {
IUniswapV2Factory(factory).createPair(tokenA, tokenB);
}
(uint reserveA, uint reserveB) = UniswapV2Library.getReserves(factory, tokenA, tokenB);
if (reserveA == 0 && reserveB == 0) {
(amountA, amountB) = (amountADesired, amountBDesired);
} else {
uint amountBOptimal = UniswapV2Library.quote(amountADesired, reserveA, reserveB);
if (amountBOptimal <= amountBDesired) {
require(amountBOptimal >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT');
(amountA, amountB) = (amountADesired, amountBOptimal);
} else {
uint amountAOptimal = UniswapV2Library.quote(amountBDesired, reserveB, reserveA);
assert(amountAOptimal <= amountADesired);
require(amountAOptimal >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT');
(amountA, amountB) = (amountAOptimal, amountBDesired);
}
}
}
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint amountA, uint amountB, uint liquidity) {
(amountA, amountB) = _addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin);
address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
TransferHelper.safeTransferFrom(tokenA, msg.sender, pair, amountA);
TransferHelper.safeTransferFrom(tokenB, msg.sender, pair, amountB);
liquidity = IUniswapV2Pair(pair).mint(to);
}
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external virtual override payable ensure(deadline) returns (uint amountToken, uint amountETH, uint liquidity) {
(amountToken, amountETH) = _addLiquidity(
token,
WETH,
amountTokenDesired,
msg.value,
amountTokenMin,
amountETHMin
);
address pair = UniswapV2Library.pairFor(factory, token, WETH);
TransferHelper.safeTransferFrom(token, msg.sender, pair, amountToken);
IWETH(WETH).deposit{value: amountETH}();
assert(IWETH(WETH).transfer(pair, amountETH));
liquidity = IUniswapV2Pair(pair).mint(to);
// refund dust eth, if any
if (msg.value > amountETH) TransferHelper.safeTransferETH(msg.sender, msg.value - amountETH);
}
// **** REMOVE LIQUIDITY ****
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountA, uint amountB) {
address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
IUniswapV2Pair(pair).transferFrom(msg.sender, pair, liquidity); // send liquidity to pair
(uint amount0, uint amount1) = IUniswapV2Pair(pair).burn(to);
(address token0,) = UniswapV2Library.sortTokens(tokenA, tokenB);
(amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0);
require(amountA >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT');
require(amountB >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT');
}
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountToken, uint amountETH) {
(amountToken, amountETH) = removeLiquidity(
token,
WETH,
liquidity,
amountTokenMin,
amountETHMin,
address(this),
deadline
);
TransferHelper.safeTransfer(token, to, amountToken);
IWETH(WETH).withdraw(amountETH);
TransferHelper.safeTransferETH(to, amountETH);
}
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountA, uint amountB) {
address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
uint value = approveMax ? uint(-1) : liquidity;
IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
(amountA, amountB) = removeLiquidity(tokenA, tokenB, liquidity, amountAMin, amountBMin, to, deadline);
}
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountToken, uint amountETH) {
address pair = UniswapV2Library.pairFor(factory, token, WETH);
uint value = approveMax ? uint(-1) : liquidity;
IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
(amountToken, amountETH) = removeLiquidityETH(token, liquidity, amountTokenMin, amountETHMin, to, deadline);
}
// **** REMOVE LIQUIDITY (supporting fee-on-transfer tokens) ****
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountETH) {
(, amountETH) = removeLiquidity(
token,
WETH,
liquidity,
amountTokenMin,
amountETHMin,
address(this),
deadline
);
TransferHelper.safeTransfer(token, to, IERC20(token).balanceOf(address(this)));
IWETH(WETH).withdraw(amountETH);
TransferHelper.safeTransferETH(to, amountETH);
}
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountETH) {
address pair = UniswapV2Library.pairFor(factory, token, WETH);
uint value = approveMax ? uint(-1) : liquidity;
IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
amountETH = removeLiquidityETHSupportingFeeOnTransferTokens(
token, liquidity, amountTokenMin, amountETHMin, to, deadline
);
}
// **** SWAP ****
// requires the initial amount to have already been sent to the first pair
function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual {
for (uint i; i < path.length - 1; i++) {
(address input, address output) = (path[i], path[i + 1]);
(address token0,) = UniswapV2Library.sortTokens(input, output);
uint amountOut = amounts[i + 1];
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0));
address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to;
IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output)).swap(
amount0Out, amount1Out, to, new bytes(0)
);
}
}
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint[] memory amounts) {
amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, to);
}
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint[] memory amounts) {
amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, to);
}
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
virtual
override
payable
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsOut(factory, msg.value, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
IWETH(WETH).deposit{value: amounts[0]}();
assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
_swap(amounts, path, to);
}
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
virtual
override
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, address(this));
IWETH(WETH).withdraw(amounts[amounts.length - 1]);
TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
}
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
virtual
override
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, address(this));
IWETH(WETH).withdraw(amounts[amounts.length - 1]);
TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
}
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
virtual
override
payable
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= msg.value, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
IWETH(WETH).deposit{value: amounts[0]}();
assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
_swap(amounts, path, to);
// refund dust eth, if any
if (msg.value > amounts[0]) TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0]);
}
// **** SWAP (supporting fee-on-transfer tokens) ****
// requires the initial amount to have already been sent to the first pair
function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual {
for (uint i; i < path.length - 1; i++) {
(address input, address output) = (path[i], path[i + 1]);
(address token0,) = UniswapV2Library.sortTokens(input, output);
IUniswapV2Pair pair = IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output));
uint amountInput;
uint amountOutput;
{ // scope to avoid stack too deep errors
(uint reserve0, uint reserve1,) = pair.getReserves();
(uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
amountInput = IERC20(input).balanceOf(address(pair)).sub(reserveInput);
amountOutput = UniswapV2Library.getAmountOut(amountInput, reserveInput, reserveOutput);
}
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0));
address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to;
pair.swap(amount0Out, amount1Out, to, new bytes(0));
}
}
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) {
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn
);
uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to);
_swapSupportingFeeOnTransferTokens(path, to);
require(
IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin,
'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'
);
}
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
)
external
virtual
override
payable
ensure(deadline)
{
require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
uint amountIn = msg.value;
IWETH(WETH).deposit{value: amountIn}();
assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn));
uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to);
_swapSupportingFeeOnTransferTokens(path, to);
require(
IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin,
'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'
);
}
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
)
external
virtual
override
ensure(deadline)
{
require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn
);
_swapSupportingFeeOnTransferTokens(path, address(this));
uint amountOut = IERC20(WETH).balanceOf(address(this));
require(amountOut >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
IWETH(WETH).withdraw(amountOut);
TransferHelper.safeTransferETH(to, amountOut);
}
// **** LIBRARY FUNCTIONS ****
function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) {
return UniswapV2Library.quote(amountA, reserveA, reserveB);
}
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut)
public
pure
virtual
override
returns (uint amountOut)
{
return UniswapV2Library.getAmountOut(amountIn, reserveIn, reserveOut);
}
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut)
public
pure
virtual
override
returns (uint amountIn)
{
return UniswapV2Library.getAmountIn(amountOut, reserveIn, reserveOut);
}
function getAmountsOut(uint amountIn, address[] memory path)
public
view
virtual
override
returns (uint[] memory amounts)
{
return UniswapV2Library.getAmountsOut(factory, amountIn, path);
}
function getAmountsIn(uint amountOut, address[] memory path)
public
view
virtual
override
returns (uint[] memory amounts)
{
return UniswapV2Library.getAmountsIn(factory, amountOut, path);
}
} | _swap | function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual {
for (uint i; i < path.length - 1; i++) {
(address input, address output) = (path[i], path[i + 1]);
(address token0,) = UniswapV2Library.sortTokens(input, output);
uint amountOut = amounts[i + 1];
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0));
address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to;
IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output)).swap(
amount0Out, amount1Out, to, new bytes(0)
);
}
}
| // **** SWAP ****
// requires the initial amount to have already been sent to the first pair | LineComment | v0.6.6+commit.6c089d02 | None | ipfs://b585757671d7273483129a977dcee7ec3d83292d8f01e8594c04b1ae6045d497 | {
"func_code_index": [
8273,
9013
]
} | 753 |
||
UinswapTaxedRouter | contracts/uniswap_routerV2.sol | 0xaf688dc793e75ba61694ce3e6167ab6072fbf7bd | Solidity | UniswapV2Router02 | contract UniswapV2Router02 is IUniswapV2Router02 {
using SafeMath for uint;
address public immutable override factory;
address public immutable override WETH;
modifier ensure(uint deadline) {
require(deadline >= block.timestamp, 'UniswapV2Router: EXPIRED');
_;
}
constructor(address _factory, address _WETH) public {
factory = _factory;
WETH = _WETH;
}
receive() external payable {
assert(msg.sender == WETH); // only accept ETH via fallback from the WETH contract
}
// **** ADD LIQUIDITY ****
function _addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin
) internal virtual returns (uint amountA, uint amountB) {
// create the pair if it doesn't exist yet
if (IUniswapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) {
IUniswapV2Factory(factory).createPair(tokenA, tokenB);
}
(uint reserveA, uint reserveB) = UniswapV2Library.getReserves(factory, tokenA, tokenB);
if (reserveA == 0 && reserveB == 0) {
(amountA, amountB) = (amountADesired, amountBDesired);
} else {
uint amountBOptimal = UniswapV2Library.quote(amountADesired, reserveA, reserveB);
if (amountBOptimal <= amountBDesired) {
require(amountBOptimal >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT');
(amountA, amountB) = (amountADesired, amountBOptimal);
} else {
uint amountAOptimal = UniswapV2Library.quote(amountBDesired, reserveB, reserveA);
assert(amountAOptimal <= amountADesired);
require(amountAOptimal >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT');
(amountA, amountB) = (amountAOptimal, amountBDesired);
}
}
}
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint amountA, uint amountB, uint liquidity) {
(amountA, amountB) = _addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin);
address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
TransferHelper.safeTransferFrom(tokenA, msg.sender, pair, amountA);
TransferHelper.safeTransferFrom(tokenB, msg.sender, pair, amountB);
liquidity = IUniswapV2Pair(pair).mint(to);
}
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external virtual override payable ensure(deadline) returns (uint amountToken, uint amountETH, uint liquidity) {
(amountToken, amountETH) = _addLiquidity(
token,
WETH,
amountTokenDesired,
msg.value,
amountTokenMin,
amountETHMin
);
address pair = UniswapV2Library.pairFor(factory, token, WETH);
TransferHelper.safeTransferFrom(token, msg.sender, pair, amountToken);
IWETH(WETH).deposit{value: amountETH}();
assert(IWETH(WETH).transfer(pair, amountETH));
liquidity = IUniswapV2Pair(pair).mint(to);
// refund dust eth, if any
if (msg.value > amountETH) TransferHelper.safeTransferETH(msg.sender, msg.value - amountETH);
}
// **** REMOVE LIQUIDITY ****
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountA, uint amountB) {
address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
IUniswapV2Pair(pair).transferFrom(msg.sender, pair, liquidity); // send liquidity to pair
(uint amount0, uint amount1) = IUniswapV2Pair(pair).burn(to);
(address token0,) = UniswapV2Library.sortTokens(tokenA, tokenB);
(amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0);
require(amountA >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT');
require(amountB >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT');
}
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountToken, uint amountETH) {
(amountToken, amountETH) = removeLiquidity(
token,
WETH,
liquidity,
amountTokenMin,
amountETHMin,
address(this),
deadline
);
TransferHelper.safeTransfer(token, to, amountToken);
IWETH(WETH).withdraw(amountETH);
TransferHelper.safeTransferETH(to, amountETH);
}
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountA, uint amountB) {
address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
uint value = approveMax ? uint(-1) : liquidity;
IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
(amountA, amountB) = removeLiquidity(tokenA, tokenB, liquidity, amountAMin, amountBMin, to, deadline);
}
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountToken, uint amountETH) {
address pair = UniswapV2Library.pairFor(factory, token, WETH);
uint value = approveMax ? uint(-1) : liquidity;
IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
(amountToken, amountETH) = removeLiquidityETH(token, liquidity, amountTokenMin, amountETHMin, to, deadline);
}
// **** REMOVE LIQUIDITY (supporting fee-on-transfer tokens) ****
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountETH) {
(, amountETH) = removeLiquidity(
token,
WETH,
liquidity,
amountTokenMin,
amountETHMin,
address(this),
deadline
);
TransferHelper.safeTransfer(token, to, IERC20(token).balanceOf(address(this)));
IWETH(WETH).withdraw(amountETH);
TransferHelper.safeTransferETH(to, amountETH);
}
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountETH) {
address pair = UniswapV2Library.pairFor(factory, token, WETH);
uint value = approveMax ? uint(-1) : liquidity;
IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
amountETH = removeLiquidityETHSupportingFeeOnTransferTokens(
token, liquidity, amountTokenMin, amountETHMin, to, deadline
);
}
// **** SWAP ****
// requires the initial amount to have already been sent to the first pair
function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual {
for (uint i; i < path.length - 1; i++) {
(address input, address output) = (path[i], path[i + 1]);
(address token0,) = UniswapV2Library.sortTokens(input, output);
uint amountOut = amounts[i + 1];
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0));
address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to;
IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output)).swap(
amount0Out, amount1Out, to, new bytes(0)
);
}
}
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint[] memory amounts) {
amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, to);
}
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint[] memory amounts) {
amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, to);
}
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
virtual
override
payable
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsOut(factory, msg.value, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
IWETH(WETH).deposit{value: amounts[0]}();
assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
_swap(amounts, path, to);
}
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
virtual
override
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, address(this));
IWETH(WETH).withdraw(amounts[amounts.length - 1]);
TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
}
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
virtual
override
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, address(this));
IWETH(WETH).withdraw(amounts[amounts.length - 1]);
TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
}
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
virtual
override
payable
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= msg.value, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
IWETH(WETH).deposit{value: amounts[0]}();
assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
_swap(amounts, path, to);
// refund dust eth, if any
if (msg.value > amounts[0]) TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0]);
}
// **** SWAP (supporting fee-on-transfer tokens) ****
// requires the initial amount to have already been sent to the first pair
function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual {
for (uint i; i < path.length - 1; i++) {
(address input, address output) = (path[i], path[i + 1]);
(address token0,) = UniswapV2Library.sortTokens(input, output);
IUniswapV2Pair pair = IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output));
uint amountInput;
uint amountOutput;
{ // scope to avoid stack too deep errors
(uint reserve0, uint reserve1,) = pair.getReserves();
(uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
amountInput = IERC20(input).balanceOf(address(pair)).sub(reserveInput);
amountOutput = UniswapV2Library.getAmountOut(amountInput, reserveInput, reserveOutput);
}
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0));
address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to;
pair.swap(amount0Out, amount1Out, to, new bytes(0));
}
}
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) {
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn
);
uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to);
_swapSupportingFeeOnTransferTokens(path, to);
require(
IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin,
'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'
);
}
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
)
external
virtual
override
payable
ensure(deadline)
{
require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
uint amountIn = msg.value;
IWETH(WETH).deposit{value: amountIn}();
assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn));
uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to);
_swapSupportingFeeOnTransferTokens(path, to);
require(
IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin,
'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'
);
}
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
)
external
virtual
override
ensure(deadline)
{
require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn
);
_swapSupportingFeeOnTransferTokens(path, address(this));
uint amountOut = IERC20(WETH).balanceOf(address(this));
require(amountOut >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
IWETH(WETH).withdraw(amountOut);
TransferHelper.safeTransferETH(to, amountOut);
}
// **** LIBRARY FUNCTIONS ****
function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) {
return UniswapV2Library.quote(amountA, reserveA, reserveB);
}
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut)
public
pure
virtual
override
returns (uint amountOut)
{
return UniswapV2Library.getAmountOut(amountIn, reserveIn, reserveOut);
}
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut)
public
pure
virtual
override
returns (uint amountIn)
{
return UniswapV2Library.getAmountIn(amountOut, reserveIn, reserveOut);
}
function getAmountsOut(uint amountIn, address[] memory path)
public
view
virtual
override
returns (uint[] memory amounts)
{
return UniswapV2Library.getAmountsOut(factory, amountIn, path);
}
function getAmountsIn(uint amountOut, address[] memory path)
public
view
virtual
override
returns (uint[] memory amounts)
{
return UniswapV2Library.getAmountsIn(factory, amountOut, path);
}
} | _swapSupportingFeeOnTransferTokens | function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual {
for (uint i; i < path.length - 1; i++) {
(address input, address output) = (path[i], path[i + 1]);
(address token0,) = UniswapV2Library.sortTokens(input, output);
IUniswapV2Pair pair = IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output));
uint amountInput;
uint amountOutput;
{ // scope to avoid stack too deep errors
(uint reserve0, uint reserve1,) = pair.getReserves();
(uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
amountInput = IERC20(input).balanceOf(address(pair)).sub(reserveInput);
amountOutput = UniswapV2Library.getAmountOut(amountInput, reserveInput, reserveOutput);
}
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0));
address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to;
pair.swap(amount0Out, amount1Out, to, new bytes(0));
}
}
| // **** SWAP (supporting fee-on-transfer tokens) ****
// requires the initial amount to have already been sent to the first pair | LineComment | v0.6.6+commit.6c089d02 | None | ipfs://b585757671d7273483129a977dcee7ec3d83292d8f01e8594c04b1ae6045d497 | {
"func_code_index": [
13610,
14829
]
} | 754 |
||
UinswapTaxedRouter | contracts/uniswap_routerV2.sol | 0xaf688dc793e75ba61694ce3e6167ab6072fbf7bd | Solidity | UniswapV2Router02 | contract UniswapV2Router02 is IUniswapV2Router02 {
using SafeMath for uint;
address public immutable override factory;
address public immutable override WETH;
modifier ensure(uint deadline) {
require(deadline >= block.timestamp, 'UniswapV2Router: EXPIRED');
_;
}
constructor(address _factory, address _WETH) public {
factory = _factory;
WETH = _WETH;
}
receive() external payable {
assert(msg.sender == WETH); // only accept ETH via fallback from the WETH contract
}
// **** ADD LIQUIDITY ****
function _addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin
) internal virtual returns (uint amountA, uint amountB) {
// create the pair if it doesn't exist yet
if (IUniswapV2Factory(factory).getPair(tokenA, tokenB) == address(0)) {
IUniswapV2Factory(factory).createPair(tokenA, tokenB);
}
(uint reserveA, uint reserveB) = UniswapV2Library.getReserves(factory, tokenA, tokenB);
if (reserveA == 0 && reserveB == 0) {
(amountA, amountB) = (amountADesired, amountBDesired);
} else {
uint amountBOptimal = UniswapV2Library.quote(amountADesired, reserveA, reserveB);
if (amountBOptimal <= amountBDesired) {
require(amountBOptimal >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT');
(amountA, amountB) = (amountADesired, amountBOptimal);
} else {
uint amountAOptimal = UniswapV2Library.quote(amountBDesired, reserveB, reserveA);
assert(amountAOptimal <= amountADesired);
require(amountAOptimal >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT');
(amountA, amountB) = (amountAOptimal, amountBDesired);
}
}
}
function addLiquidity(
address tokenA,
address tokenB,
uint amountADesired,
uint amountBDesired,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint amountA, uint amountB, uint liquidity) {
(amountA, amountB) = _addLiquidity(tokenA, tokenB, amountADesired, amountBDesired, amountAMin, amountBMin);
address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
TransferHelper.safeTransferFrom(tokenA, msg.sender, pair, amountA);
TransferHelper.safeTransferFrom(tokenB, msg.sender, pair, amountB);
liquidity = IUniswapV2Pair(pair).mint(to);
}
function addLiquidityETH(
address token,
uint amountTokenDesired,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) external virtual override payable ensure(deadline) returns (uint amountToken, uint amountETH, uint liquidity) {
(amountToken, amountETH) = _addLiquidity(
token,
WETH,
amountTokenDesired,
msg.value,
amountTokenMin,
amountETHMin
);
address pair = UniswapV2Library.pairFor(factory, token, WETH);
TransferHelper.safeTransferFrom(token, msg.sender, pair, amountToken);
IWETH(WETH).deposit{value: amountETH}();
assert(IWETH(WETH).transfer(pair, amountETH));
liquidity = IUniswapV2Pair(pair).mint(to);
// refund dust eth, if any
if (msg.value > amountETH) TransferHelper.safeTransferETH(msg.sender, msg.value - amountETH);
}
// **** REMOVE LIQUIDITY ****
function removeLiquidity(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountA, uint amountB) {
address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
IUniswapV2Pair(pair).transferFrom(msg.sender, pair, liquidity); // send liquidity to pair
(uint amount0, uint amount1) = IUniswapV2Pair(pair).burn(to);
(address token0,) = UniswapV2Library.sortTokens(tokenA, tokenB);
(amountA, amountB) = tokenA == token0 ? (amount0, amount1) : (amount1, amount0);
require(amountA >= amountAMin, 'UniswapV2Router: INSUFFICIENT_A_AMOUNT');
require(amountB >= amountBMin, 'UniswapV2Router: INSUFFICIENT_B_AMOUNT');
}
function removeLiquidityETH(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountToken, uint amountETH) {
(amountToken, amountETH) = removeLiquidity(
token,
WETH,
liquidity,
amountTokenMin,
amountETHMin,
address(this),
deadline
);
TransferHelper.safeTransfer(token, to, amountToken);
IWETH(WETH).withdraw(amountETH);
TransferHelper.safeTransferETH(to, amountETH);
}
function removeLiquidityWithPermit(
address tokenA,
address tokenB,
uint liquidity,
uint amountAMin,
uint amountBMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountA, uint amountB) {
address pair = UniswapV2Library.pairFor(factory, tokenA, tokenB);
uint value = approveMax ? uint(-1) : liquidity;
IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
(amountA, amountB) = removeLiquidity(tokenA, tokenB, liquidity, amountAMin, amountBMin, to, deadline);
}
function removeLiquidityETHWithPermit(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountToken, uint amountETH) {
address pair = UniswapV2Library.pairFor(factory, token, WETH);
uint value = approveMax ? uint(-1) : liquidity;
IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
(amountToken, amountETH) = removeLiquidityETH(token, liquidity, amountTokenMin, amountETHMin, to, deadline);
}
// **** REMOVE LIQUIDITY (supporting fee-on-transfer tokens) ****
function removeLiquidityETHSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline
) public virtual override ensure(deadline) returns (uint amountETH) {
(, amountETH) = removeLiquidity(
token,
WETH,
liquidity,
amountTokenMin,
amountETHMin,
address(this),
deadline
);
TransferHelper.safeTransfer(token, to, IERC20(token).balanceOf(address(this)));
IWETH(WETH).withdraw(amountETH);
TransferHelper.safeTransferETH(to, amountETH);
}
function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
address token,
uint liquidity,
uint amountTokenMin,
uint amountETHMin,
address to,
uint deadline,
bool approveMax, uint8 v, bytes32 r, bytes32 s
) external virtual override returns (uint amountETH) {
address pair = UniswapV2Library.pairFor(factory, token, WETH);
uint value = approveMax ? uint(-1) : liquidity;
IUniswapV2Pair(pair).permit(msg.sender, address(this), value, deadline, v, r, s);
amountETH = removeLiquidityETHSupportingFeeOnTransferTokens(
token, liquidity, amountTokenMin, amountETHMin, to, deadline
);
}
// **** SWAP ****
// requires the initial amount to have already been sent to the first pair
function _swap(uint[] memory amounts, address[] memory path, address _to) internal virtual {
for (uint i; i < path.length - 1; i++) {
(address input, address output) = (path[i], path[i + 1]);
(address token0,) = UniswapV2Library.sortTokens(input, output);
uint amountOut = amounts[i + 1];
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOut) : (amountOut, uint(0));
address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to;
IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output)).swap(
amount0Out, amount1Out, to, new bytes(0)
);
}
}
function swapExactTokensForTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint[] memory amounts) {
amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, to);
}
function swapTokensForExactTokens(
uint amountOut,
uint amountInMax,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) returns (uint[] memory amounts) {
amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, to);
}
function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
external
virtual
override
payable
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsOut(factory, msg.value, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
IWETH(WETH).deposit{value: amounts[0]}();
assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
_swap(amounts, path, to);
}
function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
external
virtual
override
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= amountInMax, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, address(this));
IWETH(WETH).withdraw(amounts[amounts.length - 1]);
TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
}
function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
external
virtual
override
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsOut(factory, amountIn, path);
require(amounts[amounts.length - 1] >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]
);
_swap(amounts, path, address(this));
IWETH(WETH).withdraw(amounts[amounts.length - 1]);
TransferHelper.safeTransferETH(to, amounts[amounts.length - 1]);
}
function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
external
virtual
override
payable
ensure(deadline)
returns (uint[] memory amounts)
{
require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
amounts = UniswapV2Library.getAmountsIn(factory, amountOut, path);
require(amounts[0] <= msg.value, 'UniswapV2Router: EXCESSIVE_INPUT_AMOUNT');
IWETH(WETH).deposit{value: amounts[0]}();
assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amounts[0]));
_swap(amounts, path, to);
// refund dust eth, if any
if (msg.value > amounts[0]) TransferHelper.safeTransferETH(msg.sender, msg.value - amounts[0]);
}
// **** SWAP (supporting fee-on-transfer tokens) ****
// requires the initial amount to have already been sent to the first pair
function _swapSupportingFeeOnTransferTokens(address[] memory path, address _to) internal virtual {
for (uint i; i < path.length - 1; i++) {
(address input, address output) = (path[i], path[i + 1]);
(address token0,) = UniswapV2Library.sortTokens(input, output);
IUniswapV2Pair pair = IUniswapV2Pair(UniswapV2Library.pairFor(factory, input, output));
uint amountInput;
uint amountOutput;
{ // scope to avoid stack too deep errors
(uint reserve0, uint reserve1,) = pair.getReserves();
(uint reserveInput, uint reserveOutput) = input == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
amountInput = IERC20(input).balanceOf(address(pair)).sub(reserveInput);
amountOutput = UniswapV2Library.getAmountOut(amountInput, reserveInput, reserveOutput);
}
(uint amount0Out, uint amount1Out) = input == token0 ? (uint(0), amountOutput) : (amountOutput, uint(0));
address to = i < path.length - 2 ? UniswapV2Library.pairFor(factory, output, path[i + 2]) : _to;
pair.swap(amount0Out, amount1Out, to, new bytes(0));
}
}
function swapExactTokensForTokensSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external virtual override ensure(deadline) {
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn
);
uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to);
_swapSupportingFeeOnTransferTokens(path, to);
require(
IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin,
'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'
);
}
function swapExactETHForTokensSupportingFeeOnTransferTokens(
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
)
external
virtual
override
payable
ensure(deadline)
{
require(path[0] == WETH, 'UniswapV2Router: INVALID_PATH');
uint amountIn = msg.value;
IWETH(WETH).deposit{value: amountIn}();
assert(IWETH(WETH).transfer(UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn));
uint balanceBefore = IERC20(path[path.length - 1]).balanceOf(to);
_swapSupportingFeeOnTransferTokens(path, to);
require(
IERC20(path[path.length - 1]).balanceOf(to).sub(balanceBefore) >= amountOutMin,
'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT'
);
}
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
)
external
virtual
override
ensure(deadline)
{
require(path[path.length - 1] == WETH, 'UniswapV2Router: INVALID_PATH');
TransferHelper.safeTransferFrom(
path[0], msg.sender, UniswapV2Library.pairFor(factory, path[0], path[1]), amountIn
);
_swapSupportingFeeOnTransferTokens(path, address(this));
uint amountOut = IERC20(WETH).balanceOf(address(this));
require(amountOut >= amountOutMin, 'UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT');
IWETH(WETH).withdraw(amountOut);
TransferHelper.safeTransferETH(to, amountOut);
}
// **** LIBRARY FUNCTIONS ****
function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) {
return UniswapV2Library.quote(amountA, reserveA, reserveB);
}
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut)
public
pure
virtual
override
returns (uint amountOut)
{
return UniswapV2Library.getAmountOut(amountIn, reserveIn, reserveOut);
}
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut)
public
pure
virtual
override
returns (uint amountIn)
{
return UniswapV2Library.getAmountIn(amountOut, reserveIn, reserveOut);
}
function getAmountsOut(uint amountIn, address[] memory path)
public
view
virtual
override
returns (uint[] memory amounts)
{
return UniswapV2Library.getAmountsOut(factory, amountIn, path);
}
function getAmountsIn(uint amountOut, address[] memory path)
public
view
virtual
override
returns (uint[] memory amounts)
{
return UniswapV2Library.getAmountsIn(factory, amountOut, path);
}
} | quote | function quote(uint amountA, uint reserveA, uint reserveB) public pure virtual override returns (uint amountB) {
return UniswapV2Library.quote(amountA, reserveA, reserveB);
}
| // **** LIBRARY FUNCTIONS **** | LineComment | v0.6.6+commit.6c089d02 | None | ipfs://b585757671d7273483129a977dcee7ec3d83292d8f01e8594c04b1ae6045d497 | {
"func_code_index": [
17293,
17486
]
} | 755 |
||
UinswapTaxedRouter | contracts/uniswap_routerV2.sol | 0xaf688dc793e75ba61694ce3e6167ab6072fbf7bd | Solidity | UniswapV2Library | library UniswapV2Library {
using SafeMath for uint;
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
// fetches and sorts the reserves for a pair
function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
amountB = amountA.mul(reserveB) / reserveA;
}
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
// given an output amount of an asset and pair reserves, returns a required input amount of the other asset
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn.mul(amountOut).mul(1000);
uint denominator = reserveOut.sub(amountOut).mul(997);
amountIn = (numerator / denominator).add(1);
}
// performs chained getAmountOut calculations on any number of pairs
function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
// performs chained getAmountIn calculations on any number of pairs
function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
} | sortTokens | function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
| // returns sorted token addresses, used to handle return values from pairs sorted in this order | LineComment | v0.6.6+commit.6c089d02 | None | ipfs://b585757671d7273483129a977dcee7ec3d83292d8f01e8594c04b1ae6045d497 | {
"func_code_index": [
161,
515
]
} | 756 |
||
UinswapTaxedRouter | contracts/uniswap_routerV2.sol | 0xaf688dc793e75ba61694ce3e6167ab6072fbf7bd | Solidity | UniswapV2Library | library UniswapV2Library {
using SafeMath for uint;
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
// fetches and sorts the reserves for a pair
function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
amountB = amountA.mul(reserveB) / reserveA;
}
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
// given an output amount of an asset and pair reserves, returns a required input amount of the other asset
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn.mul(amountOut).mul(1000);
uint denominator = reserveOut.sub(amountOut).mul(997);
amountIn = (numerator / denominator).add(1);
}
// performs chained getAmountOut calculations on any number of pairs
function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
// performs chained getAmountIn calculations on any number of pairs
function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
} | pairFor | function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
| // calculates the CREATE2 address for a pair without making any external calls | LineComment | v0.6.6+commit.6c089d02 | None | ipfs://b585757671d7273483129a977dcee7ec3d83292d8f01e8594c04b1ae6045d497 | {
"func_code_index": [
602,
1085
]
} | 757 |
||
UinswapTaxedRouter | contracts/uniswap_routerV2.sol | 0xaf688dc793e75ba61694ce3e6167ab6072fbf7bd | Solidity | UniswapV2Library | library UniswapV2Library {
using SafeMath for uint;
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
// fetches and sorts the reserves for a pair
function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
amountB = amountA.mul(reserveB) / reserveA;
}
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
// given an output amount of an asset and pair reserves, returns a required input amount of the other asset
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn.mul(amountOut).mul(1000);
uint denominator = reserveOut.sub(amountOut).mul(997);
amountIn = (numerator / denominator).add(1);
}
// performs chained getAmountOut calculations on any number of pairs
function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
// performs chained getAmountIn calculations on any number of pairs
function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
} | getReserves | function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
| // fetches and sorts the reserves for a pair | LineComment | v0.6.6+commit.6c089d02 | None | ipfs://b585757671d7273483129a977dcee7ec3d83292d8f01e8594c04b1ae6045d497 | {
"func_code_index": [
1138,
1534
]
} | 758 |
||
UinswapTaxedRouter | contracts/uniswap_routerV2.sol | 0xaf688dc793e75ba61694ce3e6167ab6072fbf7bd | Solidity | UniswapV2Library | library UniswapV2Library {
using SafeMath for uint;
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
// fetches and sorts the reserves for a pair
function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
amountB = amountA.mul(reserveB) / reserveA;
}
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
// given an output amount of an asset and pair reserves, returns a required input amount of the other asset
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn.mul(amountOut).mul(1000);
uint denominator = reserveOut.sub(amountOut).mul(997);
amountIn = (numerator / denominator).add(1);
}
// performs chained getAmountOut calculations on any number of pairs
function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
// performs chained getAmountIn calculations on any number of pairs
function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
} | quote | function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
amountB = amountA.mul(reserveB) / reserveA;
}
| // given some amount of an asset and pair reserves, returns an equivalent amount of the other asset | LineComment | v0.6.6+commit.6c089d02 | None | ipfs://b585757671d7273483129a977dcee7ec3d83292d8f01e8594c04b1ae6045d497 | {
"func_code_index": [
1642,
1968
]
} | 759 |
||
UinswapTaxedRouter | contracts/uniswap_routerV2.sol | 0xaf688dc793e75ba61694ce3e6167ab6072fbf7bd | Solidity | UniswapV2Library | library UniswapV2Library {
using SafeMath for uint;
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
// fetches and sorts the reserves for a pair
function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
amountB = amountA.mul(reserveB) / reserveA;
}
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
// given an output amount of an asset and pair reserves, returns a required input amount of the other asset
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn.mul(amountOut).mul(1000);
uint denominator = reserveOut.sub(amountOut).mul(997);
amountIn = (numerator / denominator).add(1);
}
// performs chained getAmountOut calculations on any number of pairs
function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
// performs chained getAmountIn calculations on any number of pairs
function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
} | getAmountOut | function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
| // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset | LineComment | v0.6.6+commit.6c089d02 | None | ipfs://b585757671d7273483129a977dcee7ec3d83292d8f01e8594c04b1ae6045d497 | {
"func_code_index": [
2085,
2607
]
} | 760 |
||
UinswapTaxedRouter | contracts/uniswap_routerV2.sol | 0xaf688dc793e75ba61694ce3e6167ab6072fbf7bd | Solidity | UniswapV2Library | library UniswapV2Library {
using SafeMath for uint;
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
// fetches and sorts the reserves for a pair
function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
amountB = amountA.mul(reserveB) / reserveA;
}
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
// given an output amount of an asset and pair reserves, returns a required input amount of the other asset
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn.mul(amountOut).mul(1000);
uint denominator = reserveOut.sub(amountOut).mul(997);
amountIn = (numerator / denominator).add(1);
}
// performs chained getAmountOut calculations on any number of pairs
function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
// performs chained getAmountIn calculations on any number of pairs
function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
} | getAmountIn | function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn.mul(amountOut).mul(1000);
uint denominator = reserveOut.sub(amountOut).mul(997);
amountIn = (numerator / denominator).add(1);
}
| // given an output amount of an asset and pair reserves, returns a required input amount of the other asset | LineComment | v0.6.6+commit.6c089d02 | None | ipfs://b585757671d7273483129a977dcee7ec3d83292d8f01e8594c04b1ae6045d497 | {
"func_code_index": [
2723,
3200
]
} | 761 |
||
UinswapTaxedRouter | contracts/uniswap_routerV2.sol | 0xaf688dc793e75ba61694ce3e6167ab6072fbf7bd | Solidity | UniswapV2Library | library UniswapV2Library {
using SafeMath for uint;
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
// fetches and sorts the reserves for a pair
function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
amountB = amountA.mul(reserveB) / reserveA;
}
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
// given an output amount of an asset and pair reserves, returns a required input amount of the other asset
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn.mul(amountOut).mul(1000);
uint denominator = reserveOut.sub(amountOut).mul(997);
amountIn = (numerator / denominator).add(1);
}
// performs chained getAmountOut calculations on any number of pairs
function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
// performs chained getAmountIn calculations on any number of pairs
function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
} | getAmountsOut | function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
| // performs chained getAmountOut calculations on any number of pairs | LineComment | v0.6.6+commit.6c089d02 | None | ipfs://b585757671d7273483129a977dcee7ec3d83292d8f01e8594c04b1ae6045d497 | {
"func_code_index": [
3277,
3793
]
} | 762 |
||
UinswapTaxedRouter | contracts/uniswap_routerV2.sol | 0xaf688dc793e75ba61694ce3e6167ab6072fbf7bd | Solidity | UniswapV2Library | library UniswapV2Library {
using SafeMath for uint;
// returns sorted token addresses, used to handle return values from pairs sorted in this order
function sortTokens(address tokenA, address tokenB) internal pure returns (address token0, address token1) {
require(tokenA != tokenB, 'UniswapV2Library: IDENTICAL_ADDRESSES');
(token0, token1) = tokenA < tokenB ? (tokenA, tokenB) : (tokenB, tokenA);
require(token0 != address(0), 'UniswapV2Library: ZERO_ADDRESS');
}
// calculates the CREATE2 address for a pair without making any external calls
function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
// fetches and sorts the reserves for a pair
function getReserves(address factory, address tokenA, address tokenB) internal view returns (uint reserveA, uint reserveB) {
(address token0,) = sortTokens(tokenA, tokenB);
(uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves();
(reserveA, reserveB) = tokenA == token0 ? (reserve0, reserve1) : (reserve1, reserve0);
}
// given some amount of an asset and pair reserves, returns an equivalent amount of the other asset
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB) {
require(amountA > 0, 'UniswapV2Library: INSUFFICIENT_AMOUNT');
require(reserveA > 0 && reserveB > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
amountB = amountA.mul(reserveB) / reserveA;
}
// given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = amountIn.mul(997);
uint numerator = amountInWithFee.mul(reserveOut);
uint denominator = reserveIn.mul(1000).add(amountInWithFee);
amountOut = numerator / denominator;
}
// given an output amount of an asset and pair reserves, returns a required input amount of the other asset
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn) {
require(amountOut > 0, 'UniswapV2Library: INSUFFICIENT_OUTPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint numerator = reserveIn.mul(amountOut).mul(1000);
uint denominator = reserveOut.sub(amountOut).mul(997);
amountIn = (numerator / denominator).add(1);
}
// performs chained getAmountOut calculations on any number of pairs
function getAmountsOut(address factory, uint amountIn, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[0] = amountIn;
for (uint i; i < path.length - 1; i++) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i], path[i + 1]);
amounts[i + 1] = getAmountOut(amounts[i], reserveIn, reserveOut);
}
}
// performs chained getAmountIn calculations on any number of pairs
function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
} | getAmountsIn | function getAmountsIn(address factory, uint amountOut, address[] memory path) internal view returns (uint[] memory amounts) {
require(path.length >= 2, 'UniswapV2Library: INVALID_PATH');
amounts = new uint[](path.length);
amounts[amounts.length - 1] = amountOut;
for (uint i = path.length - 1; i > 0; i--) {
(uint reserveIn, uint reserveOut) = getReserves(factory, path[i - 1], path[i]);
amounts[i - 1] = getAmountIn(amounts[i], reserveIn, reserveOut);
}
}
| // performs chained getAmountIn calculations on any number of pairs | LineComment | v0.6.6+commit.6c089d02 | None | ipfs://b585757671d7273483129a977dcee7ec3d83292d8f01e8594c04b1ae6045d497 | {
"func_code_index": [
3869,
4406
]
} | 763 |
||
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | SafeMath | library SafeMath {
//multiply
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
//divide
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
//subtract
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
//addition
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
} | //Math operations with safety checks that throw on error | LineComment | mul | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
| //multiply | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
38,
204
]
} | 764 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | SafeMath | library SafeMath {
//multiply
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
//divide
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
//subtract
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
//addition
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
} | //Math operations with safety checks that throw on error | LineComment | 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 c;
}
| //divide | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
219,
512
]
} | 765 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | SafeMath | library SafeMath {
//multiply
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
//divide
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
//subtract
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
//addition
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
} | //Math operations with safety checks that throw on error | LineComment | sub | function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
| //subtract | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
531,
659
]
} | 766 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | SafeMath | library SafeMath {
//multiply
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
//divide
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
//subtract
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
//addition
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
} | //Math operations with safety checks that throw on error | LineComment | add | function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
| //addition | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
678,
830
]
} | 767 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | name | function name() public view returns (string) {
return _name;
}
| // Returns the _name of the token | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
632,
721
]
} | 768 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | symbol | function symbol() public view returns (string) {
return _symbol;
}
| // Returns the _symbol of the token | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
765,
850
]
} | 769 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | standard | function standard() public view returns (string) {
return _standard;
}
| // Returns the _standard of the token | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
896,
985
]
} | 770 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | decimals | function decimals() public view returns (uint256) {
return _decimals;
}
| // Returns the _decimals of the token | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
1031,
1121
]
} | 771 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | totalSupply | function totalSupply() public view returns (uint256) {
return _totalSupply;
}
| // Function to return the total supply of the token | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
1181,
1277
]
} | 772 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | balanceOf | function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
| // Function to return the balance of a specified address | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
1342,
1462
]
} | 773 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | transfer | function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
| // Transfer function to be compatable with ERC20 Standard | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
1528,
1825
]
} | 774 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | transfer | function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
| // Transfer function to be compatable with ERC223 Standard | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
1892,
2171
]
} | 775 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | isContract | function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
| // This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
2304,
2522
]
} | 776 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | transferToContract | function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
| // This function to be used if the target is a contract address | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
2594,
3346
]
} | 777 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | transferToAddress | function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
| // This function to be used if the target is a normal eth/wallet address | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
3428,
3877
]
} | 778 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | transferFrom | function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
| // ERC20 standard function | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
3912,
4418
]
} | 779 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | approve | function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
| // ERC20 standard function | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
4453,
4719
]
} | 780 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | allowance | function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
| // ERC20 standard function | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
4754,
4902
]
} | 781 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | function () public {
revert();
}
| // Stops any attempt from sending Ether to this contract | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
4967,
5018
]
} | 782 |
||
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | burn | function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
| // public function to call the _burn function | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
5073,
5169
]
} | 783 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | _burn | function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
| // Burn the specified amount of tokens by the owner | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
5229,
5647
]
} | 784 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | addVesting | function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
| // Create a vesting entry for the specified user | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
5704,
5880
]
} | 785 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | getVestedAmount | function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
| // Returns the vested amount for a specified user | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
5938,
6097
]
} | 786 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | getVestingEndTime | function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
| // Returns the vested end time for a specified user | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
6157,
6322
]
} | 787 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | vestingEnded | function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
| // Checks if the venting period is over for a specified user | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
6391,
6605
]
} | 788 |
|
NatminToken | NatminToken.sol | 0x4afea0f1252335e5e6be870139de87725e16560b | Solidity | NatminToken | contract NatminToken is ERC20Standard, ERC223Standard, Ownable, NatminVesting, BurnToken {
using SafeMath for uint256;
string _name = "Natmin";
string _symbol = "NAT";
string _standard = "ERC20 / ERC223";
uint256 _decimals = 18; // same value as wei
uint256 _totalSupply;
mapping(address => uint256) balances;
mapping(address => mapping(address => uint256)) allowed;
constructor(uint256 _supply) public {
require(_supply != 0);
_totalSupply = _supply * (10 ** 18);
balances[contractOwner] = _totalSupply;
}
// Returns the _name of the token
function name() public view returns (string) {
return _name;
}
// Returns the _symbol of the token
function symbol() public view returns (string) {
return _symbol;
}
// Returns the _standard of the token
function standard() public view returns (string) {
return _standard;
}
// Returns the _decimals of the token
function decimals() public view returns (uint256) {
return _decimals;
}
// Function to return the total supply of the token
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
// Function to return the balance of a specified address
function balanceOf(address _user) public view returns (uint256 balance){
return balances[_user];
}
// Transfer function to be compatable with ERC20 Standard
function transfer(address _to, uint256 _value) public returns (bool success){
bytes memory _empty;
if(isContract(_to)){
return transferToContract(_to, _value, _empty);
}else{
return transferToAddress(_to, _value, _empty);
}
}
// Transfer function to be compatable with ERC223 Standard
function transfer(address _to, uint256 _value, bytes _data) public returns (bool success) {
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}else{
return transferToAddress(_to, _value, _data);
}
}
// This function checks if the address is a contract or wallet
// If the codeLength is greater than 0, it is a contract
function isContract(address _to) internal view returns (bool) {
uint256 _codeLength;
assembly {
_codeLength := extcodesize(_to)
}
return _codeLength > 0;
}
// This function to be used if the target is a contract address
function transferToContract(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
// This will override settings and allow contract owner to send to contract
if(msg.sender != contractOwner){
ERC223ReceivingContract _tokenReceiver = ERC223ReceivingContract(_to);
_tokenReceiver.tokenFallback(msg.sender, _value, _data);
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// This function to be used if the target is a normal eth/wallet address
function transferToAddress(address _to, uint256 _value, bytes _data) internal returns (bool) {
require(balances[msg.sender] >= _value);
require(vestingEnded(msg.sender));
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// ERC20 standard function
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
require(_value <= allowed[_from][msg.sender]);
require(_value <= balances[_from]);
require(vestingEnded(_from));
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
// ERC20 standard function
function approve(address _spender, uint256 _value) public returns (bool success){
allowed[msg.sender][_spender] = 0;
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
// ERC20 standard function
function allowance(address _owner, address _spender) public view returns (uint256 remaining){
return allowed[_owner][_spender];
}
// Stops any attempt from sending Ether to this contract
function () public {
revert();
}
// public function to call the _burn function
function burn(uint256 _value) public ownerOnly {
_burn(msg.sender, _value);
}
// Burn the specified amount of tokens by the owner
function _burn(address _user, uint256 _value) internal ownerOnly {
require(balances[_user] >= _value);
balances[_user] = balances[_user].sub(_value);
_totalSupply = _totalSupply.sub(_value);
emit Burn(_user, _value);
emit Transfer(_user, address(0), _value);
bytes memory _empty;
emit Transfer(_user, address(0), _value, _empty);
}
// Create a vesting entry for the specified user
function addVesting(address _user, uint256 _amount) public ownerOnly {
vestings[_user].amount = _amount;
vestings[_user].endTime = now + 180 days;
}
// Returns the vested amount for a specified user
function getVestedAmount(address _user) public view returns (uint256 _amount) {
_amount = vestings[_user].amount;
return _amount;
}
// Returns the vested end time for a specified user
function getVestingEndTime(address _user) public view returns (uint256 _endTime) {
_endTime = vestings[_user].endTime;
return _endTime;
}
// Checks if the venting period is over for a specified user
function vestingEnded(address _user) public view returns (bool) {
if(vestings[_user].endTime <= now) {
return true;
}
else {
return false;
}
}
// Manual end vested time
function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
} | //NatminToken implements the ERC20, ERC223 standard methods | LineComment | endVesting | function endVesting(address _user) public ownerOnly {
vestings[_user].endTime = now;
}
| // Manual end vested time | LineComment | v0.4.24+commit.e67f0147 | bzzr://d3b6d4fbdfe9a9e2b9830828b19ebc9c394b1189b9577697fa8cf5e8a6808b3e | {
"func_code_index": [
6640,
6745
]
} | 789 |
|
EmblemVault | browser/github/0xcert/ethereum-erc721/src/contracts/math/safe-math.sol | 0x82c7a8f707110f5fbb16184a5933e9f78a34c6ab | Solidity | SafeMath | library SafeMath
{
/**
* List of revert message codes. Implementing dApp should handle showing the correct message.
* Based on 0xcert framework error codes.
*/
string constant OVERFLOW = "008001";
string constant SUBTRAHEND_GREATER_THEN_MINUEND = "008002";
string constant DIVISION_BY_ZERO = "008003";
/**
* @dev Multiplies two numbers, reverts on overflow.
* @param _factor1 Factor number.
* @param _factor2 Factor number.
* @return product The product of the two factors.
*/
function mul(
uint256 _factor1,
uint256 _factor2
)
internal
pure
returns (uint256 product)
{
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_factor1 == 0)
{
return 0;
}
product = _factor1 * _factor2;
require(product / _factor1 == _factor2, OVERFLOW);
}
/**
* @dev Integer division of two numbers, truncating the quotient, reverts on division by zero.
* @param _dividend Dividend number.
* @param _divisor Divisor number.
* @return quotient The quotient.
*/
function div(
uint256 _dividend,
uint256 _divisor
)
internal
pure
returns (uint256 quotient)
{
// Solidity automatically asserts when dividing by 0, using all gas.
require(_divisor > 0, DIVISION_BY_ZERO);
quotient = _dividend / _divisor;
// assert(_dividend == _divisor * quotient + _dividend % _divisor); // There is no case in which this doesn't hold.
}
/**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
* @param _minuend Minuend number.
* @param _subtrahend Subtrahend number.
* @return difference Difference.
*/
function sub(
uint256 _minuend,
uint256 _subtrahend
)
internal
pure
returns (uint256 difference)
{
require(_subtrahend <= _minuend, SUBTRAHEND_GREATER_THEN_MINUEND);
difference = _minuend - _subtrahend;
}
/**
* @dev Adds two numbers, reverts on overflow.
* @param _addend1 Number.
* @param _addend2 Number.
* @return sum Sum.
*/
function add(
uint256 _addend1,
uint256 _addend2
)
internal
pure
returns (uint256 sum)
{
sum = _addend1 + _addend2;
require(sum >= _addend1, OVERFLOW);
}
/**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo), reverts when
* dividing by zero.
* @param _dividend Number.
* @param _divisor Number.
* @return remainder Remainder.
*/
function mod(
uint256 _dividend,
uint256 _divisor
)
internal
pure
returns (uint256 remainder)
{
require(_divisor != 0, DIVISION_BY_ZERO);
remainder = _dividend % _divisor;
}
} | /**
* @dev Math operations with safety checks that throw on error. This contract is based on the
* source code at:
* https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol.
*/ | NatSpecMultiLine | mul | function mul(
uint256 _factor1,
uint256 _factor2
)
internal
pure
returns (uint256 product)
{
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_factor1 == 0)
{
return 0;
}
product = _factor1 * _factor2;
require(product / _factor1 == _factor2, OVERFLOW);
}
| /**
* @dev Multiplies two numbers, reverts on overflow.
* @param _factor1 Factor number.
* @param _factor2 Factor number.
* @return product The product of the two factors.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://6626fd920334c84d658057cbe16dd3b47b41fc7475707238fefa241a53c0a511 | {
"func_code_index": [
528,
1016
]
} | 790 |
EmblemVault | browser/github/0xcert/ethereum-erc721/src/contracts/math/safe-math.sol | 0x82c7a8f707110f5fbb16184a5933e9f78a34c6ab | Solidity | SafeMath | library SafeMath
{
/**
* List of revert message codes. Implementing dApp should handle showing the correct message.
* Based on 0xcert framework error codes.
*/
string constant OVERFLOW = "008001";
string constant SUBTRAHEND_GREATER_THEN_MINUEND = "008002";
string constant DIVISION_BY_ZERO = "008003";
/**
* @dev Multiplies two numbers, reverts on overflow.
* @param _factor1 Factor number.
* @param _factor2 Factor number.
* @return product The product of the two factors.
*/
function mul(
uint256 _factor1,
uint256 _factor2
)
internal
pure
returns (uint256 product)
{
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_factor1 == 0)
{
return 0;
}
product = _factor1 * _factor2;
require(product / _factor1 == _factor2, OVERFLOW);
}
/**
* @dev Integer division of two numbers, truncating the quotient, reverts on division by zero.
* @param _dividend Dividend number.
* @param _divisor Divisor number.
* @return quotient The quotient.
*/
function div(
uint256 _dividend,
uint256 _divisor
)
internal
pure
returns (uint256 quotient)
{
// Solidity automatically asserts when dividing by 0, using all gas.
require(_divisor > 0, DIVISION_BY_ZERO);
quotient = _dividend / _divisor;
// assert(_dividend == _divisor * quotient + _dividend % _divisor); // There is no case in which this doesn't hold.
}
/**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
* @param _minuend Minuend number.
* @param _subtrahend Subtrahend number.
* @return difference Difference.
*/
function sub(
uint256 _minuend,
uint256 _subtrahend
)
internal
pure
returns (uint256 difference)
{
require(_subtrahend <= _minuend, SUBTRAHEND_GREATER_THEN_MINUEND);
difference = _minuend - _subtrahend;
}
/**
* @dev Adds two numbers, reverts on overflow.
* @param _addend1 Number.
* @param _addend2 Number.
* @return sum Sum.
*/
function add(
uint256 _addend1,
uint256 _addend2
)
internal
pure
returns (uint256 sum)
{
sum = _addend1 + _addend2;
require(sum >= _addend1, OVERFLOW);
}
/**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo), reverts when
* dividing by zero.
* @param _dividend Number.
* @param _divisor Number.
* @return remainder Remainder.
*/
function mod(
uint256 _dividend,
uint256 _divisor
)
internal
pure
returns (uint256 remainder)
{
require(_divisor != 0, DIVISION_BY_ZERO);
remainder = _dividend % _divisor;
}
} | /**
* @dev Math operations with safety checks that throw on error. This contract is based on the
* source code at:
* https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol.
*/ | NatSpecMultiLine | div | function div(
uint256 _dividend,
uint256 _divisor
)
internal
pure
returns (uint256 quotient)
{
// Solidity automatically asserts when dividing by 0, using all gas.
require(_divisor > 0, DIVISION_BY_ZERO);
quotient = _dividend / _divisor;
// assert(_dividend == _divisor * quotient + _dividend % _divisor); // There is no case in which this doesn't hold.
}
| /**
* @dev Integer division of two numbers, truncating the quotient, reverts on division by zero.
* @param _dividend Dividend number.
* @param _divisor Divisor number.
* @return quotient The quotient.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://6626fd920334c84d658057cbe16dd3b47b41fc7475707238fefa241a53c0a511 | {
"func_code_index": [
1246,
1658
]
} | 791 |
EmblemVault | browser/github/0xcert/ethereum-erc721/src/contracts/math/safe-math.sol | 0x82c7a8f707110f5fbb16184a5933e9f78a34c6ab | Solidity | SafeMath | library SafeMath
{
/**
* List of revert message codes. Implementing dApp should handle showing the correct message.
* Based on 0xcert framework error codes.
*/
string constant OVERFLOW = "008001";
string constant SUBTRAHEND_GREATER_THEN_MINUEND = "008002";
string constant DIVISION_BY_ZERO = "008003";
/**
* @dev Multiplies two numbers, reverts on overflow.
* @param _factor1 Factor number.
* @param _factor2 Factor number.
* @return product The product of the two factors.
*/
function mul(
uint256 _factor1,
uint256 _factor2
)
internal
pure
returns (uint256 product)
{
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_factor1 == 0)
{
return 0;
}
product = _factor1 * _factor2;
require(product / _factor1 == _factor2, OVERFLOW);
}
/**
* @dev Integer division of two numbers, truncating the quotient, reverts on division by zero.
* @param _dividend Dividend number.
* @param _divisor Divisor number.
* @return quotient The quotient.
*/
function div(
uint256 _dividend,
uint256 _divisor
)
internal
pure
returns (uint256 quotient)
{
// Solidity automatically asserts when dividing by 0, using all gas.
require(_divisor > 0, DIVISION_BY_ZERO);
quotient = _dividend / _divisor;
// assert(_dividend == _divisor * quotient + _dividend % _divisor); // There is no case in which this doesn't hold.
}
/**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
* @param _minuend Minuend number.
* @param _subtrahend Subtrahend number.
* @return difference Difference.
*/
function sub(
uint256 _minuend,
uint256 _subtrahend
)
internal
pure
returns (uint256 difference)
{
require(_subtrahend <= _minuend, SUBTRAHEND_GREATER_THEN_MINUEND);
difference = _minuend - _subtrahend;
}
/**
* @dev Adds two numbers, reverts on overflow.
* @param _addend1 Number.
* @param _addend2 Number.
* @return sum Sum.
*/
function add(
uint256 _addend1,
uint256 _addend2
)
internal
pure
returns (uint256 sum)
{
sum = _addend1 + _addend2;
require(sum >= _addend1, OVERFLOW);
}
/**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo), reverts when
* dividing by zero.
* @param _dividend Number.
* @param _divisor Number.
* @return remainder Remainder.
*/
function mod(
uint256 _dividend,
uint256 _divisor
)
internal
pure
returns (uint256 remainder)
{
require(_divisor != 0, DIVISION_BY_ZERO);
remainder = _dividend % _divisor;
}
} | /**
* @dev Math operations with safety checks that throw on error. This contract is based on the
* source code at:
* https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol.
*/ | NatSpecMultiLine | sub | function sub(
uint256 _minuend,
uint256 _subtrahend
)
internal
pure
returns (uint256 difference)
{
require(_subtrahend <= _minuend, SUBTRAHEND_GREATER_THEN_MINUEND);
difference = _minuend - _subtrahend;
}
| /**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
* @param _minuend Minuend number.
* @param _subtrahend Subtrahend number.
* @return difference Difference.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://6626fd920334c84d658057cbe16dd3b47b41fc7475707238fefa241a53c0a511 | {
"func_code_index": [
1894,
2145
]
} | 792 |
EmblemVault | browser/github/0xcert/ethereum-erc721/src/contracts/math/safe-math.sol | 0x82c7a8f707110f5fbb16184a5933e9f78a34c6ab | Solidity | SafeMath | library SafeMath
{
/**
* List of revert message codes. Implementing dApp should handle showing the correct message.
* Based on 0xcert framework error codes.
*/
string constant OVERFLOW = "008001";
string constant SUBTRAHEND_GREATER_THEN_MINUEND = "008002";
string constant DIVISION_BY_ZERO = "008003";
/**
* @dev Multiplies two numbers, reverts on overflow.
* @param _factor1 Factor number.
* @param _factor2 Factor number.
* @return product The product of the two factors.
*/
function mul(
uint256 _factor1,
uint256 _factor2
)
internal
pure
returns (uint256 product)
{
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_factor1 == 0)
{
return 0;
}
product = _factor1 * _factor2;
require(product / _factor1 == _factor2, OVERFLOW);
}
/**
* @dev Integer division of two numbers, truncating the quotient, reverts on division by zero.
* @param _dividend Dividend number.
* @param _divisor Divisor number.
* @return quotient The quotient.
*/
function div(
uint256 _dividend,
uint256 _divisor
)
internal
pure
returns (uint256 quotient)
{
// Solidity automatically asserts when dividing by 0, using all gas.
require(_divisor > 0, DIVISION_BY_ZERO);
quotient = _dividend / _divisor;
// assert(_dividend == _divisor * quotient + _dividend % _divisor); // There is no case in which this doesn't hold.
}
/**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
* @param _minuend Minuend number.
* @param _subtrahend Subtrahend number.
* @return difference Difference.
*/
function sub(
uint256 _minuend,
uint256 _subtrahend
)
internal
pure
returns (uint256 difference)
{
require(_subtrahend <= _minuend, SUBTRAHEND_GREATER_THEN_MINUEND);
difference = _minuend - _subtrahend;
}
/**
* @dev Adds two numbers, reverts on overflow.
* @param _addend1 Number.
* @param _addend2 Number.
* @return sum Sum.
*/
function add(
uint256 _addend1,
uint256 _addend2
)
internal
pure
returns (uint256 sum)
{
sum = _addend1 + _addend2;
require(sum >= _addend1, OVERFLOW);
}
/**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo), reverts when
* dividing by zero.
* @param _dividend Number.
* @param _divisor Number.
* @return remainder Remainder.
*/
function mod(
uint256 _dividend,
uint256 _divisor
)
internal
pure
returns (uint256 remainder)
{
require(_divisor != 0, DIVISION_BY_ZERO);
remainder = _dividend % _divisor;
}
} | /**
* @dev Math operations with safety checks that throw on error. This contract is based on the
* source code at:
* https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol.
*/ | NatSpecMultiLine | add | function add(
uint256 _addend1,
uint256 _addend2
)
internal
pure
returns (uint256 sum)
{
sum = _addend1 + _addend2;
require(sum >= _addend1, OVERFLOW);
}
| /**
* @dev Adds two numbers, reverts on overflow.
* @param _addend1 Number.
* @param _addend2 Number.
* @return sum Sum.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://6626fd920334c84d658057cbe16dd3b47b41fc7475707238fefa241a53c0a511 | {
"func_code_index": [
2295,
2495
]
} | 793 |
EmblemVault | browser/github/0xcert/ethereum-erc721/src/contracts/math/safe-math.sol | 0x82c7a8f707110f5fbb16184a5933e9f78a34c6ab | Solidity | SafeMath | library SafeMath
{
/**
* List of revert message codes. Implementing dApp should handle showing the correct message.
* Based on 0xcert framework error codes.
*/
string constant OVERFLOW = "008001";
string constant SUBTRAHEND_GREATER_THEN_MINUEND = "008002";
string constant DIVISION_BY_ZERO = "008003";
/**
* @dev Multiplies two numbers, reverts on overflow.
* @param _factor1 Factor number.
* @param _factor2 Factor number.
* @return product The product of the two factors.
*/
function mul(
uint256 _factor1,
uint256 _factor2
)
internal
pure
returns (uint256 product)
{
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_factor1 == 0)
{
return 0;
}
product = _factor1 * _factor2;
require(product / _factor1 == _factor2, OVERFLOW);
}
/**
* @dev Integer division of two numbers, truncating the quotient, reverts on division by zero.
* @param _dividend Dividend number.
* @param _divisor Divisor number.
* @return quotient The quotient.
*/
function div(
uint256 _dividend,
uint256 _divisor
)
internal
pure
returns (uint256 quotient)
{
// Solidity automatically asserts when dividing by 0, using all gas.
require(_divisor > 0, DIVISION_BY_ZERO);
quotient = _dividend / _divisor;
// assert(_dividend == _divisor * quotient + _dividend % _divisor); // There is no case in which this doesn't hold.
}
/**
* @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
* @param _minuend Minuend number.
* @param _subtrahend Subtrahend number.
* @return difference Difference.
*/
function sub(
uint256 _minuend,
uint256 _subtrahend
)
internal
pure
returns (uint256 difference)
{
require(_subtrahend <= _minuend, SUBTRAHEND_GREATER_THEN_MINUEND);
difference = _minuend - _subtrahend;
}
/**
* @dev Adds two numbers, reverts on overflow.
* @param _addend1 Number.
* @param _addend2 Number.
* @return sum Sum.
*/
function add(
uint256 _addend1,
uint256 _addend2
)
internal
pure
returns (uint256 sum)
{
sum = _addend1 + _addend2;
require(sum >= _addend1, OVERFLOW);
}
/**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo), reverts when
* dividing by zero.
* @param _dividend Number.
* @param _divisor Number.
* @return remainder Remainder.
*/
function mod(
uint256 _dividend,
uint256 _divisor
)
internal
pure
returns (uint256 remainder)
{
require(_divisor != 0, DIVISION_BY_ZERO);
remainder = _dividend % _divisor;
}
} | /**
* @dev Math operations with safety checks that throw on error. This contract is based on the
* source code at:
* https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/math/SafeMath.sol.
*/ | NatSpecMultiLine | mod | function mod(
uint256 _dividend,
uint256 _divisor
)
internal
pure
returns (uint256 remainder)
{
require(_divisor != 0, DIVISION_BY_ZERO);
remainder = _dividend % _divisor;
}
| /**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo), reverts when
* dividing by zero.
* @param _dividend Number.
* @param _divisor Number.
* @return remainder Remainder.
*/ | NatSpecMultiLine | v0.6.2+commit.bacdbe57 | MIT | ipfs://6626fd920334c84d658057cbe16dd3b47b41fc7475707238fefa241a53c0a511 | {
"func_code_index": [
2735,
2955
]
} | 794 |
UniV3LiquidityAMO_V2 | contracts/Misc_AMOs/UniV3LiquidityAMO_V2.sol | 0xc91bb4b0696e3b48c0c501b4ce8e7244fc363a79 | Solidity | UniV3LiquidityAMO_V2 | contract UniV3LiquidityAMO_V2 is Owned {
using SafeMath for uint256;
using SafeERC20 for ERC20;
/* ========== STATE VARIABLES ========== */
// Core
FRAXStablecoin private FRAX;
FRAXShares private FXS;
IFraxAMOMinter private amo_minter;
ERC20 private giveback_collateral;
address public giveback_collateral_address;
uint256 public missing_decimals_giveback_collat;
address public timelock_address;
address public custodian_address;
// Uniswap v3
IUniswapV3Factory public univ3_factory;
INonfungiblePositionManager public univ3_positions;
ISwapRouter public univ3_router;
// Price constants
uint256 private constant PRICE_PRECISION = 1e6;
// Wildcat AMO
// Details about the AMO's uniswap positions
struct Position {
uint256 token_id;
address collateral_address;
uint128 liquidity; // the liquidity of the position
int24 tickLower; // the tick range of the position
int24 tickUpper;
uint24 fee_tier;
}
// Array of all Uni v3 NFT positions held by the AMO
Position[] public positions_array;
// List of all collaterals
address[] public collateral_addresses;
mapping(address => bool) public allowed_collaterals; // Mapping is also used for faster verification
mapping(address => OracleLike) public oracles; // Mapping of oracles (if oracle == address(0) the collateral is assumed to be pegged to 1usd)
// Map token_id to Position
mapping(uint256 => Position) public positions_mapping;
/* ========== CONSTRUCTOR ========== */
constructor(
address _creator_address,
address _giveback_collateral_address,
address _amo_minter_address
) Owned(_creator_address) {
FRAX = FRAXStablecoin(0x853d955aCEf822Db058eb8505911ED77F175b99e);
FXS = FRAXShares(0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0);
giveback_collateral_address = _giveback_collateral_address;
giveback_collateral = ERC20(_giveback_collateral_address);
missing_decimals_giveback_collat = uint(18).sub(giveback_collateral.decimals());
collateral_addresses.push(_giveback_collateral_address);
allowed_collaterals[_giveback_collateral_address] = true;
univ3_factory = IUniswapV3Factory(0x1F98431c8aD98523631AE4a59f267346ea31F984);
univ3_positions = INonfungiblePositionManager(0xC36442b4a4522E871399CD717aBDD847Ab11FE88);
univ3_router = ISwapRouter(0xE592427A0AEce92De3Edee1F18E0157C05861564);
// Initialize the minter
amo_minter = IFraxAMOMinter(_amo_minter_address);
// Get the custodian and timelock addresses from the minter
custodian_address = amo_minter.custodian_address();
timelock_address = amo_minter.timelock_address();
}
/* ========== MODIFIERS ========== */
modifier onlyByOwnGov() {
require(msg.sender == timelock_address || msg.sender == owner, "Not owner or timelock");
_;
}
modifier onlyByOwnGovCust() {
require(msg.sender == timelock_address || msg.sender == owner || msg.sender == custodian_address, "Not owner, tlck, or custd");
_;
}
modifier onlyByMinter() {
require(msg.sender == address(amo_minter), "Not minter");
_;
}
/* ========== VIEWS ========== */
function showAllocations() public view returns (uint256[4] memory allocations) {
// All numbers given are in FRAX unless otherwise stated
// Unallocated FRAX
allocations[0] = FRAX.balanceOf(address(this));
// Unallocated Collateral Dollar Value (E18)
allocations[1] = freeColDolVal();
// Sum of Uni v3 Positions liquidity, if it was all in FRAX
allocations[2] = TotalLiquidityFrax();
// Total Value
allocations[3] = allocations[0].add(allocations[1]).add(allocations[2]);
}
// E18 Collateral dollar value
function freeColDolVal() public view returns (uint256) {
uint256 value_tally_e18 = 0;
for (uint i = 0; i < collateral_addresses.length; i++){
ERC20 thisCollateral = ERC20(collateral_addresses[i]);
uint256 missing_decs = uint256(18).sub(thisCollateral.decimals());
uint256 col_bal_e18 = thisCollateral.balanceOf(address(this)).mul(10 ** missing_decs);
uint256 col_usd_value_e18 = collatDolarValue(oracles[collateral_addresses[i]], col_bal_e18);
value_tally_e18 = value_tally_e18.add(col_usd_value_e18);
}
return value_tally_e18;
}
// Convert collateral to dolar. If no oracle assumes pegged to 1USD. Both oracle, balance and return are E18
function collatDolarValue(OracleLike oracle, uint256 balance) public view returns (uint256) {
if (address(oracle) == address(0)) return balance;
return balance.mul(oracle.read()).div(1 ether);
}
// Needed for the Frax contract to function
function collatDollarBalance() public view returns (uint256) {
// Get the allocations
uint256[4] memory allocations = showAllocations();
// Get the collateral and FRAX portions
uint256 collat_portion = allocations[1];
uint256 frax_portion = (allocations[0]).add(allocations[2]);
// Assumes worst case scenario if FRAX slips out of range.
// Otherwise, it would only be half that is multiplied by the CR
frax_portion = frax_portion.mul(FRAX.global_collateral_ratio()).div(PRICE_PRECISION);
return (collat_portion).add(frax_portion);
}
function dollarBalances() public view returns (uint256 frax_val_e18, uint256 collat_val_e18) {
frax_val_e18 = showAllocations()[3];
collat_val_e18 = collatDollarBalance();
}
function TotalLiquidityFrax() public view returns (uint256) {
uint256 frax_tally = 0;
Position memory thisPosition;
for (uint256 i = 0; i < positions_array.length; i++) {
thisPosition = positions_array[i];
uint128 this_liq = thisPosition.liquidity;
if (this_liq > 0){
uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(thisPosition.tickLower);
uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(thisPosition.tickUpper);
if (thisPosition.collateral_address > 0x853d955aCEf822Db058eb8505911ED77F175b99e){ // if address(FRAX) < collateral_address, then FRAX is token0
frax_tally = frax_tally.add(LiquidityAmounts.getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, this_liq));
}
else {
frax_tally = frax_tally.add(LiquidityAmounts.getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, this_liq));
}
}
}
// Return the sum of all the positions' balances of FRAX, if the price fell off the range towards that side
return frax_tally;
}
// Returns this contract's liquidity in a specific [FRAX]-[collateral] uni v3 pool
function liquidityInPool(address _collateral_address, int24 _tickLower, int24 _tickUpper, uint24 _fee) public view returns (uint128) {
IUniswapV3Pool get_pool = IUniswapV3Pool(univ3_factory.getPool(address(FRAX), _collateral_address, _fee));
// goes into the pool's positions mapping, and grabs this address's liquidity
(uint128 liquidity, , , , ) = get_pool.positions(keccak256(abi.encodePacked(address(this), _tickLower, _tickUpper)));
return liquidity;
}
// Backwards compatibility
function mintedBalance() public view returns (int256) {
return amo_minter.frax_mint_balances(address(this));
}
// Backwards compatibility
function collateralBalance() public view returns (int256) {
return amo_minter.collat_borrowed_balances(address(this));
}
// Only counts non-withdrawn positions
function numPositions() public view returns (uint256) {
return positions_array.length;
}
function allCollateralAddresses() external view returns (address[] memory) {
return collateral_addresses;
}
/* ========== RESTRICTED FUNCTIONS, BUT CUSTODIAN CAN CALL ========== */
// Iterate through all positions and collect fees accumulated
function collectFees() external onlyByOwnGovCust {
for (uint i = 0; i < positions_array.length; i++){
Position memory current_position = positions_array[i];
INonfungiblePositionManager.CollectParams memory collect_params = INonfungiblePositionManager.CollectParams(
current_position.token_id,
custodian_address,
type(uint128).max,
type(uint128).max
);
// Send to custodian address
univ3_positions.collect(collect_params);
}
}
/* ---------------------------------------------------- */
/* ---------------------- Uni v3 ---------------------- */
/* ---------------------------------------------------- */
function approveTarget(address _target, address _token, uint256 _amount, bool use_safe_approve) public onlyByOwnGov {
if (use_safe_approve) {
// safeApprove needed for USDT and others for the first approval
// You need to approve 0 every time beforehand for USDT: it resets
TransferHelper.safeApprove(_token, _target, _amount);
}
else {
ERC20(_token).approve(_target, _amount);
}
}
// IUniswapV3Pool public current_uni_pool; // only used for mint callback; is set and accessed during execution of addLiquidity()
function addLiquidity(address _tokenA, address _tokenB, int24 _tickLower, int24 _tickUpper, uint24 _fee, uint256 _amount0Desired, uint256 _amount1Desired, uint256 _amount0Min, uint256 _amount1Min) public onlyByOwnGov {
// Make sure the collateral is allowed
require(allowed_collaterals[_tokenA] || _tokenA == address(FRAX), "TokenA not allowed");
require(allowed_collaterals[_tokenB] || _tokenB == address(FRAX), "TokenB not allowed");
ERC20(_tokenA).transferFrom(msg.sender, address(this), _amount0Desired);
ERC20(_tokenB).transferFrom(msg.sender, address(this), _amount1Desired);
ERC20(_tokenA).approve(address(univ3_positions), _amount0Desired);
ERC20(_tokenB).approve(address(univ3_positions), _amount1Desired);
INonfungiblePositionManager.MintParams memory params = INonfungiblePositionManager.MintParams(
_tokenA,
_tokenB,
_fee,
_tickLower,
_tickUpper,
_amount0Desired,
_amount1Desired,
_amount0Min,
_amount1Min,
address(this),
block.timestamp
);
(uint256 tokenId, uint128 amountLiquidity,,) = univ3_positions.mint(params);
Position memory pos = Position(
tokenId,
_tokenA == address(FRAX) ? _tokenB : _tokenA,
amountLiquidity,
_tickLower,
_tickUpper,
_fee
);
positions_array.push(pos);
positions_mapping[tokenId] = pos;
}
/*
** burn tokenAmount from the recipient and send tokens to the receipient
*/
event log(uint);
function removeLiquidity(uint256 positionIndex) public onlyByOwnGov {
Position memory pos = positions_array[positionIndex];
INonfungiblePositionManager.CollectParams memory collect_params = INonfungiblePositionManager.CollectParams(
pos.token_id,
custodian_address,
type(uint128).max,
type(uint128).max
);
univ3_positions.collect(collect_params);
univ3_positions.burn(pos.token_id);
positions_array[positionIndex] = positions_array[positions_array.length -1];
positions_array.pop();
delete positions_mapping[pos.token_id];
emit log(positions_array.length);
emit log(positions_mapping[pos.token_id].token_id);
}
// Swap tokenA into tokenB using univ3_router.ExactInputSingle()
// Uni V3 only
function swap(address _tokenA, address _tokenB, uint24 _fee_tier, uint256 _amountAtoB, uint256 _amountOutMinimum, uint160 _sqrtPriceLimitX96) public onlyByOwnGov returns (uint256) {
// Make sure the collateral is allowed
require(allowed_collaterals[_tokenA] || _tokenA == address(FRAX), "TokenA not allowed");
require(allowed_collaterals[_tokenB] || _tokenB == address(FRAX), "TokenB not allowed");
ISwapRouter.ExactInputSingleParams memory swap_params = ISwapRouter.ExactInputSingleParams(
_tokenA,
_tokenB,
_fee_tier,
address(this),
2105300114, // Expiration: a long time from now
_amountAtoB,
_amountOutMinimum,
_sqrtPriceLimitX96
);
// Approval
TransferHelper.safeApprove(_tokenA, address(univ3_router), _amountAtoB);
uint256 amountOut = univ3_router.exactInputSingle(swap_params);
return amountOut;
}
/* ========== Burns and givebacks ========== */
// Give USDC profits back. Goes through the minter
function giveCollatBack(uint256 collat_amount) external onlyByOwnGovCust {
giveback_collateral.approve(address(amo_minter), collat_amount);
amo_minter.receiveCollatFromAMO(collat_amount);
}
// Burn unneeded or excess FRAX. Goes through the minter
function burnFRAX(uint256 frax_amount) public onlyByOwnGovCust {
FRAX.approve(address(amo_minter), frax_amount);
amo_minter.burnFraxFromAMO(frax_amount);
}
// Burn unneeded FXS. Goes through the minter
function burnFXS(uint256 fxs_amount) public onlyByOwnGovCust {
FXS.approve(address(amo_minter), fxs_amount);
amo_minter.burnFxsFromAMO(fxs_amount);
}
/* ========== OWNER / GOVERNANCE FUNCTIONS ONLY ========== */
// Only owner or timelock can call, to limit risk
// Adds collateral addresses supported. Needed to make sure dollarBalances is correct
function addCollateral(address collat_addr) public onlyByOwnGov {
require(collat_addr != address(0), "Zero address detected");
require(collat_addr != address(FRAX), "FRAX is not collateral");
require(allowed_collaterals[collat_addr] == false, "Address already exists");
allowed_collaterals[collat_addr] = true;
collateral_addresses.push(collat_addr);
}
// Adds oracle for collateral. Optional for 1usd pegged coins.
function addOracle(address collat_addr, address oracle) public onlyByOwnGov {
require(collat_addr != address(0), "Zero address detected");
require(collat_addr != address(FRAX), "FRAX is not collateral");
oracles[collat_addr] = OracleLike(oracle);
}
function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyByOwnGov {
// Can only be triggered by owner or governance, not custodian
// Tokens are sent to the custodian, as a sort of safeguard
TransferHelper.safeTransfer(tokenAddress, custodian_address, tokenAmount);
emit RecoveredERC20(tokenAddress, tokenAmount);
}
function recoverERC721(address tokenAddress, uint256 token_id) external onlyByOwnGov {
// Only the owner address can ever receive the recovery withdrawal
// INonfungiblePositionManager inherits IERC721 so the latter does not need to be imported
INonfungiblePositionManager(tokenAddress).safeTransferFrom( address(this), custodian_address, token_id);
emit RecoveredERC721(tokenAddress, token_id);
}
// Generic proxy
function execute(
address _to,
uint256 _value,
bytes calldata _data
) external onlyByOwnGov returns (bool, bytes memory) {
(bool success, bytes memory result) = _to.call{value:_value}(_data);
return (success, result);
}
/* ========== EVENTS ========== */
event RecoveredERC20(address token, uint256 amount);
event RecoveredERC721(address token, uint256 id);
} | showAllocations | function showAllocations() public view returns (uint256[4] memory allocations) {
// All numbers given are in FRAX unless otherwise stated
// Unallocated FRAX
allocations[0] = FRAX.balanceOf(address(this));
// Unallocated Collateral Dollar Value (E18)
allocations[1] = freeColDolVal();
// Sum of Uni v3 Positions liquidity, if it was all in FRAX
allocations[2] = TotalLiquidityFrax();
// Total Value
allocations[3] = allocations[0].add(allocations[1]).add(allocations[2]);
}
| /* ========== VIEWS ========== */ | Comment | v0.8.6+commit.11564f7e | {
"func_code_index": [
3351,
3908
]
} | 795 |
||||
UniV3LiquidityAMO_V2 | contracts/Misc_AMOs/UniV3LiquidityAMO_V2.sol | 0xc91bb4b0696e3b48c0c501b4ce8e7244fc363a79 | Solidity | UniV3LiquidityAMO_V2 | contract UniV3LiquidityAMO_V2 is Owned {
using SafeMath for uint256;
using SafeERC20 for ERC20;
/* ========== STATE VARIABLES ========== */
// Core
FRAXStablecoin private FRAX;
FRAXShares private FXS;
IFraxAMOMinter private amo_minter;
ERC20 private giveback_collateral;
address public giveback_collateral_address;
uint256 public missing_decimals_giveback_collat;
address public timelock_address;
address public custodian_address;
// Uniswap v3
IUniswapV3Factory public univ3_factory;
INonfungiblePositionManager public univ3_positions;
ISwapRouter public univ3_router;
// Price constants
uint256 private constant PRICE_PRECISION = 1e6;
// Wildcat AMO
// Details about the AMO's uniswap positions
struct Position {
uint256 token_id;
address collateral_address;
uint128 liquidity; // the liquidity of the position
int24 tickLower; // the tick range of the position
int24 tickUpper;
uint24 fee_tier;
}
// Array of all Uni v3 NFT positions held by the AMO
Position[] public positions_array;
// List of all collaterals
address[] public collateral_addresses;
mapping(address => bool) public allowed_collaterals; // Mapping is also used for faster verification
mapping(address => OracleLike) public oracles; // Mapping of oracles (if oracle == address(0) the collateral is assumed to be pegged to 1usd)
// Map token_id to Position
mapping(uint256 => Position) public positions_mapping;
/* ========== CONSTRUCTOR ========== */
constructor(
address _creator_address,
address _giveback_collateral_address,
address _amo_minter_address
) Owned(_creator_address) {
FRAX = FRAXStablecoin(0x853d955aCEf822Db058eb8505911ED77F175b99e);
FXS = FRAXShares(0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0);
giveback_collateral_address = _giveback_collateral_address;
giveback_collateral = ERC20(_giveback_collateral_address);
missing_decimals_giveback_collat = uint(18).sub(giveback_collateral.decimals());
collateral_addresses.push(_giveback_collateral_address);
allowed_collaterals[_giveback_collateral_address] = true;
univ3_factory = IUniswapV3Factory(0x1F98431c8aD98523631AE4a59f267346ea31F984);
univ3_positions = INonfungiblePositionManager(0xC36442b4a4522E871399CD717aBDD847Ab11FE88);
univ3_router = ISwapRouter(0xE592427A0AEce92De3Edee1F18E0157C05861564);
// Initialize the minter
amo_minter = IFraxAMOMinter(_amo_minter_address);
// Get the custodian and timelock addresses from the minter
custodian_address = amo_minter.custodian_address();
timelock_address = amo_minter.timelock_address();
}
/* ========== MODIFIERS ========== */
modifier onlyByOwnGov() {
require(msg.sender == timelock_address || msg.sender == owner, "Not owner or timelock");
_;
}
modifier onlyByOwnGovCust() {
require(msg.sender == timelock_address || msg.sender == owner || msg.sender == custodian_address, "Not owner, tlck, or custd");
_;
}
modifier onlyByMinter() {
require(msg.sender == address(amo_minter), "Not minter");
_;
}
/* ========== VIEWS ========== */
function showAllocations() public view returns (uint256[4] memory allocations) {
// All numbers given are in FRAX unless otherwise stated
// Unallocated FRAX
allocations[0] = FRAX.balanceOf(address(this));
// Unallocated Collateral Dollar Value (E18)
allocations[1] = freeColDolVal();
// Sum of Uni v3 Positions liquidity, if it was all in FRAX
allocations[2] = TotalLiquidityFrax();
// Total Value
allocations[3] = allocations[0].add(allocations[1]).add(allocations[2]);
}
// E18 Collateral dollar value
function freeColDolVal() public view returns (uint256) {
uint256 value_tally_e18 = 0;
for (uint i = 0; i < collateral_addresses.length; i++){
ERC20 thisCollateral = ERC20(collateral_addresses[i]);
uint256 missing_decs = uint256(18).sub(thisCollateral.decimals());
uint256 col_bal_e18 = thisCollateral.balanceOf(address(this)).mul(10 ** missing_decs);
uint256 col_usd_value_e18 = collatDolarValue(oracles[collateral_addresses[i]], col_bal_e18);
value_tally_e18 = value_tally_e18.add(col_usd_value_e18);
}
return value_tally_e18;
}
// Convert collateral to dolar. If no oracle assumes pegged to 1USD. Both oracle, balance and return are E18
function collatDolarValue(OracleLike oracle, uint256 balance) public view returns (uint256) {
if (address(oracle) == address(0)) return balance;
return balance.mul(oracle.read()).div(1 ether);
}
// Needed for the Frax contract to function
function collatDollarBalance() public view returns (uint256) {
// Get the allocations
uint256[4] memory allocations = showAllocations();
// Get the collateral and FRAX portions
uint256 collat_portion = allocations[1];
uint256 frax_portion = (allocations[0]).add(allocations[2]);
// Assumes worst case scenario if FRAX slips out of range.
// Otherwise, it would only be half that is multiplied by the CR
frax_portion = frax_portion.mul(FRAX.global_collateral_ratio()).div(PRICE_PRECISION);
return (collat_portion).add(frax_portion);
}
function dollarBalances() public view returns (uint256 frax_val_e18, uint256 collat_val_e18) {
frax_val_e18 = showAllocations()[3];
collat_val_e18 = collatDollarBalance();
}
function TotalLiquidityFrax() public view returns (uint256) {
uint256 frax_tally = 0;
Position memory thisPosition;
for (uint256 i = 0; i < positions_array.length; i++) {
thisPosition = positions_array[i];
uint128 this_liq = thisPosition.liquidity;
if (this_liq > 0){
uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(thisPosition.tickLower);
uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(thisPosition.tickUpper);
if (thisPosition.collateral_address > 0x853d955aCEf822Db058eb8505911ED77F175b99e){ // if address(FRAX) < collateral_address, then FRAX is token0
frax_tally = frax_tally.add(LiquidityAmounts.getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, this_liq));
}
else {
frax_tally = frax_tally.add(LiquidityAmounts.getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, this_liq));
}
}
}
// Return the sum of all the positions' balances of FRAX, if the price fell off the range towards that side
return frax_tally;
}
// Returns this contract's liquidity in a specific [FRAX]-[collateral] uni v3 pool
function liquidityInPool(address _collateral_address, int24 _tickLower, int24 _tickUpper, uint24 _fee) public view returns (uint128) {
IUniswapV3Pool get_pool = IUniswapV3Pool(univ3_factory.getPool(address(FRAX), _collateral_address, _fee));
// goes into the pool's positions mapping, and grabs this address's liquidity
(uint128 liquidity, , , , ) = get_pool.positions(keccak256(abi.encodePacked(address(this), _tickLower, _tickUpper)));
return liquidity;
}
// Backwards compatibility
function mintedBalance() public view returns (int256) {
return amo_minter.frax_mint_balances(address(this));
}
// Backwards compatibility
function collateralBalance() public view returns (int256) {
return amo_minter.collat_borrowed_balances(address(this));
}
// Only counts non-withdrawn positions
function numPositions() public view returns (uint256) {
return positions_array.length;
}
function allCollateralAddresses() external view returns (address[] memory) {
return collateral_addresses;
}
/* ========== RESTRICTED FUNCTIONS, BUT CUSTODIAN CAN CALL ========== */
// Iterate through all positions and collect fees accumulated
function collectFees() external onlyByOwnGovCust {
for (uint i = 0; i < positions_array.length; i++){
Position memory current_position = positions_array[i];
INonfungiblePositionManager.CollectParams memory collect_params = INonfungiblePositionManager.CollectParams(
current_position.token_id,
custodian_address,
type(uint128).max,
type(uint128).max
);
// Send to custodian address
univ3_positions.collect(collect_params);
}
}
/* ---------------------------------------------------- */
/* ---------------------- Uni v3 ---------------------- */
/* ---------------------------------------------------- */
function approveTarget(address _target, address _token, uint256 _amount, bool use_safe_approve) public onlyByOwnGov {
if (use_safe_approve) {
// safeApprove needed for USDT and others for the first approval
// You need to approve 0 every time beforehand for USDT: it resets
TransferHelper.safeApprove(_token, _target, _amount);
}
else {
ERC20(_token).approve(_target, _amount);
}
}
// IUniswapV3Pool public current_uni_pool; // only used for mint callback; is set and accessed during execution of addLiquidity()
function addLiquidity(address _tokenA, address _tokenB, int24 _tickLower, int24 _tickUpper, uint24 _fee, uint256 _amount0Desired, uint256 _amount1Desired, uint256 _amount0Min, uint256 _amount1Min) public onlyByOwnGov {
// Make sure the collateral is allowed
require(allowed_collaterals[_tokenA] || _tokenA == address(FRAX), "TokenA not allowed");
require(allowed_collaterals[_tokenB] || _tokenB == address(FRAX), "TokenB not allowed");
ERC20(_tokenA).transferFrom(msg.sender, address(this), _amount0Desired);
ERC20(_tokenB).transferFrom(msg.sender, address(this), _amount1Desired);
ERC20(_tokenA).approve(address(univ3_positions), _amount0Desired);
ERC20(_tokenB).approve(address(univ3_positions), _amount1Desired);
INonfungiblePositionManager.MintParams memory params = INonfungiblePositionManager.MintParams(
_tokenA,
_tokenB,
_fee,
_tickLower,
_tickUpper,
_amount0Desired,
_amount1Desired,
_amount0Min,
_amount1Min,
address(this),
block.timestamp
);
(uint256 tokenId, uint128 amountLiquidity,,) = univ3_positions.mint(params);
Position memory pos = Position(
tokenId,
_tokenA == address(FRAX) ? _tokenB : _tokenA,
amountLiquidity,
_tickLower,
_tickUpper,
_fee
);
positions_array.push(pos);
positions_mapping[tokenId] = pos;
}
/*
** burn tokenAmount from the recipient and send tokens to the receipient
*/
event log(uint);
function removeLiquidity(uint256 positionIndex) public onlyByOwnGov {
Position memory pos = positions_array[positionIndex];
INonfungiblePositionManager.CollectParams memory collect_params = INonfungiblePositionManager.CollectParams(
pos.token_id,
custodian_address,
type(uint128).max,
type(uint128).max
);
univ3_positions.collect(collect_params);
univ3_positions.burn(pos.token_id);
positions_array[positionIndex] = positions_array[positions_array.length -1];
positions_array.pop();
delete positions_mapping[pos.token_id];
emit log(positions_array.length);
emit log(positions_mapping[pos.token_id].token_id);
}
// Swap tokenA into tokenB using univ3_router.ExactInputSingle()
// Uni V3 only
function swap(address _tokenA, address _tokenB, uint24 _fee_tier, uint256 _amountAtoB, uint256 _amountOutMinimum, uint160 _sqrtPriceLimitX96) public onlyByOwnGov returns (uint256) {
// Make sure the collateral is allowed
require(allowed_collaterals[_tokenA] || _tokenA == address(FRAX), "TokenA not allowed");
require(allowed_collaterals[_tokenB] || _tokenB == address(FRAX), "TokenB not allowed");
ISwapRouter.ExactInputSingleParams memory swap_params = ISwapRouter.ExactInputSingleParams(
_tokenA,
_tokenB,
_fee_tier,
address(this),
2105300114, // Expiration: a long time from now
_amountAtoB,
_amountOutMinimum,
_sqrtPriceLimitX96
);
// Approval
TransferHelper.safeApprove(_tokenA, address(univ3_router), _amountAtoB);
uint256 amountOut = univ3_router.exactInputSingle(swap_params);
return amountOut;
}
/* ========== Burns and givebacks ========== */
// Give USDC profits back. Goes through the minter
function giveCollatBack(uint256 collat_amount) external onlyByOwnGovCust {
giveback_collateral.approve(address(amo_minter), collat_amount);
amo_minter.receiveCollatFromAMO(collat_amount);
}
// Burn unneeded or excess FRAX. Goes through the minter
function burnFRAX(uint256 frax_amount) public onlyByOwnGovCust {
FRAX.approve(address(amo_minter), frax_amount);
amo_minter.burnFraxFromAMO(frax_amount);
}
// Burn unneeded FXS. Goes through the minter
function burnFXS(uint256 fxs_amount) public onlyByOwnGovCust {
FXS.approve(address(amo_minter), fxs_amount);
amo_minter.burnFxsFromAMO(fxs_amount);
}
/* ========== OWNER / GOVERNANCE FUNCTIONS ONLY ========== */
// Only owner or timelock can call, to limit risk
// Adds collateral addresses supported. Needed to make sure dollarBalances is correct
function addCollateral(address collat_addr) public onlyByOwnGov {
require(collat_addr != address(0), "Zero address detected");
require(collat_addr != address(FRAX), "FRAX is not collateral");
require(allowed_collaterals[collat_addr] == false, "Address already exists");
allowed_collaterals[collat_addr] = true;
collateral_addresses.push(collat_addr);
}
// Adds oracle for collateral. Optional for 1usd pegged coins.
function addOracle(address collat_addr, address oracle) public onlyByOwnGov {
require(collat_addr != address(0), "Zero address detected");
require(collat_addr != address(FRAX), "FRAX is not collateral");
oracles[collat_addr] = OracleLike(oracle);
}
function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyByOwnGov {
// Can only be triggered by owner or governance, not custodian
// Tokens are sent to the custodian, as a sort of safeguard
TransferHelper.safeTransfer(tokenAddress, custodian_address, tokenAmount);
emit RecoveredERC20(tokenAddress, tokenAmount);
}
function recoverERC721(address tokenAddress, uint256 token_id) external onlyByOwnGov {
// Only the owner address can ever receive the recovery withdrawal
// INonfungiblePositionManager inherits IERC721 so the latter does not need to be imported
INonfungiblePositionManager(tokenAddress).safeTransferFrom( address(this), custodian_address, token_id);
emit RecoveredERC721(tokenAddress, token_id);
}
// Generic proxy
function execute(
address _to,
uint256 _value,
bytes calldata _data
) external onlyByOwnGov returns (bool, bytes memory) {
(bool success, bytes memory result) = _to.call{value:_value}(_data);
return (success, result);
}
/* ========== EVENTS ========== */
event RecoveredERC20(address token, uint256 amount);
event RecoveredERC721(address token, uint256 id);
} | freeColDolVal | function freeColDolVal() public view returns (uint256) {
uint256 value_tally_e18 = 0;
for (uint i = 0; i < collateral_addresses.length; i++){
ERC20 thisCollateral = ERC20(collateral_addresses[i]);
uint256 missing_decs = uint256(18).sub(thisCollateral.decimals());
uint256 col_bal_e18 = thisCollateral.balanceOf(address(this)).mul(10 ** missing_decs);
uint256 col_usd_value_e18 = collatDolarValue(oracles[collateral_addresses[i]], col_bal_e18);
value_tally_e18 = value_tally_e18.add(col_usd_value_e18);
}
return value_tally_e18;
}
| // E18 Collateral dollar value | LineComment | v0.8.6+commit.11564f7e | {
"func_code_index": [
3945,
4574
]
} | 796 |
||||
UniV3LiquidityAMO_V2 | contracts/Misc_AMOs/UniV3LiquidityAMO_V2.sol | 0xc91bb4b0696e3b48c0c501b4ce8e7244fc363a79 | Solidity | UniV3LiquidityAMO_V2 | contract UniV3LiquidityAMO_V2 is Owned {
using SafeMath for uint256;
using SafeERC20 for ERC20;
/* ========== STATE VARIABLES ========== */
// Core
FRAXStablecoin private FRAX;
FRAXShares private FXS;
IFraxAMOMinter private amo_minter;
ERC20 private giveback_collateral;
address public giveback_collateral_address;
uint256 public missing_decimals_giveback_collat;
address public timelock_address;
address public custodian_address;
// Uniswap v3
IUniswapV3Factory public univ3_factory;
INonfungiblePositionManager public univ3_positions;
ISwapRouter public univ3_router;
// Price constants
uint256 private constant PRICE_PRECISION = 1e6;
// Wildcat AMO
// Details about the AMO's uniswap positions
struct Position {
uint256 token_id;
address collateral_address;
uint128 liquidity; // the liquidity of the position
int24 tickLower; // the tick range of the position
int24 tickUpper;
uint24 fee_tier;
}
// Array of all Uni v3 NFT positions held by the AMO
Position[] public positions_array;
// List of all collaterals
address[] public collateral_addresses;
mapping(address => bool) public allowed_collaterals; // Mapping is also used for faster verification
mapping(address => OracleLike) public oracles; // Mapping of oracles (if oracle == address(0) the collateral is assumed to be pegged to 1usd)
// Map token_id to Position
mapping(uint256 => Position) public positions_mapping;
/* ========== CONSTRUCTOR ========== */
constructor(
address _creator_address,
address _giveback_collateral_address,
address _amo_minter_address
) Owned(_creator_address) {
FRAX = FRAXStablecoin(0x853d955aCEf822Db058eb8505911ED77F175b99e);
FXS = FRAXShares(0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0);
giveback_collateral_address = _giveback_collateral_address;
giveback_collateral = ERC20(_giveback_collateral_address);
missing_decimals_giveback_collat = uint(18).sub(giveback_collateral.decimals());
collateral_addresses.push(_giveback_collateral_address);
allowed_collaterals[_giveback_collateral_address] = true;
univ3_factory = IUniswapV3Factory(0x1F98431c8aD98523631AE4a59f267346ea31F984);
univ3_positions = INonfungiblePositionManager(0xC36442b4a4522E871399CD717aBDD847Ab11FE88);
univ3_router = ISwapRouter(0xE592427A0AEce92De3Edee1F18E0157C05861564);
// Initialize the minter
amo_minter = IFraxAMOMinter(_amo_minter_address);
// Get the custodian and timelock addresses from the minter
custodian_address = amo_minter.custodian_address();
timelock_address = amo_minter.timelock_address();
}
/* ========== MODIFIERS ========== */
modifier onlyByOwnGov() {
require(msg.sender == timelock_address || msg.sender == owner, "Not owner or timelock");
_;
}
modifier onlyByOwnGovCust() {
require(msg.sender == timelock_address || msg.sender == owner || msg.sender == custodian_address, "Not owner, tlck, or custd");
_;
}
modifier onlyByMinter() {
require(msg.sender == address(amo_minter), "Not minter");
_;
}
/* ========== VIEWS ========== */
function showAllocations() public view returns (uint256[4] memory allocations) {
// All numbers given are in FRAX unless otherwise stated
// Unallocated FRAX
allocations[0] = FRAX.balanceOf(address(this));
// Unallocated Collateral Dollar Value (E18)
allocations[1] = freeColDolVal();
// Sum of Uni v3 Positions liquidity, if it was all in FRAX
allocations[2] = TotalLiquidityFrax();
// Total Value
allocations[3] = allocations[0].add(allocations[1]).add(allocations[2]);
}
// E18 Collateral dollar value
function freeColDolVal() public view returns (uint256) {
uint256 value_tally_e18 = 0;
for (uint i = 0; i < collateral_addresses.length; i++){
ERC20 thisCollateral = ERC20(collateral_addresses[i]);
uint256 missing_decs = uint256(18).sub(thisCollateral.decimals());
uint256 col_bal_e18 = thisCollateral.balanceOf(address(this)).mul(10 ** missing_decs);
uint256 col_usd_value_e18 = collatDolarValue(oracles[collateral_addresses[i]], col_bal_e18);
value_tally_e18 = value_tally_e18.add(col_usd_value_e18);
}
return value_tally_e18;
}
// Convert collateral to dolar. If no oracle assumes pegged to 1USD. Both oracle, balance and return are E18
function collatDolarValue(OracleLike oracle, uint256 balance) public view returns (uint256) {
if (address(oracle) == address(0)) return balance;
return balance.mul(oracle.read()).div(1 ether);
}
// Needed for the Frax contract to function
function collatDollarBalance() public view returns (uint256) {
// Get the allocations
uint256[4] memory allocations = showAllocations();
// Get the collateral and FRAX portions
uint256 collat_portion = allocations[1];
uint256 frax_portion = (allocations[0]).add(allocations[2]);
// Assumes worst case scenario if FRAX slips out of range.
// Otherwise, it would only be half that is multiplied by the CR
frax_portion = frax_portion.mul(FRAX.global_collateral_ratio()).div(PRICE_PRECISION);
return (collat_portion).add(frax_portion);
}
function dollarBalances() public view returns (uint256 frax_val_e18, uint256 collat_val_e18) {
frax_val_e18 = showAllocations()[3];
collat_val_e18 = collatDollarBalance();
}
function TotalLiquidityFrax() public view returns (uint256) {
uint256 frax_tally = 0;
Position memory thisPosition;
for (uint256 i = 0; i < positions_array.length; i++) {
thisPosition = positions_array[i];
uint128 this_liq = thisPosition.liquidity;
if (this_liq > 0){
uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(thisPosition.tickLower);
uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(thisPosition.tickUpper);
if (thisPosition.collateral_address > 0x853d955aCEf822Db058eb8505911ED77F175b99e){ // if address(FRAX) < collateral_address, then FRAX is token0
frax_tally = frax_tally.add(LiquidityAmounts.getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, this_liq));
}
else {
frax_tally = frax_tally.add(LiquidityAmounts.getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, this_liq));
}
}
}
// Return the sum of all the positions' balances of FRAX, if the price fell off the range towards that side
return frax_tally;
}
// Returns this contract's liquidity in a specific [FRAX]-[collateral] uni v3 pool
function liquidityInPool(address _collateral_address, int24 _tickLower, int24 _tickUpper, uint24 _fee) public view returns (uint128) {
IUniswapV3Pool get_pool = IUniswapV3Pool(univ3_factory.getPool(address(FRAX), _collateral_address, _fee));
// goes into the pool's positions mapping, and grabs this address's liquidity
(uint128 liquidity, , , , ) = get_pool.positions(keccak256(abi.encodePacked(address(this), _tickLower, _tickUpper)));
return liquidity;
}
// Backwards compatibility
function mintedBalance() public view returns (int256) {
return amo_minter.frax_mint_balances(address(this));
}
// Backwards compatibility
function collateralBalance() public view returns (int256) {
return amo_minter.collat_borrowed_balances(address(this));
}
// Only counts non-withdrawn positions
function numPositions() public view returns (uint256) {
return positions_array.length;
}
function allCollateralAddresses() external view returns (address[] memory) {
return collateral_addresses;
}
/* ========== RESTRICTED FUNCTIONS, BUT CUSTODIAN CAN CALL ========== */
// Iterate through all positions and collect fees accumulated
function collectFees() external onlyByOwnGovCust {
for (uint i = 0; i < positions_array.length; i++){
Position memory current_position = positions_array[i];
INonfungiblePositionManager.CollectParams memory collect_params = INonfungiblePositionManager.CollectParams(
current_position.token_id,
custodian_address,
type(uint128).max,
type(uint128).max
);
// Send to custodian address
univ3_positions.collect(collect_params);
}
}
/* ---------------------------------------------------- */
/* ---------------------- Uni v3 ---------------------- */
/* ---------------------------------------------------- */
function approveTarget(address _target, address _token, uint256 _amount, bool use_safe_approve) public onlyByOwnGov {
if (use_safe_approve) {
// safeApprove needed for USDT and others for the first approval
// You need to approve 0 every time beforehand for USDT: it resets
TransferHelper.safeApprove(_token, _target, _amount);
}
else {
ERC20(_token).approve(_target, _amount);
}
}
// IUniswapV3Pool public current_uni_pool; // only used for mint callback; is set and accessed during execution of addLiquidity()
function addLiquidity(address _tokenA, address _tokenB, int24 _tickLower, int24 _tickUpper, uint24 _fee, uint256 _amount0Desired, uint256 _amount1Desired, uint256 _amount0Min, uint256 _amount1Min) public onlyByOwnGov {
// Make sure the collateral is allowed
require(allowed_collaterals[_tokenA] || _tokenA == address(FRAX), "TokenA not allowed");
require(allowed_collaterals[_tokenB] || _tokenB == address(FRAX), "TokenB not allowed");
ERC20(_tokenA).transferFrom(msg.sender, address(this), _amount0Desired);
ERC20(_tokenB).transferFrom(msg.sender, address(this), _amount1Desired);
ERC20(_tokenA).approve(address(univ3_positions), _amount0Desired);
ERC20(_tokenB).approve(address(univ3_positions), _amount1Desired);
INonfungiblePositionManager.MintParams memory params = INonfungiblePositionManager.MintParams(
_tokenA,
_tokenB,
_fee,
_tickLower,
_tickUpper,
_amount0Desired,
_amount1Desired,
_amount0Min,
_amount1Min,
address(this),
block.timestamp
);
(uint256 tokenId, uint128 amountLiquidity,,) = univ3_positions.mint(params);
Position memory pos = Position(
tokenId,
_tokenA == address(FRAX) ? _tokenB : _tokenA,
amountLiquidity,
_tickLower,
_tickUpper,
_fee
);
positions_array.push(pos);
positions_mapping[tokenId] = pos;
}
/*
** burn tokenAmount from the recipient and send tokens to the receipient
*/
event log(uint);
function removeLiquidity(uint256 positionIndex) public onlyByOwnGov {
Position memory pos = positions_array[positionIndex];
INonfungiblePositionManager.CollectParams memory collect_params = INonfungiblePositionManager.CollectParams(
pos.token_id,
custodian_address,
type(uint128).max,
type(uint128).max
);
univ3_positions.collect(collect_params);
univ3_positions.burn(pos.token_id);
positions_array[positionIndex] = positions_array[positions_array.length -1];
positions_array.pop();
delete positions_mapping[pos.token_id];
emit log(positions_array.length);
emit log(positions_mapping[pos.token_id].token_id);
}
// Swap tokenA into tokenB using univ3_router.ExactInputSingle()
// Uni V3 only
function swap(address _tokenA, address _tokenB, uint24 _fee_tier, uint256 _amountAtoB, uint256 _amountOutMinimum, uint160 _sqrtPriceLimitX96) public onlyByOwnGov returns (uint256) {
// Make sure the collateral is allowed
require(allowed_collaterals[_tokenA] || _tokenA == address(FRAX), "TokenA not allowed");
require(allowed_collaterals[_tokenB] || _tokenB == address(FRAX), "TokenB not allowed");
ISwapRouter.ExactInputSingleParams memory swap_params = ISwapRouter.ExactInputSingleParams(
_tokenA,
_tokenB,
_fee_tier,
address(this),
2105300114, // Expiration: a long time from now
_amountAtoB,
_amountOutMinimum,
_sqrtPriceLimitX96
);
// Approval
TransferHelper.safeApprove(_tokenA, address(univ3_router), _amountAtoB);
uint256 amountOut = univ3_router.exactInputSingle(swap_params);
return amountOut;
}
/* ========== Burns and givebacks ========== */
// Give USDC profits back. Goes through the minter
function giveCollatBack(uint256 collat_amount) external onlyByOwnGovCust {
giveback_collateral.approve(address(amo_minter), collat_amount);
amo_minter.receiveCollatFromAMO(collat_amount);
}
// Burn unneeded or excess FRAX. Goes through the minter
function burnFRAX(uint256 frax_amount) public onlyByOwnGovCust {
FRAX.approve(address(amo_minter), frax_amount);
amo_minter.burnFraxFromAMO(frax_amount);
}
// Burn unneeded FXS. Goes through the minter
function burnFXS(uint256 fxs_amount) public onlyByOwnGovCust {
FXS.approve(address(amo_minter), fxs_amount);
amo_minter.burnFxsFromAMO(fxs_amount);
}
/* ========== OWNER / GOVERNANCE FUNCTIONS ONLY ========== */
// Only owner or timelock can call, to limit risk
// Adds collateral addresses supported. Needed to make sure dollarBalances is correct
function addCollateral(address collat_addr) public onlyByOwnGov {
require(collat_addr != address(0), "Zero address detected");
require(collat_addr != address(FRAX), "FRAX is not collateral");
require(allowed_collaterals[collat_addr] == false, "Address already exists");
allowed_collaterals[collat_addr] = true;
collateral_addresses.push(collat_addr);
}
// Adds oracle for collateral. Optional for 1usd pegged coins.
function addOracle(address collat_addr, address oracle) public onlyByOwnGov {
require(collat_addr != address(0), "Zero address detected");
require(collat_addr != address(FRAX), "FRAX is not collateral");
oracles[collat_addr] = OracleLike(oracle);
}
function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyByOwnGov {
// Can only be triggered by owner or governance, not custodian
// Tokens are sent to the custodian, as a sort of safeguard
TransferHelper.safeTransfer(tokenAddress, custodian_address, tokenAmount);
emit RecoveredERC20(tokenAddress, tokenAmount);
}
function recoverERC721(address tokenAddress, uint256 token_id) external onlyByOwnGov {
// Only the owner address can ever receive the recovery withdrawal
// INonfungiblePositionManager inherits IERC721 so the latter does not need to be imported
INonfungiblePositionManager(tokenAddress).safeTransferFrom( address(this), custodian_address, token_id);
emit RecoveredERC721(tokenAddress, token_id);
}
// Generic proxy
function execute(
address _to,
uint256 _value,
bytes calldata _data
) external onlyByOwnGov returns (bool, bytes memory) {
(bool success, bytes memory result) = _to.call{value:_value}(_data);
return (success, result);
}
/* ========== EVENTS ========== */
event RecoveredERC20(address token, uint256 amount);
event RecoveredERC721(address token, uint256 id);
} | collatDolarValue | function collatDolarValue(OracleLike oracle, uint256 balance) public view returns (uint256) {
if (address(oracle) == address(0)) return balance;
return balance.mul(oracle.read()).div(1 ether);
}
| // Convert collateral to dolar. If no oracle assumes pegged to 1USD. Both oracle, balance and return are E18 | LineComment | v0.8.6+commit.11564f7e | {
"func_code_index": [
4689,
4907
]
} | 797 |
||||
UniV3LiquidityAMO_V2 | contracts/Misc_AMOs/UniV3LiquidityAMO_V2.sol | 0xc91bb4b0696e3b48c0c501b4ce8e7244fc363a79 | Solidity | UniV3LiquidityAMO_V2 | contract UniV3LiquidityAMO_V2 is Owned {
using SafeMath for uint256;
using SafeERC20 for ERC20;
/* ========== STATE VARIABLES ========== */
// Core
FRAXStablecoin private FRAX;
FRAXShares private FXS;
IFraxAMOMinter private amo_minter;
ERC20 private giveback_collateral;
address public giveback_collateral_address;
uint256 public missing_decimals_giveback_collat;
address public timelock_address;
address public custodian_address;
// Uniswap v3
IUniswapV3Factory public univ3_factory;
INonfungiblePositionManager public univ3_positions;
ISwapRouter public univ3_router;
// Price constants
uint256 private constant PRICE_PRECISION = 1e6;
// Wildcat AMO
// Details about the AMO's uniswap positions
struct Position {
uint256 token_id;
address collateral_address;
uint128 liquidity; // the liquidity of the position
int24 tickLower; // the tick range of the position
int24 tickUpper;
uint24 fee_tier;
}
// Array of all Uni v3 NFT positions held by the AMO
Position[] public positions_array;
// List of all collaterals
address[] public collateral_addresses;
mapping(address => bool) public allowed_collaterals; // Mapping is also used for faster verification
mapping(address => OracleLike) public oracles; // Mapping of oracles (if oracle == address(0) the collateral is assumed to be pegged to 1usd)
// Map token_id to Position
mapping(uint256 => Position) public positions_mapping;
/* ========== CONSTRUCTOR ========== */
constructor(
address _creator_address,
address _giveback_collateral_address,
address _amo_minter_address
) Owned(_creator_address) {
FRAX = FRAXStablecoin(0x853d955aCEf822Db058eb8505911ED77F175b99e);
FXS = FRAXShares(0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0);
giveback_collateral_address = _giveback_collateral_address;
giveback_collateral = ERC20(_giveback_collateral_address);
missing_decimals_giveback_collat = uint(18).sub(giveback_collateral.decimals());
collateral_addresses.push(_giveback_collateral_address);
allowed_collaterals[_giveback_collateral_address] = true;
univ3_factory = IUniswapV3Factory(0x1F98431c8aD98523631AE4a59f267346ea31F984);
univ3_positions = INonfungiblePositionManager(0xC36442b4a4522E871399CD717aBDD847Ab11FE88);
univ3_router = ISwapRouter(0xE592427A0AEce92De3Edee1F18E0157C05861564);
// Initialize the minter
amo_minter = IFraxAMOMinter(_amo_minter_address);
// Get the custodian and timelock addresses from the minter
custodian_address = amo_minter.custodian_address();
timelock_address = amo_minter.timelock_address();
}
/* ========== MODIFIERS ========== */
modifier onlyByOwnGov() {
require(msg.sender == timelock_address || msg.sender == owner, "Not owner or timelock");
_;
}
modifier onlyByOwnGovCust() {
require(msg.sender == timelock_address || msg.sender == owner || msg.sender == custodian_address, "Not owner, tlck, or custd");
_;
}
modifier onlyByMinter() {
require(msg.sender == address(amo_minter), "Not minter");
_;
}
/* ========== VIEWS ========== */
function showAllocations() public view returns (uint256[4] memory allocations) {
// All numbers given are in FRAX unless otherwise stated
// Unallocated FRAX
allocations[0] = FRAX.balanceOf(address(this));
// Unallocated Collateral Dollar Value (E18)
allocations[1] = freeColDolVal();
// Sum of Uni v3 Positions liquidity, if it was all in FRAX
allocations[2] = TotalLiquidityFrax();
// Total Value
allocations[3] = allocations[0].add(allocations[1]).add(allocations[2]);
}
// E18 Collateral dollar value
function freeColDolVal() public view returns (uint256) {
uint256 value_tally_e18 = 0;
for (uint i = 0; i < collateral_addresses.length; i++){
ERC20 thisCollateral = ERC20(collateral_addresses[i]);
uint256 missing_decs = uint256(18).sub(thisCollateral.decimals());
uint256 col_bal_e18 = thisCollateral.balanceOf(address(this)).mul(10 ** missing_decs);
uint256 col_usd_value_e18 = collatDolarValue(oracles[collateral_addresses[i]], col_bal_e18);
value_tally_e18 = value_tally_e18.add(col_usd_value_e18);
}
return value_tally_e18;
}
// Convert collateral to dolar. If no oracle assumes pegged to 1USD. Both oracle, balance and return are E18
function collatDolarValue(OracleLike oracle, uint256 balance) public view returns (uint256) {
if (address(oracle) == address(0)) return balance;
return balance.mul(oracle.read()).div(1 ether);
}
// Needed for the Frax contract to function
function collatDollarBalance() public view returns (uint256) {
// Get the allocations
uint256[4] memory allocations = showAllocations();
// Get the collateral and FRAX portions
uint256 collat_portion = allocations[1];
uint256 frax_portion = (allocations[0]).add(allocations[2]);
// Assumes worst case scenario if FRAX slips out of range.
// Otherwise, it would only be half that is multiplied by the CR
frax_portion = frax_portion.mul(FRAX.global_collateral_ratio()).div(PRICE_PRECISION);
return (collat_portion).add(frax_portion);
}
function dollarBalances() public view returns (uint256 frax_val_e18, uint256 collat_val_e18) {
frax_val_e18 = showAllocations()[3];
collat_val_e18 = collatDollarBalance();
}
function TotalLiquidityFrax() public view returns (uint256) {
uint256 frax_tally = 0;
Position memory thisPosition;
for (uint256 i = 0; i < positions_array.length; i++) {
thisPosition = positions_array[i];
uint128 this_liq = thisPosition.liquidity;
if (this_liq > 0){
uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(thisPosition.tickLower);
uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(thisPosition.tickUpper);
if (thisPosition.collateral_address > 0x853d955aCEf822Db058eb8505911ED77F175b99e){ // if address(FRAX) < collateral_address, then FRAX is token0
frax_tally = frax_tally.add(LiquidityAmounts.getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, this_liq));
}
else {
frax_tally = frax_tally.add(LiquidityAmounts.getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, this_liq));
}
}
}
// Return the sum of all the positions' balances of FRAX, if the price fell off the range towards that side
return frax_tally;
}
// Returns this contract's liquidity in a specific [FRAX]-[collateral] uni v3 pool
function liquidityInPool(address _collateral_address, int24 _tickLower, int24 _tickUpper, uint24 _fee) public view returns (uint128) {
IUniswapV3Pool get_pool = IUniswapV3Pool(univ3_factory.getPool(address(FRAX), _collateral_address, _fee));
// goes into the pool's positions mapping, and grabs this address's liquidity
(uint128 liquidity, , , , ) = get_pool.positions(keccak256(abi.encodePacked(address(this), _tickLower, _tickUpper)));
return liquidity;
}
// Backwards compatibility
function mintedBalance() public view returns (int256) {
return amo_minter.frax_mint_balances(address(this));
}
// Backwards compatibility
function collateralBalance() public view returns (int256) {
return amo_minter.collat_borrowed_balances(address(this));
}
// Only counts non-withdrawn positions
function numPositions() public view returns (uint256) {
return positions_array.length;
}
function allCollateralAddresses() external view returns (address[] memory) {
return collateral_addresses;
}
/* ========== RESTRICTED FUNCTIONS, BUT CUSTODIAN CAN CALL ========== */
// Iterate through all positions and collect fees accumulated
function collectFees() external onlyByOwnGovCust {
for (uint i = 0; i < positions_array.length; i++){
Position memory current_position = positions_array[i];
INonfungiblePositionManager.CollectParams memory collect_params = INonfungiblePositionManager.CollectParams(
current_position.token_id,
custodian_address,
type(uint128).max,
type(uint128).max
);
// Send to custodian address
univ3_positions.collect(collect_params);
}
}
/* ---------------------------------------------------- */
/* ---------------------- Uni v3 ---------------------- */
/* ---------------------------------------------------- */
function approveTarget(address _target, address _token, uint256 _amount, bool use_safe_approve) public onlyByOwnGov {
if (use_safe_approve) {
// safeApprove needed for USDT and others for the first approval
// You need to approve 0 every time beforehand for USDT: it resets
TransferHelper.safeApprove(_token, _target, _amount);
}
else {
ERC20(_token).approve(_target, _amount);
}
}
// IUniswapV3Pool public current_uni_pool; // only used for mint callback; is set and accessed during execution of addLiquidity()
function addLiquidity(address _tokenA, address _tokenB, int24 _tickLower, int24 _tickUpper, uint24 _fee, uint256 _amount0Desired, uint256 _amount1Desired, uint256 _amount0Min, uint256 _amount1Min) public onlyByOwnGov {
// Make sure the collateral is allowed
require(allowed_collaterals[_tokenA] || _tokenA == address(FRAX), "TokenA not allowed");
require(allowed_collaterals[_tokenB] || _tokenB == address(FRAX), "TokenB not allowed");
ERC20(_tokenA).transferFrom(msg.sender, address(this), _amount0Desired);
ERC20(_tokenB).transferFrom(msg.sender, address(this), _amount1Desired);
ERC20(_tokenA).approve(address(univ3_positions), _amount0Desired);
ERC20(_tokenB).approve(address(univ3_positions), _amount1Desired);
INonfungiblePositionManager.MintParams memory params = INonfungiblePositionManager.MintParams(
_tokenA,
_tokenB,
_fee,
_tickLower,
_tickUpper,
_amount0Desired,
_amount1Desired,
_amount0Min,
_amount1Min,
address(this),
block.timestamp
);
(uint256 tokenId, uint128 amountLiquidity,,) = univ3_positions.mint(params);
Position memory pos = Position(
tokenId,
_tokenA == address(FRAX) ? _tokenB : _tokenA,
amountLiquidity,
_tickLower,
_tickUpper,
_fee
);
positions_array.push(pos);
positions_mapping[tokenId] = pos;
}
/*
** burn tokenAmount from the recipient and send tokens to the receipient
*/
event log(uint);
function removeLiquidity(uint256 positionIndex) public onlyByOwnGov {
Position memory pos = positions_array[positionIndex];
INonfungiblePositionManager.CollectParams memory collect_params = INonfungiblePositionManager.CollectParams(
pos.token_id,
custodian_address,
type(uint128).max,
type(uint128).max
);
univ3_positions.collect(collect_params);
univ3_positions.burn(pos.token_id);
positions_array[positionIndex] = positions_array[positions_array.length -1];
positions_array.pop();
delete positions_mapping[pos.token_id];
emit log(positions_array.length);
emit log(positions_mapping[pos.token_id].token_id);
}
// Swap tokenA into tokenB using univ3_router.ExactInputSingle()
// Uni V3 only
function swap(address _tokenA, address _tokenB, uint24 _fee_tier, uint256 _amountAtoB, uint256 _amountOutMinimum, uint160 _sqrtPriceLimitX96) public onlyByOwnGov returns (uint256) {
// Make sure the collateral is allowed
require(allowed_collaterals[_tokenA] || _tokenA == address(FRAX), "TokenA not allowed");
require(allowed_collaterals[_tokenB] || _tokenB == address(FRAX), "TokenB not allowed");
ISwapRouter.ExactInputSingleParams memory swap_params = ISwapRouter.ExactInputSingleParams(
_tokenA,
_tokenB,
_fee_tier,
address(this),
2105300114, // Expiration: a long time from now
_amountAtoB,
_amountOutMinimum,
_sqrtPriceLimitX96
);
// Approval
TransferHelper.safeApprove(_tokenA, address(univ3_router), _amountAtoB);
uint256 amountOut = univ3_router.exactInputSingle(swap_params);
return amountOut;
}
/* ========== Burns and givebacks ========== */
// Give USDC profits back. Goes through the minter
function giveCollatBack(uint256 collat_amount) external onlyByOwnGovCust {
giveback_collateral.approve(address(amo_minter), collat_amount);
amo_minter.receiveCollatFromAMO(collat_amount);
}
// Burn unneeded or excess FRAX. Goes through the minter
function burnFRAX(uint256 frax_amount) public onlyByOwnGovCust {
FRAX.approve(address(amo_minter), frax_amount);
amo_minter.burnFraxFromAMO(frax_amount);
}
// Burn unneeded FXS. Goes through the minter
function burnFXS(uint256 fxs_amount) public onlyByOwnGovCust {
FXS.approve(address(amo_minter), fxs_amount);
amo_minter.burnFxsFromAMO(fxs_amount);
}
/* ========== OWNER / GOVERNANCE FUNCTIONS ONLY ========== */
// Only owner or timelock can call, to limit risk
// Adds collateral addresses supported. Needed to make sure dollarBalances is correct
function addCollateral(address collat_addr) public onlyByOwnGov {
require(collat_addr != address(0), "Zero address detected");
require(collat_addr != address(FRAX), "FRAX is not collateral");
require(allowed_collaterals[collat_addr] == false, "Address already exists");
allowed_collaterals[collat_addr] = true;
collateral_addresses.push(collat_addr);
}
// Adds oracle for collateral. Optional for 1usd pegged coins.
function addOracle(address collat_addr, address oracle) public onlyByOwnGov {
require(collat_addr != address(0), "Zero address detected");
require(collat_addr != address(FRAX), "FRAX is not collateral");
oracles[collat_addr] = OracleLike(oracle);
}
function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyByOwnGov {
// Can only be triggered by owner or governance, not custodian
// Tokens are sent to the custodian, as a sort of safeguard
TransferHelper.safeTransfer(tokenAddress, custodian_address, tokenAmount);
emit RecoveredERC20(tokenAddress, tokenAmount);
}
function recoverERC721(address tokenAddress, uint256 token_id) external onlyByOwnGov {
// Only the owner address can ever receive the recovery withdrawal
// INonfungiblePositionManager inherits IERC721 so the latter does not need to be imported
INonfungiblePositionManager(tokenAddress).safeTransferFrom( address(this), custodian_address, token_id);
emit RecoveredERC721(tokenAddress, token_id);
}
// Generic proxy
function execute(
address _to,
uint256 _value,
bytes calldata _data
) external onlyByOwnGov returns (bool, bytes memory) {
(bool success, bytes memory result) = _to.call{value:_value}(_data);
return (success, result);
}
/* ========== EVENTS ========== */
event RecoveredERC20(address token, uint256 amount);
event RecoveredERC721(address token, uint256 id);
} | collatDollarBalance | function collatDollarBalance() public view returns (uint256) {
// Get the allocations
uint256[4] memory allocations = showAllocations();
// Get the collateral and FRAX portions
uint256 collat_portion = allocations[1];
uint256 frax_portion = (allocations[0]).add(allocations[2]);
// Assumes worst case scenario if FRAX slips out of range.
// Otherwise, it would only be half that is multiplied by the CR
frax_portion = frax_portion.mul(FRAX.global_collateral_ratio()).div(PRICE_PRECISION);
return (collat_portion).add(frax_portion);
}
| // Needed for the Frax contract to function | LineComment | v0.8.6+commit.11564f7e | {
"func_code_index": [
4957,
5572
]
} | 798 |
||||
UniV3LiquidityAMO_V2 | contracts/Misc_AMOs/UniV3LiquidityAMO_V2.sol | 0xc91bb4b0696e3b48c0c501b4ce8e7244fc363a79 | Solidity | UniV3LiquidityAMO_V2 | contract UniV3LiquidityAMO_V2 is Owned {
using SafeMath for uint256;
using SafeERC20 for ERC20;
/* ========== STATE VARIABLES ========== */
// Core
FRAXStablecoin private FRAX;
FRAXShares private FXS;
IFraxAMOMinter private amo_minter;
ERC20 private giveback_collateral;
address public giveback_collateral_address;
uint256 public missing_decimals_giveback_collat;
address public timelock_address;
address public custodian_address;
// Uniswap v3
IUniswapV3Factory public univ3_factory;
INonfungiblePositionManager public univ3_positions;
ISwapRouter public univ3_router;
// Price constants
uint256 private constant PRICE_PRECISION = 1e6;
// Wildcat AMO
// Details about the AMO's uniswap positions
struct Position {
uint256 token_id;
address collateral_address;
uint128 liquidity; // the liquidity of the position
int24 tickLower; // the tick range of the position
int24 tickUpper;
uint24 fee_tier;
}
// Array of all Uni v3 NFT positions held by the AMO
Position[] public positions_array;
// List of all collaterals
address[] public collateral_addresses;
mapping(address => bool) public allowed_collaterals; // Mapping is also used for faster verification
mapping(address => OracleLike) public oracles; // Mapping of oracles (if oracle == address(0) the collateral is assumed to be pegged to 1usd)
// Map token_id to Position
mapping(uint256 => Position) public positions_mapping;
/* ========== CONSTRUCTOR ========== */
constructor(
address _creator_address,
address _giveback_collateral_address,
address _amo_minter_address
) Owned(_creator_address) {
FRAX = FRAXStablecoin(0x853d955aCEf822Db058eb8505911ED77F175b99e);
FXS = FRAXShares(0x3432B6A60D23Ca0dFCa7761B7ab56459D9C964D0);
giveback_collateral_address = _giveback_collateral_address;
giveback_collateral = ERC20(_giveback_collateral_address);
missing_decimals_giveback_collat = uint(18).sub(giveback_collateral.decimals());
collateral_addresses.push(_giveback_collateral_address);
allowed_collaterals[_giveback_collateral_address] = true;
univ3_factory = IUniswapV3Factory(0x1F98431c8aD98523631AE4a59f267346ea31F984);
univ3_positions = INonfungiblePositionManager(0xC36442b4a4522E871399CD717aBDD847Ab11FE88);
univ3_router = ISwapRouter(0xE592427A0AEce92De3Edee1F18E0157C05861564);
// Initialize the minter
amo_minter = IFraxAMOMinter(_amo_minter_address);
// Get the custodian and timelock addresses from the minter
custodian_address = amo_minter.custodian_address();
timelock_address = amo_minter.timelock_address();
}
/* ========== MODIFIERS ========== */
modifier onlyByOwnGov() {
require(msg.sender == timelock_address || msg.sender == owner, "Not owner or timelock");
_;
}
modifier onlyByOwnGovCust() {
require(msg.sender == timelock_address || msg.sender == owner || msg.sender == custodian_address, "Not owner, tlck, or custd");
_;
}
modifier onlyByMinter() {
require(msg.sender == address(amo_minter), "Not minter");
_;
}
/* ========== VIEWS ========== */
function showAllocations() public view returns (uint256[4] memory allocations) {
// All numbers given are in FRAX unless otherwise stated
// Unallocated FRAX
allocations[0] = FRAX.balanceOf(address(this));
// Unallocated Collateral Dollar Value (E18)
allocations[1] = freeColDolVal();
// Sum of Uni v3 Positions liquidity, if it was all in FRAX
allocations[2] = TotalLiquidityFrax();
// Total Value
allocations[3] = allocations[0].add(allocations[1]).add(allocations[2]);
}
// E18 Collateral dollar value
function freeColDolVal() public view returns (uint256) {
uint256 value_tally_e18 = 0;
for (uint i = 0; i < collateral_addresses.length; i++){
ERC20 thisCollateral = ERC20(collateral_addresses[i]);
uint256 missing_decs = uint256(18).sub(thisCollateral.decimals());
uint256 col_bal_e18 = thisCollateral.balanceOf(address(this)).mul(10 ** missing_decs);
uint256 col_usd_value_e18 = collatDolarValue(oracles[collateral_addresses[i]], col_bal_e18);
value_tally_e18 = value_tally_e18.add(col_usd_value_e18);
}
return value_tally_e18;
}
// Convert collateral to dolar. If no oracle assumes pegged to 1USD. Both oracle, balance and return are E18
function collatDolarValue(OracleLike oracle, uint256 balance) public view returns (uint256) {
if (address(oracle) == address(0)) return balance;
return balance.mul(oracle.read()).div(1 ether);
}
// Needed for the Frax contract to function
function collatDollarBalance() public view returns (uint256) {
// Get the allocations
uint256[4] memory allocations = showAllocations();
// Get the collateral and FRAX portions
uint256 collat_portion = allocations[1];
uint256 frax_portion = (allocations[0]).add(allocations[2]);
// Assumes worst case scenario if FRAX slips out of range.
// Otherwise, it would only be half that is multiplied by the CR
frax_portion = frax_portion.mul(FRAX.global_collateral_ratio()).div(PRICE_PRECISION);
return (collat_portion).add(frax_portion);
}
function dollarBalances() public view returns (uint256 frax_val_e18, uint256 collat_val_e18) {
frax_val_e18 = showAllocations()[3];
collat_val_e18 = collatDollarBalance();
}
function TotalLiquidityFrax() public view returns (uint256) {
uint256 frax_tally = 0;
Position memory thisPosition;
for (uint256 i = 0; i < positions_array.length; i++) {
thisPosition = positions_array[i];
uint128 this_liq = thisPosition.liquidity;
if (this_liq > 0){
uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(thisPosition.tickLower);
uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(thisPosition.tickUpper);
if (thisPosition.collateral_address > 0x853d955aCEf822Db058eb8505911ED77F175b99e){ // if address(FRAX) < collateral_address, then FRAX is token0
frax_tally = frax_tally.add(LiquidityAmounts.getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, this_liq));
}
else {
frax_tally = frax_tally.add(LiquidityAmounts.getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, this_liq));
}
}
}
// Return the sum of all the positions' balances of FRAX, if the price fell off the range towards that side
return frax_tally;
}
// Returns this contract's liquidity in a specific [FRAX]-[collateral] uni v3 pool
function liquidityInPool(address _collateral_address, int24 _tickLower, int24 _tickUpper, uint24 _fee) public view returns (uint128) {
IUniswapV3Pool get_pool = IUniswapV3Pool(univ3_factory.getPool(address(FRAX), _collateral_address, _fee));
// goes into the pool's positions mapping, and grabs this address's liquidity
(uint128 liquidity, , , , ) = get_pool.positions(keccak256(abi.encodePacked(address(this), _tickLower, _tickUpper)));
return liquidity;
}
// Backwards compatibility
function mintedBalance() public view returns (int256) {
return amo_minter.frax_mint_balances(address(this));
}
// Backwards compatibility
function collateralBalance() public view returns (int256) {
return amo_minter.collat_borrowed_balances(address(this));
}
// Only counts non-withdrawn positions
function numPositions() public view returns (uint256) {
return positions_array.length;
}
function allCollateralAddresses() external view returns (address[] memory) {
return collateral_addresses;
}
/* ========== RESTRICTED FUNCTIONS, BUT CUSTODIAN CAN CALL ========== */
// Iterate through all positions and collect fees accumulated
function collectFees() external onlyByOwnGovCust {
for (uint i = 0; i < positions_array.length; i++){
Position memory current_position = positions_array[i];
INonfungiblePositionManager.CollectParams memory collect_params = INonfungiblePositionManager.CollectParams(
current_position.token_id,
custodian_address,
type(uint128).max,
type(uint128).max
);
// Send to custodian address
univ3_positions.collect(collect_params);
}
}
/* ---------------------------------------------------- */
/* ---------------------- Uni v3 ---------------------- */
/* ---------------------------------------------------- */
function approveTarget(address _target, address _token, uint256 _amount, bool use_safe_approve) public onlyByOwnGov {
if (use_safe_approve) {
// safeApprove needed for USDT and others for the first approval
// You need to approve 0 every time beforehand for USDT: it resets
TransferHelper.safeApprove(_token, _target, _amount);
}
else {
ERC20(_token).approve(_target, _amount);
}
}
// IUniswapV3Pool public current_uni_pool; // only used for mint callback; is set and accessed during execution of addLiquidity()
function addLiquidity(address _tokenA, address _tokenB, int24 _tickLower, int24 _tickUpper, uint24 _fee, uint256 _amount0Desired, uint256 _amount1Desired, uint256 _amount0Min, uint256 _amount1Min) public onlyByOwnGov {
// Make sure the collateral is allowed
require(allowed_collaterals[_tokenA] || _tokenA == address(FRAX), "TokenA not allowed");
require(allowed_collaterals[_tokenB] || _tokenB == address(FRAX), "TokenB not allowed");
ERC20(_tokenA).transferFrom(msg.sender, address(this), _amount0Desired);
ERC20(_tokenB).transferFrom(msg.sender, address(this), _amount1Desired);
ERC20(_tokenA).approve(address(univ3_positions), _amount0Desired);
ERC20(_tokenB).approve(address(univ3_positions), _amount1Desired);
INonfungiblePositionManager.MintParams memory params = INonfungiblePositionManager.MintParams(
_tokenA,
_tokenB,
_fee,
_tickLower,
_tickUpper,
_amount0Desired,
_amount1Desired,
_amount0Min,
_amount1Min,
address(this),
block.timestamp
);
(uint256 tokenId, uint128 amountLiquidity,,) = univ3_positions.mint(params);
Position memory pos = Position(
tokenId,
_tokenA == address(FRAX) ? _tokenB : _tokenA,
amountLiquidity,
_tickLower,
_tickUpper,
_fee
);
positions_array.push(pos);
positions_mapping[tokenId] = pos;
}
/*
** burn tokenAmount from the recipient and send tokens to the receipient
*/
event log(uint);
function removeLiquidity(uint256 positionIndex) public onlyByOwnGov {
Position memory pos = positions_array[positionIndex];
INonfungiblePositionManager.CollectParams memory collect_params = INonfungiblePositionManager.CollectParams(
pos.token_id,
custodian_address,
type(uint128).max,
type(uint128).max
);
univ3_positions.collect(collect_params);
univ3_positions.burn(pos.token_id);
positions_array[positionIndex] = positions_array[positions_array.length -1];
positions_array.pop();
delete positions_mapping[pos.token_id];
emit log(positions_array.length);
emit log(positions_mapping[pos.token_id].token_id);
}
// Swap tokenA into tokenB using univ3_router.ExactInputSingle()
// Uni V3 only
function swap(address _tokenA, address _tokenB, uint24 _fee_tier, uint256 _amountAtoB, uint256 _amountOutMinimum, uint160 _sqrtPriceLimitX96) public onlyByOwnGov returns (uint256) {
// Make sure the collateral is allowed
require(allowed_collaterals[_tokenA] || _tokenA == address(FRAX), "TokenA not allowed");
require(allowed_collaterals[_tokenB] || _tokenB == address(FRAX), "TokenB not allowed");
ISwapRouter.ExactInputSingleParams memory swap_params = ISwapRouter.ExactInputSingleParams(
_tokenA,
_tokenB,
_fee_tier,
address(this),
2105300114, // Expiration: a long time from now
_amountAtoB,
_amountOutMinimum,
_sqrtPriceLimitX96
);
// Approval
TransferHelper.safeApprove(_tokenA, address(univ3_router), _amountAtoB);
uint256 amountOut = univ3_router.exactInputSingle(swap_params);
return amountOut;
}
/* ========== Burns and givebacks ========== */
// Give USDC profits back. Goes through the minter
function giveCollatBack(uint256 collat_amount) external onlyByOwnGovCust {
giveback_collateral.approve(address(amo_minter), collat_amount);
amo_minter.receiveCollatFromAMO(collat_amount);
}
// Burn unneeded or excess FRAX. Goes through the minter
function burnFRAX(uint256 frax_amount) public onlyByOwnGovCust {
FRAX.approve(address(amo_minter), frax_amount);
amo_minter.burnFraxFromAMO(frax_amount);
}
// Burn unneeded FXS. Goes through the minter
function burnFXS(uint256 fxs_amount) public onlyByOwnGovCust {
FXS.approve(address(amo_minter), fxs_amount);
amo_minter.burnFxsFromAMO(fxs_amount);
}
/* ========== OWNER / GOVERNANCE FUNCTIONS ONLY ========== */
// Only owner or timelock can call, to limit risk
// Adds collateral addresses supported. Needed to make sure dollarBalances is correct
function addCollateral(address collat_addr) public onlyByOwnGov {
require(collat_addr != address(0), "Zero address detected");
require(collat_addr != address(FRAX), "FRAX is not collateral");
require(allowed_collaterals[collat_addr] == false, "Address already exists");
allowed_collaterals[collat_addr] = true;
collateral_addresses.push(collat_addr);
}
// Adds oracle for collateral. Optional for 1usd pegged coins.
function addOracle(address collat_addr, address oracle) public onlyByOwnGov {
require(collat_addr != address(0), "Zero address detected");
require(collat_addr != address(FRAX), "FRAX is not collateral");
oracles[collat_addr] = OracleLike(oracle);
}
function recoverERC20(address tokenAddress, uint256 tokenAmount) external onlyByOwnGov {
// Can only be triggered by owner or governance, not custodian
// Tokens are sent to the custodian, as a sort of safeguard
TransferHelper.safeTransfer(tokenAddress, custodian_address, tokenAmount);
emit RecoveredERC20(tokenAddress, tokenAmount);
}
function recoverERC721(address tokenAddress, uint256 token_id) external onlyByOwnGov {
// Only the owner address can ever receive the recovery withdrawal
// INonfungiblePositionManager inherits IERC721 so the latter does not need to be imported
INonfungiblePositionManager(tokenAddress).safeTransferFrom( address(this), custodian_address, token_id);
emit RecoveredERC721(tokenAddress, token_id);
}
// Generic proxy
function execute(
address _to,
uint256 _value,
bytes calldata _data
) external onlyByOwnGov returns (bool, bytes memory) {
(bool success, bytes memory result) = _to.call{value:_value}(_data);
return (success, result);
}
/* ========== EVENTS ========== */
event RecoveredERC20(address token, uint256 amount);
event RecoveredERC721(address token, uint256 id);
} | liquidityInPool | function liquidityInPool(address _collateral_address, int24 _tickLower, int24 _tickUpper, uint24 _fee) public view returns (uint128) {
IUniswapV3Pool get_pool = IUniswapV3Pool(univ3_factory.getPool(address(FRAX), _collateral_address, _fee));
// goes into the pool's positions mapping, and grabs this address's liquidity
(uint128 liquidity, , , , ) = get_pool.positions(keccak256(abi.encodePacked(address(this), _tickLower, _tickUpper)));
return liquidity;
}
| // Returns this contract's liquidity in a specific [FRAX]-[collateral] uni v3 pool | LineComment | v0.8.6+commit.11564f7e | {
"func_code_index": [
7033,
7531
]
} | 799 |