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
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
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); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
allowance
function allowance(address owner, address spender) external view returns (uint256);
/** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */
NatSpecMultiLine
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 879, 967 ] }
3,700
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
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); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
approve
function approve(address spender, uint256 amount) external returns (bool);
/** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */
NatSpecMultiLine
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 1618, 1697 ] }
3,701
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
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); }
/** * @dev Interface of the ERC20 standard as defined in the EIP. */
NatSpecMultiLine
transferFrom
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */
NatSpecMultiLine
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 2002, 2104 ] }
3,702
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
/** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */
NatSpecMultiLine
tryAdd
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } }
/** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */
NatSpecMultiLine
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 157, 384 ] }
3,703
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
/** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */
NatSpecMultiLine
trySub
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } }
/** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */
NatSpecMultiLine
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 528, 727 ] }
3,704
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
/** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */
NatSpecMultiLine
tryMul
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } }
/** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */
NatSpecMultiLine
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 873, 1381 ] }
3,705
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
/** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */
NatSpecMultiLine
tryDiv
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } }
/** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */
NatSpecMultiLine
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 1528, 1728 ] }
3,706
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
/** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */
NatSpecMultiLine
tryMod
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } }
/** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */
NatSpecMultiLine
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 1885, 2085 ] }
3,707
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
/** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */
NatSpecMultiLine
add
function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; }
/** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */
NatSpecMultiLine
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 2318, 2421 ] }
3,708
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
/** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */
NatSpecMultiLine
mod
function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; }
/** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */
NatSpecMultiLine
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 3193, 3296 ] }
3,709
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
/** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */
NatSpecMultiLine
sub
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } }
/** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */
NatSpecMultiLine
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 3758, 3969 ] }
3,710
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
/** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */
NatSpecMultiLine
div
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } }
/** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */
NatSpecMultiLine
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 4674, 4884 ] }
3,711
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
Solidity
SafeMath
library SafeMath { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the substraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
/** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is no longer needed starting with Solidity 0.8. The compiler * now has built in overflow checking. */
NatSpecMultiLine
mod
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } }
/** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */
NatSpecMultiLine
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 5528, 5738 ] }
3,712
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
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) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
isContract
function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; }
/** * @dev 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.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 590, 1017 ] }
3,713
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
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) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
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.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 1932, 2334 ] }
3,714
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
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) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
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.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 3073, 3251 ] }
3,715
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
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) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
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.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 3471, 3671 ] }
3,716
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
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) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
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.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 4031, 4262 ] }
3,717
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
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) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
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"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); }
/** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */
NatSpecMultiLine
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 4508, 5043 ] }
3,718
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
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) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionStaticCall
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); }
/** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */
NatSpecMultiLine
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 5218, 5422 ] }
3,719
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
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) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionStaticCall
function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); }
/** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */
NatSpecMultiLine
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 5604, 6031 ] }
3,720
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
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) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionDelegateCall
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); }
/** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */
NatSpecMultiLine
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 6208, 6413 ] }
3,721
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
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) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: value }(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.staticcall(data); return _verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); } function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
/** * @dev Collection of functions related to the address type */
NatSpecMultiLine
functionDelegateCall
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.delegatecall(data); return _verifyCallResult(success, returndata, errorMessage); }
/** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */
NatSpecMultiLine
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 6597, 7025 ] }
3,722
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
Solidity
Ownable
abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { _owner = _msgSender(); emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */
NatSpecMultiLine
owner
function owner() public view virtual returns (address) { return _owner; }
/** * @dev Returns the address of the current owner. */
NatSpecMultiLine
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 450, 542 ] }
3,723
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
Solidity
Ownable
abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { _owner = _msgSender(); emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */
NatSpecMultiLine
renounceOwnership
function renounceOwnership() public virtual onlyOwner { 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.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 1093, 1246 ] }
3,724
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
Solidity
Ownable
abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor () { _owner = _msgSender(); emit OwnershipTransferred(address(0), _owner); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(owner() == _msgSender(), "Ownable: caller is not the owner"); _; } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { emit OwnershipTransferred(_owner, address(0)); _owner = address(0); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; } }
/** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */
NatSpecMultiLine
transferOwnership
function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); 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.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 1393, 1642 ] }
3,725
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
Solidity
SushiInu
contract SushiInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; uint8 private _decimals = 9; // string private _name = "SUSHI INU"; string private _symbol = "SUSHIINU"; uint256 private _tTotal = 1000 * 10**9 * 10**uint256(_decimals); // % to holders uint256 public defaultTaxFee = 3; uint256 public _taxFee = defaultTaxFee; uint256 private _previousTaxFee = _taxFee; // % to swap & send to marketing wallet uint256 public defaultMarketingFee = 7; uint256 public _marketingFee = defaultMarketingFee; uint256 private _previousMarketingFee = _marketingFee; uint256 public _marketingFee4Sellers = 7; bool public feesOnSellersAndBuyers = true; uint256 public _maxTxAmount = _tTotal.div(1).div(49); uint256 public numTokensToExchangeForMarketing = _tTotal.div(100).div(100); address payable public marketingWallet = payable(0x92341Eda873157B8d1809763a815E71185ce3328); // mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; mapping (address => bool) public _isBlacklisted; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tFeeTotal; uint256 private _rTotal = (MAX - (MAX % _tTotal)); IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndSend; bool public SwapAndSendEnabled = true; event SwapAndSendEnabledUpdated(bool enabled); modifier lockTheSwap { inSwapAndSend = true; _; inSwapAndSend = false; } constructor () { _rOwned[_msgSender()] = _rTotal; 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; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function excludeFromFee(address account) public onlyOwner() { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner() { _isExcludedFromFee[account] = false; } function removeAllFee() private { if(_taxFee == 0 && _marketingFee == 0) return; _previousTaxFee = _taxFee; _previousMarketingFee = _marketingFee; _taxFee = 0; _marketingFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _marketingFee = _previousMarketingFee; } //to recieve ETH receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function addToBlackList(address[] calldata addresses) external onlyOwner { for (uint256 i; i < addresses.length; ++i) { _isBlacklisted[addresses[i]] = true; } } function removeFromBlackList(address account) external onlyOwner { _isBlacklisted[account] = false; } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tMarketing, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tMarketing); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tMarketing = calculateMarketingFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tMarketing); return (tTransferAmount, tFee, tMarketing); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tMarketing, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rMarketing = tMarketing.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rMarketing); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _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 calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateMarketingFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_marketingFee).div( 10**2 ); } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); require(!_isBlacklisted[from] && !_isBlacklisted[to], "This address is blacklisted"); if(from != owner() && to != 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 + send lock? // also, don't get caught in a circular sending event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); bool overMinTokenBalance = contractTokenBalance >= numTokensToExchangeForMarketing; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if ( overMinTokenBalance && !inSwapAndSend && from != uniswapV2Pair && SwapAndSendEnabled ) { SwapAndSend(contractTokenBalance); } if(feesOnSellersAndBuyers) { setFees(to); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } function setFees(address recipient) private { _taxFee = defaultTaxFee; _marketingFee = defaultMarketingFee; if (recipient == uniswapV2Pair) { // sell _marketingFee = _marketingFee4Sellers; } } function SwapAndSend(uint256 contractTokenBalance) 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), contractTokenBalance); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( contractTokenBalance, 0, // accept any amount of ETH path, address(this), block.timestamp ); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { marketingWallet.transfer(contractETHBalance); } } //this method is responsible for taking all fee, if takeFee is true 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 setDefaultMarketingFee(uint256 marketingFee) external onlyOwner() { defaultMarketingFee = marketingFee; } function setMarketingFee4Sellers(uint256 marketingFee4Sellers) external onlyOwner() { _marketingFee4Sellers = marketingFee4Sellers; } function setFeesOnSellersAndBuyers(bool _enabled) public onlyOwner() { feesOnSellersAndBuyers = _enabled; } function setSwapAndSendEnabled(bool _enabled) public onlyOwner() { SwapAndSendEnabled = _enabled; emit SwapAndSendEnabledUpdated(_enabled); } function setnumTokensToExchangeForMarketing(uint256 _numTokensToExchangeForMarketing) public onlyOwner() { numTokensToExchangeForMarketing = _numTokensToExchangeForMarketing; } function _setMarketingWallet(address payable wallet) external onlyOwner() { marketingWallet = wallet; } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } }
//to recieve ETH
LineComment
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 7002, 7036 ] }
3,726
SushiInu
SushiInu.sol
0x54c137667c11c26d13c7bbb7fbfa8b7c50f181a4
Solidity
SushiInu
contract SushiInu is Context, IERC20, Ownable { using SafeMath for uint256; using Address for address; uint8 private _decimals = 9; // string private _name = "SUSHI INU"; string private _symbol = "SUSHIINU"; uint256 private _tTotal = 1000 * 10**9 * 10**uint256(_decimals); // % to holders uint256 public defaultTaxFee = 3; uint256 public _taxFee = defaultTaxFee; uint256 private _previousTaxFee = _taxFee; // % to swap & send to marketing wallet uint256 public defaultMarketingFee = 7; uint256 public _marketingFee = defaultMarketingFee; uint256 private _previousMarketingFee = _marketingFee; uint256 public _marketingFee4Sellers = 7; bool public feesOnSellersAndBuyers = true; uint256 public _maxTxAmount = _tTotal.div(1).div(49); uint256 public numTokensToExchangeForMarketing = _tTotal.div(100).div(100); address payable public marketingWallet = payable(0x92341Eda873157B8d1809763a815E71185ce3328); // mapping (address => uint256) private _rOwned; mapping (address => uint256) private _tOwned; mapping (address => mapping (address => uint256)) private _allowances; mapping (address => bool) private _isExcludedFromFee; mapping (address => bool) private _isExcluded; mapping (address => bool) public _isBlacklisted; address[] private _excluded; uint256 private constant MAX = ~uint256(0); uint256 private _tFeeTotal; uint256 private _rTotal = (MAX - (MAX % _tTotal)); IUniswapV2Router02 public immutable uniswapV2Router; address public immutable uniswapV2Pair; bool inSwapAndSend; bool public SwapAndSendEnabled = true; event SwapAndSendEnabledUpdated(bool enabled); modifier lockTheSwap { inSwapAndSend = true; _; inSwapAndSend = false; } constructor () { _rOwned[_msgSender()] = _rTotal; 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; emit Transfer(address(0), _msgSender(), _tTotal); } function name() public view returns (string memory) { return _name; } function symbol() public view returns (string memory) { return _symbol; } function decimals() public view returns (uint8) { return _decimals; } function totalSupply() public view override returns (uint256) { return _tTotal; } function balanceOf(address account) public view override returns (uint256) { if (_isExcluded[account]) return _tOwned[account]; return tokenFromReflection(_rOwned[account]); } function transfer(address recipient, uint256 amount) public override returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } function allowance(address owner, address spender) public view override returns (uint256) { return _allowances[owner][spender]; } function approve(address spender, uint256 amount) public override returns (bool) { _approve(_msgSender(), spender, amount); return true; } function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; } function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } function isExcludedFromReward(address account) public view returns (bool) { return _isExcluded[account]; } function totalFees() public view returns (uint256) { return _tFeeTotal; } function reflectionFromToken(uint256 tAmount, bool deductTransferFee) public view returns(uint256) { require(tAmount <= _tTotal, "Amount must be less than supply"); if (!deductTransferFee) { (uint256 rAmount,,,,,) = _getValues(tAmount); return rAmount; } else { (,uint256 rTransferAmount,,,,) = _getValues(tAmount); return rTransferAmount; } } function tokenFromReflection(uint256 rAmount) public view returns(uint256) { require(rAmount <= _rTotal, "Amount must be less than total reflections"); uint256 currentRate = _getRate(); return rAmount.div(currentRate); } function excludeFromReward(address account) public onlyOwner() { // require(account != 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D, 'We can not exclude Uniswap router.'); require(!_isExcluded[account], "Account is already excluded"); if(_rOwned[account] > 0) { _tOwned[account] = tokenFromReflection(_rOwned[account]); } _isExcluded[account] = true; _excluded.push(account); } function includeInReward(address account) external onlyOwner() { require(_isExcluded[account], "Account is already excluded"); for (uint256 i = 0; i < _excluded.length; i++) { if (_excluded[i] == account) { _excluded[i] = _excluded[_excluded.length - 1]; _tOwned[account] = 0; _isExcluded[account] = false; _excluded.pop(); break; } } } function excludeFromFee(address account) public onlyOwner() { _isExcludedFromFee[account] = true; } function includeInFee(address account) public onlyOwner() { _isExcludedFromFee[account] = false; } function removeAllFee() private { if(_taxFee == 0 && _marketingFee == 0) return; _previousTaxFee = _taxFee; _previousMarketingFee = _marketingFee; _taxFee = 0; _marketingFee = 0; } function restoreAllFee() private { _taxFee = _previousTaxFee; _marketingFee = _previousMarketingFee; } //to recieve ETH receive() external payable {} function _reflectFee(uint256 rFee, uint256 tFee) private { _rTotal = _rTotal.sub(rFee); _tFeeTotal = _tFeeTotal.add(tFee); } function addToBlackList(address[] calldata addresses) external onlyOwner { for (uint256 i; i < addresses.length; ++i) { _isBlacklisted[addresses[i]] = true; } } function removeFromBlackList(address account) external onlyOwner { _isBlacklisted[account] = false; } function _getValues(uint256 tAmount) private view returns (uint256, uint256, uint256, uint256, uint256, uint256) { (uint256 tTransferAmount, uint256 tFee, uint256 tMarketing) = _getTValues(tAmount); (uint256 rAmount, uint256 rTransferAmount, uint256 rFee) = _getRValues(tAmount, tFee, tMarketing, _getRate()); return (rAmount, rTransferAmount, rFee, tTransferAmount, tFee, tMarketing); } function _getTValues(uint256 tAmount) private view returns (uint256, uint256, uint256) { uint256 tFee = calculateTaxFee(tAmount); uint256 tMarketing = calculateMarketingFee(tAmount); uint256 tTransferAmount = tAmount.sub(tFee).sub(tMarketing); return (tTransferAmount, tFee, tMarketing); } function _getRValues(uint256 tAmount, uint256 tFee, uint256 tMarketing, uint256 currentRate) private pure returns (uint256, uint256, uint256) { uint256 rAmount = tAmount.mul(currentRate); uint256 rFee = tFee.mul(currentRate); uint256 rMarketing = tMarketing.mul(currentRate); uint256 rTransferAmount = rAmount.sub(rFee).sub(rMarketing); return (rAmount, rTransferAmount, rFee); } function _getRate() private view returns(uint256) { (uint256 rSupply, uint256 tSupply) = _getCurrentSupply(); return rSupply.div(tSupply); } function _getCurrentSupply() private view returns(uint256, uint256) { uint256 rSupply = _rTotal; uint256 tSupply = _tTotal; for (uint256 i = 0; i < _excluded.length; i++) { if (_rOwned[_excluded[i]] > rSupply || _tOwned[_excluded[i]] > tSupply) return (_rTotal, _tTotal); rSupply = rSupply.sub(_rOwned[_excluded[i]]); tSupply = tSupply.sub(_tOwned[_excluded[i]]); } if (rSupply < _rTotal.div(_tTotal)) return (_rTotal, _tTotal); return (rSupply, tSupply); } function _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 calculateTaxFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_taxFee).div( 10**2 ); } function calculateMarketingFee(uint256 _amount) private view returns (uint256) { return _amount.mul(_marketingFee).div( 10**2 ); } function isExcludedFromFee(address account) public view returns(bool) { return _isExcludedFromFee[account]; } function _approve(address owner, address spender, uint256 amount) private { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } function _transfer( address from, address to, uint256 amount ) private { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); require(amount > 0, "Transfer amount must be greater than zero"); require(!_isBlacklisted[from] && !_isBlacklisted[to], "This address is blacklisted"); if(from != owner() && to != 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 + send lock? // also, don't get caught in a circular sending event. // also, don't swap & liquify if sender is uniswap pair. uint256 contractTokenBalance = balanceOf(address(this)); bool overMinTokenBalance = contractTokenBalance >= numTokensToExchangeForMarketing; if(contractTokenBalance >= _maxTxAmount) { contractTokenBalance = _maxTxAmount; } if ( overMinTokenBalance && !inSwapAndSend && from != uniswapV2Pair && SwapAndSendEnabled ) { SwapAndSend(contractTokenBalance); } if(feesOnSellersAndBuyers) { setFees(to); } //indicates if fee should be deducted from transfer bool takeFee = true; //if any account belongs to _isExcludedFromFee account then remove the fee if(_isExcludedFromFee[from] || _isExcludedFromFee[to]) { takeFee = false; } _tokenTransfer(from,to,amount,takeFee); } function setFees(address recipient) private { _taxFee = defaultTaxFee; _marketingFee = defaultMarketingFee; if (recipient == uniswapV2Pair) { // sell _marketingFee = _marketingFee4Sellers; } } function SwapAndSend(uint256 contractTokenBalance) 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), contractTokenBalance); // make the swap uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens( contractTokenBalance, 0, // accept any amount of ETH path, address(this), block.timestamp ); uint256 contractETHBalance = address(this).balance; if(contractETHBalance > 0) { marketingWallet.transfer(contractETHBalance); } } //this method is responsible for taking all fee, if takeFee is true 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 setDefaultMarketingFee(uint256 marketingFee) external onlyOwner() { defaultMarketingFee = marketingFee; } function setMarketingFee4Sellers(uint256 marketingFee4Sellers) external onlyOwner() { _marketingFee4Sellers = marketingFee4Sellers; } function setFeesOnSellersAndBuyers(bool _enabled) public onlyOwner() { feesOnSellersAndBuyers = _enabled; } function setSwapAndSendEnabled(bool _enabled) public onlyOwner() { SwapAndSendEnabled = _enabled; emit SwapAndSendEnabledUpdated(_enabled); } function setnumTokensToExchangeForMarketing(uint256 _numTokensToExchangeForMarketing) public onlyOwner() { numTokensToExchangeForMarketing = _numTokensToExchangeForMarketing; } function _setMarketingWallet(address payable wallet) external onlyOwner() { marketingWallet = wallet; } function _setMaxTxAmount(uint256 maxTxAmount) external onlyOwner() { _maxTxAmount = maxTxAmount; } }
_tokenTransfer
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(); }
//this method is responsible for taking all fee, if takeFee is true
LineComment
v0.8.3+commit.8d00100c
None
ipfs://9d6f7d9809392a583e6bc787f803f32f149d7cd1d80334dea0efc8fd2dbbc03b
{ "func_code_index": [ 13544, 14367 ] }
3,727
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
AddressUtils
library AddressUtils { /** * Returns whether there is code in the target address * @dev This function will return false if invoked during the constructor of a contract, * as the code is not actually created until after the constructor finishes. * @param addr address address to check * @return whether there is code in the target address */ function isContract(address addr) internal view returns(bool) { uint256 size; assembly { size: = extcodesize(addr) } return size > 0; } }
/** * Utility library of inline functions on addresses */
NatSpecMultiLine
isContract
function isContract(address addr) internal view returns(bool) { uint256 size; assembly { size: = extcodesize(addr) } return size > 0; }
/** * Returns whether there is code in the target address * @dev This function will return false if invoked during the constructor of a contract, * as the code is not actually created until after the constructor finishes. * @param addr address address to check * @return whether there is code in the target address */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 372, 540 ] }
3,728
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns(uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns(uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns(uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns(uint256) { uint256 c = a + b; assert(c >= a); return c; } }
mul
function mul(uint256 a, uint256 b) internal pure returns(uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; }
/** * @dev Multiplies two numbers, throws on overflow. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 91, 273 ] }
3,729
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns(uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns(uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns(uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns(uint256) { uint256 c = a + b; assert(c >= a); return c; } }
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; }
/** * @dev Integer division of two numbers, truncating the quotient. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 359, 631 ] }
3,730
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns(uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns(uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns(uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns(uint256) { uint256 c = a + b; assert(c >= a); return c; } }
sub
function sub(uint256 a, uint256 b) internal pure returns(uint256) { assert(b <= a); return a - b; }
/** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 748, 863 ] }
3,731
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
SafeMath
library SafeMath { /** * @dev Multiplies two numbers, throws on overflow. */ function mul(uint256 a, uint256 b) internal pure returns(uint256) { if (a == 0) { return 0; } uint256 c = a * b; assert(c / a == b); return c; } /** * @dev Integer division of two numbers, truncating the quotient. */ function div(uint256 a, uint256 b) internal pure returns(uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend). */ function sub(uint256 a, uint256 b) internal pure returns(uint256) { assert(b <= a); return a - b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns(uint256) { uint256 c = a + b; assert(c >= a); return c; } }
add
function add(uint256 a, uint256 b) internal pure returns(uint256) { uint256 c = a + b; assert(c >= a); return c; }
/** * @dev Adds two numbers, throws on overflow. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 929, 1064 ] }
3,732
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
Ownable
contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } }
/** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
renounceOwnership
function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); }
/** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 815, 932 ] }
3,733
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
Ownable
contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } }
/** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
transferOwnership
function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); }
/** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 1097, 1205 ] }
3,734
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
Ownable
contract Ownable { address public owner; event OwnershipRenounced(address indexed previousOwner); event OwnershipTransferred( address indexed previousOwner, address indexed newOwner ); /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() public { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner); _; } /** * @dev Allows the current owner to relinquish control of the contract. * @notice Renouncing to ownership will leave the contract without an owner. * It will not be possible to call the functions with the `onlyOwner` * modifier anymore. */ function renounceOwnership() public onlyOwner { emit OwnershipRenounced(owner); owner = address(0); } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function transferOwnership(address _newOwner) public onlyOwner { _transferOwnership(_newOwner); } /** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */ function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; } }
/** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user permissions". */
NatSpecMultiLine
_transferOwnership
function _transferOwnership(address _newOwner) internal { require(_newOwner != address(0)); emit OwnershipTransferred(owner, _newOwner); owner = _newOwner; }
/** * @dev Transfers control of the contract to a newOwner. * @param _newOwner The address to transfer ownership to. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 1343, 1521 ] }
3,735
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
Roles
library Roles { struct Role { mapping(address => bool) bearer; } /** * @dev give an address access to this role */ function add(Role storage _role, address _addr) internal { _role.bearer[_addr] = true; } /** * @dev remove an address' access to this role */ function remove(Role storage _role, address _addr) internal { _role.bearer[_addr] = false; } /** * @dev check if an address has this role * // reverts */ function check(Role storage _role, address _addr) internal view { require(has(_role, _addr)); } /** * @dev check if an address has this role * @return bool */ function has(Role storage _role, address _addr) internal view returns(bool) { return _role.bearer[_addr]; } }
/** * @title Roles * @author Francisco Giordano (@frangio) * @dev Library for managing addresses assigned to a Role. * See RBAC.sol for example usage. */
NatSpecMultiLine
add
function add(Role storage _role, address _addr) internal { _role.bearer[_addr] = true; }
/** * @dev give an address access to this role */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 140, 242 ] }
3,736
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
Roles
library Roles { struct Role { mapping(address => bool) bearer; } /** * @dev give an address access to this role */ function add(Role storage _role, address _addr) internal { _role.bearer[_addr] = true; } /** * @dev remove an address' access to this role */ function remove(Role storage _role, address _addr) internal { _role.bearer[_addr] = false; } /** * @dev check if an address has this role * // reverts */ function check(Role storage _role, address _addr) internal view { require(has(_role, _addr)); } /** * @dev check if an address has this role * @return bool */ function has(Role storage _role, address _addr) internal view returns(bool) { return _role.bearer[_addr]; } }
/** * @title Roles * @author Francisco Giordano (@frangio) * @dev Library for managing addresses assigned to a Role. * See RBAC.sol for example usage. */
NatSpecMultiLine
remove
function remove(Role storage _role, address _addr) internal { _role.bearer[_addr] = false; }
/** * @dev remove an address' access to this role */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 309, 415 ] }
3,737
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
Roles
library Roles { struct Role { mapping(address => bool) bearer; } /** * @dev give an address access to this role */ function add(Role storage _role, address _addr) internal { _role.bearer[_addr] = true; } /** * @dev remove an address' access to this role */ function remove(Role storage _role, address _addr) internal { _role.bearer[_addr] = false; } /** * @dev check if an address has this role * // reverts */ function check(Role storage _role, address _addr) internal view { require(has(_role, _addr)); } /** * @dev check if an address has this role * @return bool */ function has(Role storage _role, address _addr) internal view returns(bool) { return _role.bearer[_addr]; } }
/** * @title Roles * @author Francisco Giordano (@frangio) * @dev Library for managing addresses assigned to a Role. * See RBAC.sol for example usage. */
NatSpecMultiLine
check
function check(Role storage _role, address _addr) internal view { require(has(_role, _addr)); }
/** * @dev check if an address has this role * // reverts */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 494, 606 ] }
3,738
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
Roles
library Roles { struct Role { mapping(address => bool) bearer; } /** * @dev give an address access to this role */ function add(Role storage _role, address _addr) internal { _role.bearer[_addr] = true; } /** * @dev remove an address' access to this role */ function remove(Role storage _role, address _addr) internal { _role.bearer[_addr] = false; } /** * @dev check if an address has this role * // reverts */ function check(Role storage _role, address _addr) internal view { require(has(_role, _addr)); } /** * @dev check if an address has this role * @return bool */ function has(Role storage _role, address _addr) internal view returns(bool) { return _role.bearer[_addr]; } }
/** * @title Roles * @author Francisco Giordano (@frangio) * @dev Library for managing addresses assigned to a Role. * See RBAC.sol for example usage. */
NatSpecMultiLine
has
function has(Role storage _role, address _addr) internal view returns(bool) { return _role.bearer[_addr]; }
/** * @dev check if an address has this role * @return bool */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 687, 814 ] }
3,739
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
RBAC
contract RBAC { using Roles for Roles.Role; mapping(string => Roles.Role) private roles; event RoleAdded(address indexed operator, string role); event RoleRemoved(address indexed operator, string role); /** * @dev reverts if addr does not have role * @param _operator address * @param _role the name of the role * // reverts */ function checkRole(address _operator, string _role) public view { roles[_role].check(_operator); } /** * @dev determine if addr has role * @param _operator address * @param _role the name of the role * @return bool */ function hasRole(address _operator, string _role) public view returns(bool) { return roles[_role].has(_operator); } /** * @dev add a role to an address * @param _operator address * @param _role the name of the role */ function addRole(address _operator, string _role) internal { roles[_role].add(_operator); emit RoleAdded(_operator, _role); } /** * @dev remove a role from an address * @param _operator address * @param _role the name of the role */ function removeRole(address _operator, string _role) internal { roles[_role].remove(_operator); emit RoleRemoved(_operator, _role); } /** * @dev modifier to scope access to a single role (uses msg.sender as addr) * @param _role the name of the role * // reverts */ modifier onlyRole(string _role) { checkRole(msg.sender, _role); _; } }
/** * @title RBAC (Role-Based Access Control) * @author Matt Condon (@Shrugs) * @dev Stores and provides setters and getters for roles and addresses. * Supports unlimited numbers of roles and addresses. * See //contracts/mocks/RBACMock.sol for an example of usage. * This RBAC method uses strings to key roles. It may be beneficial * for you to write your own implementation of this interface using Enums or similar. */
NatSpecMultiLine
checkRole
function checkRole(address _operator, string _role) public view { roles[_role].check(_operator); }
/** * @dev reverts if addr does not have role * @param _operator address * @param _role the name of the role * // reverts */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 373, 488 ] }
3,740
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
RBAC
contract RBAC { using Roles for Roles.Role; mapping(string => Roles.Role) private roles; event RoleAdded(address indexed operator, string role); event RoleRemoved(address indexed operator, string role); /** * @dev reverts if addr does not have role * @param _operator address * @param _role the name of the role * // reverts */ function checkRole(address _operator, string _role) public view { roles[_role].check(_operator); } /** * @dev determine if addr has role * @param _operator address * @param _role the name of the role * @return bool */ function hasRole(address _operator, string _role) public view returns(bool) { return roles[_role].has(_operator); } /** * @dev add a role to an address * @param _operator address * @param _role the name of the role */ function addRole(address _operator, string _role) internal { roles[_role].add(_operator); emit RoleAdded(_operator, _role); } /** * @dev remove a role from an address * @param _operator address * @param _role the name of the role */ function removeRole(address _operator, string _role) internal { roles[_role].remove(_operator); emit RoleRemoved(_operator, _role); } /** * @dev modifier to scope access to a single role (uses msg.sender as addr) * @param _role the name of the role * // reverts */ modifier onlyRole(string _role) { checkRole(msg.sender, _role); _; } }
/** * @title RBAC (Role-Based Access Control) * @author Matt Condon (@Shrugs) * @dev Stores and provides setters and getters for roles and addresses. * Supports unlimited numbers of roles and addresses. * See //contracts/mocks/RBACMock.sol for an example of usage. * This RBAC method uses strings to key roles. It may be beneficial * for you to write your own implementation of this interface using Enums or similar. */
NatSpecMultiLine
hasRole
function hasRole(address _operator, string _role) public view returns(bool) { return roles[_role].has(_operator); }
/** * @dev determine if addr has role * @param _operator address * @param _role the name of the role * @return bool */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 633, 768 ] }
3,741
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
RBAC
contract RBAC { using Roles for Roles.Role; mapping(string => Roles.Role) private roles; event RoleAdded(address indexed operator, string role); event RoleRemoved(address indexed operator, string role); /** * @dev reverts if addr does not have role * @param _operator address * @param _role the name of the role * // reverts */ function checkRole(address _operator, string _role) public view { roles[_role].check(_operator); } /** * @dev determine if addr has role * @param _operator address * @param _role the name of the role * @return bool */ function hasRole(address _operator, string _role) public view returns(bool) { return roles[_role].has(_operator); } /** * @dev add a role to an address * @param _operator address * @param _role the name of the role */ function addRole(address _operator, string _role) internal { roles[_role].add(_operator); emit RoleAdded(_operator, _role); } /** * @dev remove a role from an address * @param _operator address * @param _role the name of the role */ function removeRole(address _operator, string _role) internal { roles[_role].remove(_operator); emit RoleRemoved(_operator, _role); } /** * @dev modifier to scope access to a single role (uses msg.sender as addr) * @param _role the name of the role * // reverts */ modifier onlyRole(string _role) { checkRole(msg.sender, _role); _; } }
/** * @title RBAC (Role-Based Access Control) * @author Matt Condon (@Shrugs) * @dev Stores and provides setters and getters for roles and addresses. * Supports unlimited numbers of roles and addresses. * See //contracts/mocks/RBACMock.sol for an example of usage. * This RBAC method uses strings to key roles. It may be beneficial * for you to write your own implementation of this interface using Enums or similar. */
NatSpecMultiLine
addRole
function addRole(address _operator, string _role) internal { roles[_role].add(_operator); emit RoleAdded(_operator, _role); }
/** * @dev add a role to an address * @param _operator address * @param _role the name of the role */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 892, 1036 ] }
3,742
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
RBAC
contract RBAC { using Roles for Roles.Role; mapping(string => Roles.Role) private roles; event RoleAdded(address indexed operator, string role); event RoleRemoved(address indexed operator, string role); /** * @dev reverts if addr does not have role * @param _operator address * @param _role the name of the role * // reverts */ function checkRole(address _operator, string _role) public view { roles[_role].check(_operator); } /** * @dev determine if addr has role * @param _operator address * @param _role the name of the role * @return bool */ function hasRole(address _operator, string _role) public view returns(bool) { return roles[_role].has(_operator); } /** * @dev add a role to an address * @param _operator address * @param _role the name of the role */ function addRole(address _operator, string _role) internal { roles[_role].add(_operator); emit RoleAdded(_operator, _role); } /** * @dev remove a role from an address * @param _operator address * @param _role the name of the role */ function removeRole(address _operator, string _role) internal { roles[_role].remove(_operator); emit RoleRemoved(_operator, _role); } /** * @dev modifier to scope access to a single role (uses msg.sender as addr) * @param _role the name of the role * // reverts */ modifier onlyRole(string _role) { checkRole(msg.sender, _role); _; } }
/** * @title RBAC (Role-Based Access Control) * @author Matt Condon (@Shrugs) * @dev Stores and provides setters and getters for roles and addresses. * Supports unlimited numbers of roles and addresses. * See //contracts/mocks/RBACMock.sol for an example of usage. * This RBAC method uses strings to key roles. It may be beneficial * for you to write your own implementation of this interface using Enums or similar. */
NatSpecMultiLine
removeRole
function removeRole(address _operator, string _role) internal { roles[_role].remove(_operator); emit RoleRemoved(_operator, _role); }
/** * @dev remove a role from an address * @param _operator address * @param _role the name of the role */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 1165, 1317 ] }
3,743
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
RBACOperator
contract RBACOperator is Ownable, RBAC { /** * A constant role name for indicating operator. */ string public constant ROLE_OPERATOR = "operator"; address public partner; /** * Event for setPartner logging * @param oldPartner the old Partner * @param newPartner the new Partner */ event SetPartner(address oldPartner, address newPartner); /** * @dev Throws if called by any account other than the owner or the Partner. */ modifier onlyOwnerOrPartner() { require(msg.sender == owner || msg.sender == partner); _; } /** * @dev Throws if called by any account other than the Partner. */ modifier onlyPartner() { require(msg.sender == partner); _; } /** * @dev setPartner, set the partner address. * @param _partner the new partner address. */ function setPartner(address _partner) public onlyOwner { require(_partner != address(0)); emit SetPartner(partner, _partner); partner = _partner; } /** * @dev removePartner, remove partner address. */ function removePartner() public onlyOwner { delete partner; } /** * @dev the modifier to operate */ modifier hasOperationPermission() { checkRole(msg.sender, ROLE_OPERATOR); _; } /** * @dev add a operator role to an address * @param _operator address */ function addOperater(address _operator) public onlyOwnerOrPartner { addRole(_operator, ROLE_OPERATOR); } /** * @dev remove a operator role from an address * @param _operator address */ function removeOperater(address _operator) public onlyOwnerOrPartner { removeRole(_operator, ROLE_OPERATOR); } }
setPartner
function setPartner(address _partner) public onlyOwner { require(_partner != address(0)); emit SetPartner(partner, _partner); partner = _partner; }
/** * @dev setPartner, set the partner address. * @param _partner the new partner address. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 865, 1033 ] }
3,744
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
RBACOperator
contract RBACOperator is Ownable, RBAC { /** * A constant role name for indicating operator. */ string public constant ROLE_OPERATOR = "operator"; address public partner; /** * Event for setPartner logging * @param oldPartner the old Partner * @param newPartner the new Partner */ event SetPartner(address oldPartner, address newPartner); /** * @dev Throws if called by any account other than the owner or the Partner. */ modifier onlyOwnerOrPartner() { require(msg.sender == owner || msg.sender == partner); _; } /** * @dev Throws if called by any account other than the Partner. */ modifier onlyPartner() { require(msg.sender == partner); _; } /** * @dev setPartner, set the partner address. * @param _partner the new partner address. */ function setPartner(address _partner) public onlyOwner { require(_partner != address(0)); emit SetPartner(partner, _partner); partner = _partner; } /** * @dev removePartner, remove partner address. */ function removePartner() public onlyOwner { delete partner; } /** * @dev the modifier to operate */ modifier hasOperationPermission() { checkRole(msg.sender, ROLE_OPERATOR); _; } /** * @dev add a operator role to an address * @param _operator address */ function addOperater(address _operator) public onlyOwnerOrPartner { addRole(_operator, ROLE_OPERATOR); } /** * @dev remove a operator role from an address * @param _operator address */ function removeOperater(address _operator) public onlyOwnerOrPartner { removeRole(_operator, ROLE_OPERATOR); } }
removePartner
function removePartner() public onlyOwner { delete partner; }
/** * @dev removePartner, remove partner address. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 1103, 1175 ] }
3,745
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
RBACOperator
contract RBACOperator is Ownable, RBAC { /** * A constant role name for indicating operator. */ string public constant ROLE_OPERATOR = "operator"; address public partner; /** * Event for setPartner logging * @param oldPartner the old Partner * @param newPartner the new Partner */ event SetPartner(address oldPartner, address newPartner); /** * @dev Throws if called by any account other than the owner or the Partner. */ modifier onlyOwnerOrPartner() { require(msg.sender == owner || msg.sender == partner); _; } /** * @dev Throws if called by any account other than the Partner. */ modifier onlyPartner() { require(msg.sender == partner); _; } /** * @dev setPartner, set the partner address. * @param _partner the new partner address. */ function setPartner(address _partner) public onlyOwner { require(_partner != address(0)); emit SetPartner(partner, _partner); partner = _partner; } /** * @dev removePartner, remove partner address. */ function removePartner() public onlyOwner { delete partner; } /** * @dev the modifier to operate */ modifier hasOperationPermission() { checkRole(msg.sender, ROLE_OPERATOR); _; } /** * @dev add a operator role to an address * @param _operator address */ function addOperater(address _operator) public onlyOwnerOrPartner { addRole(_operator, ROLE_OPERATOR); } /** * @dev remove a operator role from an address * @param _operator address */ function removeOperater(address _operator) public onlyOwnerOrPartner { removeRole(_operator, ROLE_OPERATOR); } }
addOperater
function addOperater(address _operator) public onlyOwnerOrPartner { addRole(_operator, ROLE_OPERATOR); }
/** * @dev add a operator role to an address * @param _operator address */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 1418, 1533 ] }
3,746
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
RBACOperator
contract RBACOperator is Ownable, RBAC { /** * A constant role name for indicating operator. */ string public constant ROLE_OPERATOR = "operator"; address public partner; /** * Event for setPartner logging * @param oldPartner the old Partner * @param newPartner the new Partner */ event SetPartner(address oldPartner, address newPartner); /** * @dev Throws if called by any account other than the owner or the Partner. */ modifier onlyOwnerOrPartner() { require(msg.sender == owner || msg.sender == partner); _; } /** * @dev Throws if called by any account other than the Partner. */ modifier onlyPartner() { require(msg.sender == partner); _; } /** * @dev setPartner, set the partner address. * @param _partner the new partner address. */ function setPartner(address _partner) public onlyOwner { require(_partner != address(0)); emit SetPartner(partner, _partner); partner = _partner; } /** * @dev removePartner, remove partner address. */ function removePartner() public onlyOwner { delete partner; } /** * @dev the modifier to operate */ modifier hasOperationPermission() { checkRole(msg.sender, ROLE_OPERATOR); _; } /** * @dev add a operator role to an address * @param _operator address */ function addOperater(address _operator) public onlyOwnerOrPartner { addRole(_operator, ROLE_OPERATOR); } /** * @dev remove a operator role from an address * @param _operator address */ function removeOperater(address _operator) public onlyOwnerOrPartner { removeRole(_operator, ROLE_OPERATOR); } }
removeOperater
function removeOperater(address _operator) public onlyOwnerOrPartner { removeRole(_operator, ROLE_OPERATOR); }
/** * @dev remove a operator role from an address * @param _operator address */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 1631, 1752 ] }
3,747
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PartnerAuthority
contract PartnerAuthority is Ownable { address public partner; /** * Event for setPartner logging * @param oldPartner the old Partner * @param newPartner the new Partner */ event SetPartner(address oldPartner, address newPartner); /** * @dev Throws if called by any account other than the owner or the Partner. */ modifier onlyOwnerOrPartner() { require(msg.sender == owner || msg.sender == partner); _; } /** * @dev Throws if called by any account other than the Partner. */ modifier onlyPartner() { require(msg.sender == partner); _; } /** * @dev setPartner, set the partner address. */ function setPartner(address _partner) public onlyOwner { require(_partner != address(0)); emit SetPartner(partner, _partner); partner = _partner; } /** * @dev removePartner, remove partner address. */ function removePartner() public onlyOwner { delete partner; } }
setPartner
function setPartner(address _partner) public onlyOwner { require(_partner != address(0)); emit SetPartner(partner, _partner); partner = _partner; }
/** * @dev setPartner, set the partner address. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 695, 863 ] }
3,748
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PartnerAuthority
contract PartnerAuthority is Ownable { address public partner; /** * Event for setPartner logging * @param oldPartner the old Partner * @param newPartner the new Partner */ event SetPartner(address oldPartner, address newPartner); /** * @dev Throws if called by any account other than the owner or the Partner. */ modifier onlyOwnerOrPartner() { require(msg.sender == owner || msg.sender == partner); _; } /** * @dev Throws if called by any account other than the Partner. */ modifier onlyPartner() { require(msg.sender == partner); _; } /** * @dev setPartner, set the partner address. */ function setPartner(address _partner) public onlyOwner { require(_partner != address(0)); emit SetPartner(partner, _partner); partner = _partner; } /** * @dev removePartner, remove partner address. */ function removePartner() public onlyOwner { delete partner; } }
removePartner
function removePartner() public onlyOwner { delete partner; }
/** * @dev removePartner, remove partner address. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 935, 1007 ] }
3,749
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
OrderManageContract
contract OrderManageContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Status of current business execution contract. */ enum StatusChoices { NO_LOAN, REPAYMENT_WAITING, REPAYMENT_ALL, CLOSE_POSITION, OVERDUE_STOP } string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; address public maker; address public taker; address internal token20; uint256 public toTime; // the amount of the borrower’s final loan. uint256 public outLoanSum; uint256 public repaymentSum; uint256 public lastRepaymentSum; string public loanTokenName; // Borrower's record of the pledge. StatusChoices internal status; // Record the amount of the borrower's offline transfer. mapping(address => uint256) public ethAmount; /** * Event for takerOrder logging. * @param taker address of investor. * @param outLoanSum the amount of the borrower’s final loan. */ event TakerOrder(address indexed taker, uint256 outLoanSum); /** * Event for executeOrder logging. * @param maker address of borrower. * @param lastRepaymentSum current order repayment amount. */ event ExecuteOrder(address indexed maker, uint256 lastRepaymentSum); /** * Event for forceCloseOrder logging. * @param toTime order repayment due date. * @param transferSum balance under current contract. */ event ForceCloseOrder(uint256 indexed toTime, uint256 transferSum); /** * Event for WithdrawToken logging. * @param taker address of investor. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed taker, uint256 refundSum); function() external payable { // Record basic information about the borrower's REPAYMENT ETH ethAmount[msg.sender] = ethAmount[msg.sender].add(msg.value); } /** * @dev Constructor initial contract configuration parameters * @param _loanTokenAddress order type supported by the token. */ constructor(string _loanTokenName, address _loanTokenAddress, address _maker) public { require(bytes(_loanTokenName).length > 0 && _maker != address(0)); if (!_loanTokenName.stringCompare(TOKEN_ETH)) { require(_loanTokenAddress != address(0)); token20 = _loanTokenAddress; } toTime = now; maker = _maker; loanTokenName = _loanTokenName; status = StatusChoices.NO_LOAN; } /** * @dev Complete an order combination and issue the loan to the borrower. * @param _taker address of investor. * @param _toTime order repayment due date. * @param _repaymentSum total amount of money that the borrower ultimately needs to return. */ function takerOrder(address _taker, uint32 _toTime, uint256 _repaymentSum) public onlyOwnerOrPartner { require(_taker != address(0) && _toTime > 0 && now <= _toTime && _repaymentSum > 0 && status == StatusChoices.NO_LOAN); taker = _taker; toTime = _toTime; repaymentSum = _repaymentSum; // Transfer the token provided by the investor to the borrower's address if (loanTokenName.stringCompare(TOKEN_ETH)) { require(ethAmount[_taker] > 0 && address(this).balance > 0); outLoanSum = address(this).balance; maker.transfer(outLoanSum); } else { require(token20 != address(0) && ERC20(token20).balanceOf(address(this)) > 0); outLoanSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(maker, outLoanSum)); } // Update contract business execution status. status = StatusChoices.REPAYMENT_WAITING; emit TakerOrder(taker, outLoanSum); } /** * @dev Only the full repayment will execute the contract agreement. */ function executeOrder() public onlyOwnerOrPartner { require(now <= toTime && status == StatusChoices.REPAYMENT_WAITING); // The borrower pays off the loan and performs two-way operation. if (loanTokenName.stringCompare(TOKEN_ETH)) { require(ethAmount[maker] >= repaymentSum && address(this).balance >= repaymentSum); lastRepaymentSum = address(this).balance; taker.transfer(repaymentSum); } else { require(ERC20(token20).balanceOf(address(this)) >= repaymentSum); lastRepaymentSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(taker, repaymentSum)); } PledgeContract(owner)._conclude(); status = StatusChoices.REPAYMENT_ALL; emit ExecuteOrder(maker, lastRepaymentSum); } /** * @dev Close position or due repayment operation. */ function forceCloseOrder() public onlyOwnerOrPartner { require(status == StatusChoices.REPAYMENT_WAITING); uint256 transferSum = 0; if (now <= toTime) { status = StatusChoices.CLOSE_POSITION; } else { status = StatusChoices.OVERDUE_STOP; } if(loanTokenName.stringCompare(TOKEN_ETH)){ if(ethAmount[maker] > 0 && address(this).balance > 0){ transferSum = address(this).balance; maker.transfer(transferSum); } }else{ if(ERC20(token20).balanceOf(address(this)) > 0){ transferSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(maker, transferSum)); } } // Return pledge token. PledgeContract(owner)._forceConclude(taker); emit ForceCloseOrder(toTime, transferSum); } /** * @dev Withdrawal of the token invested by the taker. * @param _taker address of investor. * @param _refundSum refundSum number of tokens withdrawn. */ function withdrawToken(address _taker, uint256 _refundSum) public onlyOwnerOrPartner { require(status == StatusChoices.NO_LOAN); require(_taker != address(0) && _refundSum > 0); if (loanTokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _refundSum && ethAmount[_taker] >= _refundSum); _taker.transfer(_refundSum); ethAmount[_taker] = ethAmount[_taker].sub(_refundSum); } else { require(ERC20(token20).balanceOf(address(this)) >= _refundSum); require(safeErc20Transfer(_taker, _refundSum)); } emit WithdrawToken(_taker, _refundSum); } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(token20).transfer(_toAddress, _transferSum)); } return true; } /** * @dev Get current contract order status. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_LOAN) { pledgeStatus = "NO_LOAN"; } else if (status == StatusChoices.REPAYMENT_WAITING) { pledgeStatus = "REPAYMENT_WAITING"; } else if (status == StatusChoices.REPAYMENT_ALL) { pledgeStatus = "REPAYMENT_ALL"; } else if (status == StatusChoices.CLOSE_POSITION) { pledgeStatus = "CLOSE_POSITION"; } else { pledgeStatus = "OVERDUE_STOP"; } } }
/** * @title OrderManageContract * @dev Order process management contract. */
NatSpecMultiLine
takerOrder
function takerOrder(address _taker, uint32 _toTime, uint256 _repaymentSum) public onlyOwnerOrPartner { require(_taker != address(0) && _toTime > 0 && now <= _toTime && _repaymentSum > 0 && status == StatusChoices.NO_LOAN); taker = _taker; toTime = _toTime; repaymentSum = _repaymentSum; // Transfer the token provided by the investor to the borrower's address if (loanTokenName.stringCompare(TOKEN_ETH)) { require(ethAmount[_taker] > 0 && address(this).balance > 0); outLoanSum = address(this).balance; maker.transfer(outLoanSum); } else { require(token20 != address(0) && ERC20(token20).balanceOf(address(this)) > 0); outLoanSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(maker, outLoanSum)); } // Update contract business execution status. status = StatusChoices.REPAYMENT_WAITING; emit TakerOrder(taker, outLoanSum); }
/** * @dev Complete an order combination and issue the loan to the borrower. * @param _taker address of investor. * @param _toTime order repayment due date. * @param _repaymentSum total amount of money that the borrower ultimately needs to return. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 2806, 3762 ] }
3,750
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
OrderManageContract
contract OrderManageContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Status of current business execution contract. */ enum StatusChoices { NO_LOAN, REPAYMENT_WAITING, REPAYMENT_ALL, CLOSE_POSITION, OVERDUE_STOP } string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; address public maker; address public taker; address internal token20; uint256 public toTime; // the amount of the borrower’s final loan. uint256 public outLoanSum; uint256 public repaymentSum; uint256 public lastRepaymentSum; string public loanTokenName; // Borrower's record of the pledge. StatusChoices internal status; // Record the amount of the borrower's offline transfer. mapping(address => uint256) public ethAmount; /** * Event for takerOrder logging. * @param taker address of investor. * @param outLoanSum the amount of the borrower’s final loan. */ event TakerOrder(address indexed taker, uint256 outLoanSum); /** * Event for executeOrder logging. * @param maker address of borrower. * @param lastRepaymentSum current order repayment amount. */ event ExecuteOrder(address indexed maker, uint256 lastRepaymentSum); /** * Event for forceCloseOrder logging. * @param toTime order repayment due date. * @param transferSum balance under current contract. */ event ForceCloseOrder(uint256 indexed toTime, uint256 transferSum); /** * Event for WithdrawToken logging. * @param taker address of investor. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed taker, uint256 refundSum); function() external payable { // Record basic information about the borrower's REPAYMENT ETH ethAmount[msg.sender] = ethAmount[msg.sender].add(msg.value); } /** * @dev Constructor initial contract configuration parameters * @param _loanTokenAddress order type supported by the token. */ constructor(string _loanTokenName, address _loanTokenAddress, address _maker) public { require(bytes(_loanTokenName).length > 0 && _maker != address(0)); if (!_loanTokenName.stringCompare(TOKEN_ETH)) { require(_loanTokenAddress != address(0)); token20 = _loanTokenAddress; } toTime = now; maker = _maker; loanTokenName = _loanTokenName; status = StatusChoices.NO_LOAN; } /** * @dev Complete an order combination and issue the loan to the borrower. * @param _taker address of investor. * @param _toTime order repayment due date. * @param _repaymentSum total amount of money that the borrower ultimately needs to return. */ function takerOrder(address _taker, uint32 _toTime, uint256 _repaymentSum) public onlyOwnerOrPartner { require(_taker != address(0) && _toTime > 0 && now <= _toTime && _repaymentSum > 0 && status == StatusChoices.NO_LOAN); taker = _taker; toTime = _toTime; repaymentSum = _repaymentSum; // Transfer the token provided by the investor to the borrower's address if (loanTokenName.stringCompare(TOKEN_ETH)) { require(ethAmount[_taker] > 0 && address(this).balance > 0); outLoanSum = address(this).balance; maker.transfer(outLoanSum); } else { require(token20 != address(0) && ERC20(token20).balanceOf(address(this)) > 0); outLoanSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(maker, outLoanSum)); } // Update contract business execution status. status = StatusChoices.REPAYMENT_WAITING; emit TakerOrder(taker, outLoanSum); } /** * @dev Only the full repayment will execute the contract agreement. */ function executeOrder() public onlyOwnerOrPartner { require(now <= toTime && status == StatusChoices.REPAYMENT_WAITING); // The borrower pays off the loan and performs two-way operation. if (loanTokenName.stringCompare(TOKEN_ETH)) { require(ethAmount[maker] >= repaymentSum && address(this).balance >= repaymentSum); lastRepaymentSum = address(this).balance; taker.transfer(repaymentSum); } else { require(ERC20(token20).balanceOf(address(this)) >= repaymentSum); lastRepaymentSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(taker, repaymentSum)); } PledgeContract(owner)._conclude(); status = StatusChoices.REPAYMENT_ALL; emit ExecuteOrder(maker, lastRepaymentSum); } /** * @dev Close position or due repayment operation. */ function forceCloseOrder() public onlyOwnerOrPartner { require(status == StatusChoices.REPAYMENT_WAITING); uint256 transferSum = 0; if (now <= toTime) { status = StatusChoices.CLOSE_POSITION; } else { status = StatusChoices.OVERDUE_STOP; } if(loanTokenName.stringCompare(TOKEN_ETH)){ if(ethAmount[maker] > 0 && address(this).balance > 0){ transferSum = address(this).balance; maker.transfer(transferSum); } }else{ if(ERC20(token20).balanceOf(address(this)) > 0){ transferSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(maker, transferSum)); } } // Return pledge token. PledgeContract(owner)._forceConclude(taker); emit ForceCloseOrder(toTime, transferSum); } /** * @dev Withdrawal of the token invested by the taker. * @param _taker address of investor. * @param _refundSum refundSum number of tokens withdrawn. */ function withdrawToken(address _taker, uint256 _refundSum) public onlyOwnerOrPartner { require(status == StatusChoices.NO_LOAN); require(_taker != address(0) && _refundSum > 0); if (loanTokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _refundSum && ethAmount[_taker] >= _refundSum); _taker.transfer(_refundSum); ethAmount[_taker] = ethAmount[_taker].sub(_refundSum); } else { require(ERC20(token20).balanceOf(address(this)) >= _refundSum); require(safeErc20Transfer(_taker, _refundSum)); } emit WithdrawToken(_taker, _refundSum); } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(token20).transfer(_toAddress, _transferSum)); } return true; } /** * @dev Get current contract order status. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_LOAN) { pledgeStatus = "NO_LOAN"; } else if (status == StatusChoices.REPAYMENT_WAITING) { pledgeStatus = "REPAYMENT_WAITING"; } else if (status == StatusChoices.REPAYMENT_ALL) { pledgeStatus = "REPAYMENT_ALL"; } else if (status == StatusChoices.CLOSE_POSITION) { pledgeStatus = "CLOSE_POSITION"; } else { pledgeStatus = "OVERDUE_STOP"; } } }
/** * @title OrderManageContract * @dev Order process management contract. */
NatSpecMultiLine
executeOrder
function executeOrder() public onlyOwnerOrPartner { require(now <= toTime && status == StatusChoices.REPAYMENT_WAITING); // The borrower pays off the loan and performs two-way operation. if (loanTokenName.stringCompare(TOKEN_ETH)) { require(ethAmount[maker] >= repaymentSum && address(this).balance >= repaymentSum); lastRepaymentSum = address(this).balance; taker.transfer(repaymentSum); } else { require(ERC20(token20).balanceOf(address(this)) >= repaymentSum); lastRepaymentSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(taker, repaymentSum)); } PledgeContract(owner)._conclude(); status = StatusChoices.REPAYMENT_ALL; emit ExecuteOrder(maker, lastRepaymentSum); }
/** * @dev Only the full repayment will execute the contract agreement. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 3861, 4644 ] }
3,751
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
OrderManageContract
contract OrderManageContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Status of current business execution contract. */ enum StatusChoices { NO_LOAN, REPAYMENT_WAITING, REPAYMENT_ALL, CLOSE_POSITION, OVERDUE_STOP } string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; address public maker; address public taker; address internal token20; uint256 public toTime; // the amount of the borrower’s final loan. uint256 public outLoanSum; uint256 public repaymentSum; uint256 public lastRepaymentSum; string public loanTokenName; // Borrower's record of the pledge. StatusChoices internal status; // Record the amount of the borrower's offline transfer. mapping(address => uint256) public ethAmount; /** * Event for takerOrder logging. * @param taker address of investor. * @param outLoanSum the amount of the borrower’s final loan. */ event TakerOrder(address indexed taker, uint256 outLoanSum); /** * Event for executeOrder logging. * @param maker address of borrower. * @param lastRepaymentSum current order repayment amount. */ event ExecuteOrder(address indexed maker, uint256 lastRepaymentSum); /** * Event for forceCloseOrder logging. * @param toTime order repayment due date. * @param transferSum balance under current contract. */ event ForceCloseOrder(uint256 indexed toTime, uint256 transferSum); /** * Event for WithdrawToken logging. * @param taker address of investor. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed taker, uint256 refundSum); function() external payable { // Record basic information about the borrower's REPAYMENT ETH ethAmount[msg.sender] = ethAmount[msg.sender].add(msg.value); } /** * @dev Constructor initial contract configuration parameters * @param _loanTokenAddress order type supported by the token. */ constructor(string _loanTokenName, address _loanTokenAddress, address _maker) public { require(bytes(_loanTokenName).length > 0 && _maker != address(0)); if (!_loanTokenName.stringCompare(TOKEN_ETH)) { require(_loanTokenAddress != address(0)); token20 = _loanTokenAddress; } toTime = now; maker = _maker; loanTokenName = _loanTokenName; status = StatusChoices.NO_LOAN; } /** * @dev Complete an order combination and issue the loan to the borrower. * @param _taker address of investor. * @param _toTime order repayment due date. * @param _repaymentSum total amount of money that the borrower ultimately needs to return. */ function takerOrder(address _taker, uint32 _toTime, uint256 _repaymentSum) public onlyOwnerOrPartner { require(_taker != address(0) && _toTime > 0 && now <= _toTime && _repaymentSum > 0 && status == StatusChoices.NO_LOAN); taker = _taker; toTime = _toTime; repaymentSum = _repaymentSum; // Transfer the token provided by the investor to the borrower's address if (loanTokenName.stringCompare(TOKEN_ETH)) { require(ethAmount[_taker] > 0 && address(this).balance > 0); outLoanSum = address(this).balance; maker.transfer(outLoanSum); } else { require(token20 != address(0) && ERC20(token20).balanceOf(address(this)) > 0); outLoanSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(maker, outLoanSum)); } // Update contract business execution status. status = StatusChoices.REPAYMENT_WAITING; emit TakerOrder(taker, outLoanSum); } /** * @dev Only the full repayment will execute the contract agreement. */ function executeOrder() public onlyOwnerOrPartner { require(now <= toTime && status == StatusChoices.REPAYMENT_WAITING); // The borrower pays off the loan and performs two-way operation. if (loanTokenName.stringCompare(TOKEN_ETH)) { require(ethAmount[maker] >= repaymentSum && address(this).balance >= repaymentSum); lastRepaymentSum = address(this).balance; taker.transfer(repaymentSum); } else { require(ERC20(token20).balanceOf(address(this)) >= repaymentSum); lastRepaymentSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(taker, repaymentSum)); } PledgeContract(owner)._conclude(); status = StatusChoices.REPAYMENT_ALL; emit ExecuteOrder(maker, lastRepaymentSum); } /** * @dev Close position or due repayment operation. */ function forceCloseOrder() public onlyOwnerOrPartner { require(status == StatusChoices.REPAYMENT_WAITING); uint256 transferSum = 0; if (now <= toTime) { status = StatusChoices.CLOSE_POSITION; } else { status = StatusChoices.OVERDUE_STOP; } if(loanTokenName.stringCompare(TOKEN_ETH)){ if(ethAmount[maker] > 0 && address(this).balance > 0){ transferSum = address(this).balance; maker.transfer(transferSum); } }else{ if(ERC20(token20).balanceOf(address(this)) > 0){ transferSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(maker, transferSum)); } } // Return pledge token. PledgeContract(owner)._forceConclude(taker); emit ForceCloseOrder(toTime, transferSum); } /** * @dev Withdrawal of the token invested by the taker. * @param _taker address of investor. * @param _refundSum refundSum number of tokens withdrawn. */ function withdrawToken(address _taker, uint256 _refundSum) public onlyOwnerOrPartner { require(status == StatusChoices.NO_LOAN); require(_taker != address(0) && _refundSum > 0); if (loanTokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _refundSum && ethAmount[_taker] >= _refundSum); _taker.transfer(_refundSum); ethAmount[_taker] = ethAmount[_taker].sub(_refundSum); } else { require(ERC20(token20).balanceOf(address(this)) >= _refundSum); require(safeErc20Transfer(_taker, _refundSum)); } emit WithdrawToken(_taker, _refundSum); } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(token20).transfer(_toAddress, _transferSum)); } return true; } /** * @dev Get current contract order status. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_LOAN) { pledgeStatus = "NO_LOAN"; } else if (status == StatusChoices.REPAYMENT_WAITING) { pledgeStatus = "REPAYMENT_WAITING"; } else if (status == StatusChoices.REPAYMENT_ALL) { pledgeStatus = "REPAYMENT_ALL"; } else if (status == StatusChoices.CLOSE_POSITION) { pledgeStatus = "CLOSE_POSITION"; } else { pledgeStatus = "OVERDUE_STOP"; } } }
/** * @title OrderManageContract * @dev Order process management contract. */
NatSpecMultiLine
forceCloseOrder
function forceCloseOrder() public onlyOwnerOrPartner { require(status == StatusChoices.REPAYMENT_WAITING); uint256 transferSum = 0; if (now <= toTime) { status = StatusChoices.CLOSE_POSITION; } else { status = StatusChoices.OVERDUE_STOP; } if(loanTokenName.stringCompare(TOKEN_ETH)){ if(ethAmount[maker] > 0 && address(this).balance > 0){ transferSum = address(this).balance; maker.transfer(transferSum); } }else{ if(ERC20(token20).balanceOf(address(this)) > 0){ transferSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(maker, transferSum)); } } // Return pledge token. PledgeContract(owner)._forceConclude(taker); emit ForceCloseOrder(toTime, transferSum); }
/** * @dev Close position or due repayment operation. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 4719, 5571 ] }
3,752
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
OrderManageContract
contract OrderManageContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Status of current business execution contract. */ enum StatusChoices { NO_LOAN, REPAYMENT_WAITING, REPAYMENT_ALL, CLOSE_POSITION, OVERDUE_STOP } string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; address public maker; address public taker; address internal token20; uint256 public toTime; // the amount of the borrower’s final loan. uint256 public outLoanSum; uint256 public repaymentSum; uint256 public lastRepaymentSum; string public loanTokenName; // Borrower's record of the pledge. StatusChoices internal status; // Record the amount of the borrower's offline transfer. mapping(address => uint256) public ethAmount; /** * Event for takerOrder logging. * @param taker address of investor. * @param outLoanSum the amount of the borrower’s final loan. */ event TakerOrder(address indexed taker, uint256 outLoanSum); /** * Event for executeOrder logging. * @param maker address of borrower. * @param lastRepaymentSum current order repayment amount. */ event ExecuteOrder(address indexed maker, uint256 lastRepaymentSum); /** * Event for forceCloseOrder logging. * @param toTime order repayment due date. * @param transferSum balance under current contract. */ event ForceCloseOrder(uint256 indexed toTime, uint256 transferSum); /** * Event for WithdrawToken logging. * @param taker address of investor. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed taker, uint256 refundSum); function() external payable { // Record basic information about the borrower's REPAYMENT ETH ethAmount[msg.sender] = ethAmount[msg.sender].add(msg.value); } /** * @dev Constructor initial contract configuration parameters * @param _loanTokenAddress order type supported by the token. */ constructor(string _loanTokenName, address _loanTokenAddress, address _maker) public { require(bytes(_loanTokenName).length > 0 && _maker != address(0)); if (!_loanTokenName.stringCompare(TOKEN_ETH)) { require(_loanTokenAddress != address(0)); token20 = _loanTokenAddress; } toTime = now; maker = _maker; loanTokenName = _loanTokenName; status = StatusChoices.NO_LOAN; } /** * @dev Complete an order combination and issue the loan to the borrower. * @param _taker address of investor. * @param _toTime order repayment due date. * @param _repaymentSum total amount of money that the borrower ultimately needs to return. */ function takerOrder(address _taker, uint32 _toTime, uint256 _repaymentSum) public onlyOwnerOrPartner { require(_taker != address(0) && _toTime > 0 && now <= _toTime && _repaymentSum > 0 && status == StatusChoices.NO_LOAN); taker = _taker; toTime = _toTime; repaymentSum = _repaymentSum; // Transfer the token provided by the investor to the borrower's address if (loanTokenName.stringCompare(TOKEN_ETH)) { require(ethAmount[_taker] > 0 && address(this).balance > 0); outLoanSum = address(this).balance; maker.transfer(outLoanSum); } else { require(token20 != address(0) && ERC20(token20).balanceOf(address(this)) > 0); outLoanSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(maker, outLoanSum)); } // Update contract business execution status. status = StatusChoices.REPAYMENT_WAITING; emit TakerOrder(taker, outLoanSum); } /** * @dev Only the full repayment will execute the contract agreement. */ function executeOrder() public onlyOwnerOrPartner { require(now <= toTime && status == StatusChoices.REPAYMENT_WAITING); // The borrower pays off the loan and performs two-way operation. if (loanTokenName.stringCompare(TOKEN_ETH)) { require(ethAmount[maker] >= repaymentSum && address(this).balance >= repaymentSum); lastRepaymentSum = address(this).balance; taker.transfer(repaymentSum); } else { require(ERC20(token20).balanceOf(address(this)) >= repaymentSum); lastRepaymentSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(taker, repaymentSum)); } PledgeContract(owner)._conclude(); status = StatusChoices.REPAYMENT_ALL; emit ExecuteOrder(maker, lastRepaymentSum); } /** * @dev Close position or due repayment operation. */ function forceCloseOrder() public onlyOwnerOrPartner { require(status == StatusChoices.REPAYMENT_WAITING); uint256 transferSum = 0; if (now <= toTime) { status = StatusChoices.CLOSE_POSITION; } else { status = StatusChoices.OVERDUE_STOP; } if(loanTokenName.stringCompare(TOKEN_ETH)){ if(ethAmount[maker] > 0 && address(this).balance > 0){ transferSum = address(this).balance; maker.transfer(transferSum); } }else{ if(ERC20(token20).balanceOf(address(this)) > 0){ transferSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(maker, transferSum)); } } // Return pledge token. PledgeContract(owner)._forceConclude(taker); emit ForceCloseOrder(toTime, transferSum); } /** * @dev Withdrawal of the token invested by the taker. * @param _taker address of investor. * @param _refundSum refundSum number of tokens withdrawn. */ function withdrawToken(address _taker, uint256 _refundSum) public onlyOwnerOrPartner { require(status == StatusChoices.NO_LOAN); require(_taker != address(0) && _refundSum > 0); if (loanTokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _refundSum && ethAmount[_taker] >= _refundSum); _taker.transfer(_refundSum); ethAmount[_taker] = ethAmount[_taker].sub(_refundSum); } else { require(ERC20(token20).balanceOf(address(this)) >= _refundSum); require(safeErc20Transfer(_taker, _refundSum)); } emit WithdrawToken(_taker, _refundSum); } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(token20).transfer(_toAddress, _transferSum)); } return true; } /** * @dev Get current contract order status. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_LOAN) { pledgeStatus = "NO_LOAN"; } else if (status == StatusChoices.REPAYMENT_WAITING) { pledgeStatus = "REPAYMENT_WAITING"; } else if (status == StatusChoices.REPAYMENT_ALL) { pledgeStatus = "REPAYMENT_ALL"; } else if (status == StatusChoices.CLOSE_POSITION) { pledgeStatus = "CLOSE_POSITION"; } else { pledgeStatus = "OVERDUE_STOP"; } } }
/** * @title OrderManageContract * @dev Order process management contract. */
NatSpecMultiLine
withdrawToken
function withdrawToken(address _taker, uint256 _refundSum) public onlyOwnerOrPartner { require(status == StatusChoices.NO_LOAN); require(_taker != address(0) && _refundSum > 0); if (loanTokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _refundSum && ethAmount[_taker] >= _refundSum); _taker.transfer(_refundSum); ethAmount[_taker] = ethAmount[_taker].sub(_refundSum); } else { require(ERC20(token20).balanceOf(address(this)) >= _refundSum); require(safeErc20Transfer(_taker, _refundSum)); } emit WithdrawToken(_taker, _refundSum); }
/** * @dev Withdrawal of the token invested by the taker. * @param _taker address of investor. * @param _refundSum refundSum number of tokens withdrawn. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 5753, 6377 ] }
3,753
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
OrderManageContract
contract OrderManageContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Status of current business execution contract. */ enum StatusChoices { NO_LOAN, REPAYMENT_WAITING, REPAYMENT_ALL, CLOSE_POSITION, OVERDUE_STOP } string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; address public maker; address public taker; address internal token20; uint256 public toTime; // the amount of the borrower’s final loan. uint256 public outLoanSum; uint256 public repaymentSum; uint256 public lastRepaymentSum; string public loanTokenName; // Borrower's record of the pledge. StatusChoices internal status; // Record the amount of the borrower's offline transfer. mapping(address => uint256) public ethAmount; /** * Event for takerOrder logging. * @param taker address of investor. * @param outLoanSum the amount of the borrower’s final loan. */ event TakerOrder(address indexed taker, uint256 outLoanSum); /** * Event for executeOrder logging. * @param maker address of borrower. * @param lastRepaymentSum current order repayment amount. */ event ExecuteOrder(address indexed maker, uint256 lastRepaymentSum); /** * Event for forceCloseOrder logging. * @param toTime order repayment due date. * @param transferSum balance under current contract. */ event ForceCloseOrder(uint256 indexed toTime, uint256 transferSum); /** * Event for WithdrawToken logging. * @param taker address of investor. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed taker, uint256 refundSum); function() external payable { // Record basic information about the borrower's REPAYMENT ETH ethAmount[msg.sender] = ethAmount[msg.sender].add(msg.value); } /** * @dev Constructor initial contract configuration parameters * @param _loanTokenAddress order type supported by the token. */ constructor(string _loanTokenName, address _loanTokenAddress, address _maker) public { require(bytes(_loanTokenName).length > 0 && _maker != address(0)); if (!_loanTokenName.stringCompare(TOKEN_ETH)) { require(_loanTokenAddress != address(0)); token20 = _loanTokenAddress; } toTime = now; maker = _maker; loanTokenName = _loanTokenName; status = StatusChoices.NO_LOAN; } /** * @dev Complete an order combination and issue the loan to the borrower. * @param _taker address of investor. * @param _toTime order repayment due date. * @param _repaymentSum total amount of money that the borrower ultimately needs to return. */ function takerOrder(address _taker, uint32 _toTime, uint256 _repaymentSum) public onlyOwnerOrPartner { require(_taker != address(0) && _toTime > 0 && now <= _toTime && _repaymentSum > 0 && status == StatusChoices.NO_LOAN); taker = _taker; toTime = _toTime; repaymentSum = _repaymentSum; // Transfer the token provided by the investor to the borrower's address if (loanTokenName.stringCompare(TOKEN_ETH)) { require(ethAmount[_taker] > 0 && address(this).balance > 0); outLoanSum = address(this).balance; maker.transfer(outLoanSum); } else { require(token20 != address(0) && ERC20(token20).balanceOf(address(this)) > 0); outLoanSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(maker, outLoanSum)); } // Update contract business execution status. status = StatusChoices.REPAYMENT_WAITING; emit TakerOrder(taker, outLoanSum); } /** * @dev Only the full repayment will execute the contract agreement. */ function executeOrder() public onlyOwnerOrPartner { require(now <= toTime && status == StatusChoices.REPAYMENT_WAITING); // The borrower pays off the loan and performs two-way operation. if (loanTokenName.stringCompare(TOKEN_ETH)) { require(ethAmount[maker] >= repaymentSum && address(this).balance >= repaymentSum); lastRepaymentSum = address(this).balance; taker.transfer(repaymentSum); } else { require(ERC20(token20).balanceOf(address(this)) >= repaymentSum); lastRepaymentSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(taker, repaymentSum)); } PledgeContract(owner)._conclude(); status = StatusChoices.REPAYMENT_ALL; emit ExecuteOrder(maker, lastRepaymentSum); } /** * @dev Close position or due repayment operation. */ function forceCloseOrder() public onlyOwnerOrPartner { require(status == StatusChoices.REPAYMENT_WAITING); uint256 transferSum = 0; if (now <= toTime) { status = StatusChoices.CLOSE_POSITION; } else { status = StatusChoices.OVERDUE_STOP; } if(loanTokenName.stringCompare(TOKEN_ETH)){ if(ethAmount[maker] > 0 && address(this).balance > 0){ transferSum = address(this).balance; maker.transfer(transferSum); } }else{ if(ERC20(token20).balanceOf(address(this)) > 0){ transferSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(maker, transferSum)); } } // Return pledge token. PledgeContract(owner)._forceConclude(taker); emit ForceCloseOrder(toTime, transferSum); } /** * @dev Withdrawal of the token invested by the taker. * @param _taker address of investor. * @param _refundSum refundSum number of tokens withdrawn. */ function withdrawToken(address _taker, uint256 _refundSum) public onlyOwnerOrPartner { require(status == StatusChoices.NO_LOAN); require(_taker != address(0) && _refundSum > 0); if (loanTokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _refundSum && ethAmount[_taker] >= _refundSum); _taker.transfer(_refundSum); ethAmount[_taker] = ethAmount[_taker].sub(_refundSum); } else { require(ERC20(token20).balanceOf(address(this)) >= _refundSum); require(safeErc20Transfer(_taker, _refundSum)); } emit WithdrawToken(_taker, _refundSum); } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(token20).transfer(_toAddress, _transferSum)); } return true; } /** * @dev Get current contract order status. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_LOAN) { pledgeStatus = "NO_LOAN"; } else if (status == StatusChoices.REPAYMENT_WAITING) { pledgeStatus = "REPAYMENT_WAITING"; } else if (status == StatusChoices.REPAYMENT_ALL) { pledgeStatus = "REPAYMENT_ALL"; } else if (status == StatusChoices.CLOSE_POSITION) { pledgeStatus = "CLOSE_POSITION"; } else { pledgeStatus = "OVERDUE_STOP"; } } }
/** * @title OrderManageContract * @dev Order process management contract. */
NatSpecMultiLine
safeErc20Transfer
function safeErc20Transfer(address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(token20).transfer(_toAddress, _transferSum)); } return true; }
/** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 6766, 7083 ] }
3,754
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
OrderManageContract
contract OrderManageContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Status of current business execution contract. */ enum StatusChoices { NO_LOAN, REPAYMENT_WAITING, REPAYMENT_ALL, CLOSE_POSITION, OVERDUE_STOP } string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; address public maker; address public taker; address internal token20; uint256 public toTime; // the amount of the borrower’s final loan. uint256 public outLoanSum; uint256 public repaymentSum; uint256 public lastRepaymentSum; string public loanTokenName; // Borrower's record of the pledge. StatusChoices internal status; // Record the amount of the borrower's offline transfer. mapping(address => uint256) public ethAmount; /** * Event for takerOrder logging. * @param taker address of investor. * @param outLoanSum the amount of the borrower’s final loan. */ event TakerOrder(address indexed taker, uint256 outLoanSum); /** * Event for executeOrder logging. * @param maker address of borrower. * @param lastRepaymentSum current order repayment amount. */ event ExecuteOrder(address indexed maker, uint256 lastRepaymentSum); /** * Event for forceCloseOrder logging. * @param toTime order repayment due date. * @param transferSum balance under current contract. */ event ForceCloseOrder(uint256 indexed toTime, uint256 transferSum); /** * Event for WithdrawToken logging. * @param taker address of investor. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed taker, uint256 refundSum); function() external payable { // Record basic information about the borrower's REPAYMENT ETH ethAmount[msg.sender] = ethAmount[msg.sender].add(msg.value); } /** * @dev Constructor initial contract configuration parameters * @param _loanTokenAddress order type supported by the token. */ constructor(string _loanTokenName, address _loanTokenAddress, address _maker) public { require(bytes(_loanTokenName).length > 0 && _maker != address(0)); if (!_loanTokenName.stringCompare(TOKEN_ETH)) { require(_loanTokenAddress != address(0)); token20 = _loanTokenAddress; } toTime = now; maker = _maker; loanTokenName = _loanTokenName; status = StatusChoices.NO_LOAN; } /** * @dev Complete an order combination and issue the loan to the borrower. * @param _taker address of investor. * @param _toTime order repayment due date. * @param _repaymentSum total amount of money that the borrower ultimately needs to return. */ function takerOrder(address _taker, uint32 _toTime, uint256 _repaymentSum) public onlyOwnerOrPartner { require(_taker != address(0) && _toTime > 0 && now <= _toTime && _repaymentSum > 0 && status == StatusChoices.NO_LOAN); taker = _taker; toTime = _toTime; repaymentSum = _repaymentSum; // Transfer the token provided by the investor to the borrower's address if (loanTokenName.stringCompare(TOKEN_ETH)) { require(ethAmount[_taker] > 0 && address(this).balance > 0); outLoanSum = address(this).balance; maker.transfer(outLoanSum); } else { require(token20 != address(0) && ERC20(token20).balanceOf(address(this)) > 0); outLoanSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(maker, outLoanSum)); } // Update contract business execution status. status = StatusChoices.REPAYMENT_WAITING; emit TakerOrder(taker, outLoanSum); } /** * @dev Only the full repayment will execute the contract agreement. */ function executeOrder() public onlyOwnerOrPartner { require(now <= toTime && status == StatusChoices.REPAYMENT_WAITING); // The borrower pays off the loan and performs two-way operation. if (loanTokenName.stringCompare(TOKEN_ETH)) { require(ethAmount[maker] >= repaymentSum && address(this).balance >= repaymentSum); lastRepaymentSum = address(this).balance; taker.transfer(repaymentSum); } else { require(ERC20(token20).balanceOf(address(this)) >= repaymentSum); lastRepaymentSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(taker, repaymentSum)); } PledgeContract(owner)._conclude(); status = StatusChoices.REPAYMENT_ALL; emit ExecuteOrder(maker, lastRepaymentSum); } /** * @dev Close position or due repayment operation. */ function forceCloseOrder() public onlyOwnerOrPartner { require(status == StatusChoices.REPAYMENT_WAITING); uint256 transferSum = 0; if (now <= toTime) { status = StatusChoices.CLOSE_POSITION; } else { status = StatusChoices.OVERDUE_STOP; } if(loanTokenName.stringCompare(TOKEN_ETH)){ if(ethAmount[maker] > 0 && address(this).balance > 0){ transferSum = address(this).balance; maker.transfer(transferSum); } }else{ if(ERC20(token20).balanceOf(address(this)) > 0){ transferSum = ERC20(token20).balanceOf(address(this)); require(safeErc20Transfer(maker, transferSum)); } } // Return pledge token. PledgeContract(owner)._forceConclude(taker); emit ForceCloseOrder(toTime, transferSum); } /** * @dev Withdrawal of the token invested by the taker. * @param _taker address of investor. * @param _refundSum refundSum number of tokens withdrawn. */ function withdrawToken(address _taker, uint256 _refundSum) public onlyOwnerOrPartner { require(status == StatusChoices.NO_LOAN); require(_taker != address(0) && _refundSum > 0); if (loanTokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _refundSum && ethAmount[_taker] >= _refundSum); _taker.transfer(_refundSum); ethAmount[_taker] = ethAmount[_taker].sub(_refundSum); } else { require(ERC20(token20).balanceOf(address(this)) >= _refundSum); require(safeErc20Transfer(_taker, _refundSum)); } emit WithdrawToken(_taker, _refundSum); } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(token20).transfer(_toAddress, _transferSum)); } return true; } /** * @dev Get current contract order status. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_LOAN) { pledgeStatus = "NO_LOAN"; } else if (status == StatusChoices.REPAYMENT_WAITING) { pledgeStatus = "REPAYMENT_WAITING"; } else if (status == StatusChoices.REPAYMENT_ALL) { pledgeStatus = "REPAYMENT_ALL"; } else if (status == StatusChoices.CLOSE_POSITION) { pledgeStatus = "CLOSE_POSITION"; } else { pledgeStatus = "OVERDUE_STOP"; } } }
/** * @title OrderManageContract * @dev Order process management contract. */
NatSpecMultiLine
getPledgeStatus
function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_LOAN) { pledgeStatus = "NO_LOAN"; } else if (status == StatusChoices.REPAYMENT_WAITING) { pledgeStatus = "REPAYMENT_WAITING"; } else if (status == StatusChoices.REPAYMENT_ALL) { pledgeStatus = "REPAYMENT_ALL"; } else if (status == StatusChoices.CLOSE_POSITION) { pledgeStatus = "CLOSE_POSITION"; } else { pledgeStatus = "OVERDUE_STOP"; } }
/** * @dev Get current contract order status. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 7150, 7661 ] }
3,755
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeFactory
contract PledgeFactory is RBACOperator { using AddressUtils for address; // initial type of pledge contract. string internal constant INIT_TOKEN_NAME = "UNKNOWN"; mapping(uint256 => EscrowPledge) internal pledgeEscrowById; // pledge number unique screening. mapping(uint256 => bool) internal isPledgeId; /** * @dev Pledge guarantee statistics. */ struct EscrowPledge { address pledgeContract; string tokenName; } /** * Event for createOrderContract logging. * @param pledgeId management contract id. * @param newPledgeAddress pledge management contract address. */ event CreatePledgeContract(uint256 indexed pledgeId, address newPledgeAddress); /** * @dev Create a pledge subcontract * @param _pledgeId index number of the pledge contract. */ function createPledgeContract(uint256 _pledgeId, address _escrowPartner) public onlyPartner returns(bool) { require(_pledgeId > 0 && !isPledgeId[_pledgeId] && _escrowPartner!=address(0)); // Give the pledge contract the right to update statistics. PledgeContract pledgeAddress = new PledgeContract(_pledgeId, address(this),partner); pledgeAddress.transferOwnership(_escrowPartner); addOperater(address(pledgeAddress)); // update pledge contract info isPledgeId[_pledgeId] = true; pledgeEscrowById[_pledgeId] = EscrowPledge(pledgeAddress, INIT_TOKEN_NAME); emit CreatePledgeContract(_pledgeId, address(pledgeAddress)); return true; } /** * @dev Batch create a pledge subcontract * @param _pledgeIds index number of the pledge contract. */ function batchCreatePledgeContract(uint256[] _pledgeIds, address _escrowPartner) public onlyPartner { require(_pledgeIds.length > 0 && _escrowPartner.isContract()); for (uint i = 0; i < _pledgeIds.length; i++) { require(createPledgeContract(_pledgeIds[i],_escrowPartner)); } } /** * @dev Use the index to get the basic information of the corresponding pledge contract. * @param _pledgeId index number of the pledge contract */ function getEscrowPledge(uint256 _pledgeId) public view returns(string tokenName, address pledgeContract) { require(_pledgeId > 0); tokenName = pledgeEscrowById[_pledgeId].tokenName; pledgeContract = pledgeEscrowById[_pledgeId].pledgeContract; } // ----------------------------------------- // Internal interface (Only the pledge contract has authority to operate) // ----------------------------------------- /** * @dev Configure permissions to operate on the token pool. * @param _tokenPool token pool contract address. * @param _pledge pledge contract address. */ function tokenPoolOperater(address _tokenPool, address _pledge) public hasOperationPermission { require(_pledge != address(0) && address(msg.sender).isContract() && address(msg.sender) == _pledge); PledgePoolBase(_tokenPool).addOperater(_pledge); } /** * @dev Update the basic data of the pledge contract. * @param _pledgeId index number of the pledge contract. * @param _tokenName pledge contract supported token type. */ function updatePledgeType(uint256 _pledgeId, string _tokenName) public hasOperationPermission { require(_pledgeId > 0 && bytes(_tokenName).length > 0 && address(msg.sender).isContract()); pledgeEscrowById[_pledgeId].tokenName = _tokenName; } }
/** * @title PledgeFactory * @dev Pledge factory contract. * @dev Specially provides the pledge guarantee creation and the statistics function. */
NatSpecMultiLine
createPledgeContract
function createPledgeContract(uint256 _pledgeId, address _escrowPartner) public onlyPartner returns(bool) { require(_pledgeId > 0 && !isPledgeId[_pledgeId] && _escrowPartner!=address(0)); // Give the pledge contract the right to update statistics. PledgeContract pledgeAddress = new PledgeContract(_pledgeId, address(this),partner); pledgeAddress.transferOwnership(_escrowPartner); addOperater(address(pledgeAddress)); // update pledge contract info isPledgeId[_pledgeId] = true; pledgeEscrowById[_pledgeId] = EscrowPledge(pledgeAddress, INIT_TOKEN_NAME); emit CreatePledgeContract(_pledgeId, address(pledgeAddress)); return true; }
/** * @dev Create a pledge subcontract * @param _pledgeId index number of the pledge contract. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 838, 1532 ] }
3,756
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeFactory
contract PledgeFactory is RBACOperator { using AddressUtils for address; // initial type of pledge contract. string internal constant INIT_TOKEN_NAME = "UNKNOWN"; mapping(uint256 => EscrowPledge) internal pledgeEscrowById; // pledge number unique screening. mapping(uint256 => bool) internal isPledgeId; /** * @dev Pledge guarantee statistics. */ struct EscrowPledge { address pledgeContract; string tokenName; } /** * Event for createOrderContract logging. * @param pledgeId management contract id. * @param newPledgeAddress pledge management contract address. */ event CreatePledgeContract(uint256 indexed pledgeId, address newPledgeAddress); /** * @dev Create a pledge subcontract * @param _pledgeId index number of the pledge contract. */ function createPledgeContract(uint256 _pledgeId, address _escrowPartner) public onlyPartner returns(bool) { require(_pledgeId > 0 && !isPledgeId[_pledgeId] && _escrowPartner!=address(0)); // Give the pledge contract the right to update statistics. PledgeContract pledgeAddress = new PledgeContract(_pledgeId, address(this),partner); pledgeAddress.transferOwnership(_escrowPartner); addOperater(address(pledgeAddress)); // update pledge contract info isPledgeId[_pledgeId] = true; pledgeEscrowById[_pledgeId] = EscrowPledge(pledgeAddress, INIT_TOKEN_NAME); emit CreatePledgeContract(_pledgeId, address(pledgeAddress)); return true; } /** * @dev Batch create a pledge subcontract * @param _pledgeIds index number of the pledge contract. */ function batchCreatePledgeContract(uint256[] _pledgeIds, address _escrowPartner) public onlyPartner { require(_pledgeIds.length > 0 && _escrowPartner.isContract()); for (uint i = 0; i < _pledgeIds.length; i++) { require(createPledgeContract(_pledgeIds[i],_escrowPartner)); } } /** * @dev Use the index to get the basic information of the corresponding pledge contract. * @param _pledgeId index number of the pledge contract */ function getEscrowPledge(uint256 _pledgeId) public view returns(string tokenName, address pledgeContract) { require(_pledgeId > 0); tokenName = pledgeEscrowById[_pledgeId].tokenName; pledgeContract = pledgeEscrowById[_pledgeId].pledgeContract; } // ----------------------------------------- // Internal interface (Only the pledge contract has authority to operate) // ----------------------------------------- /** * @dev Configure permissions to operate on the token pool. * @param _tokenPool token pool contract address. * @param _pledge pledge contract address. */ function tokenPoolOperater(address _tokenPool, address _pledge) public hasOperationPermission { require(_pledge != address(0) && address(msg.sender).isContract() && address(msg.sender) == _pledge); PledgePoolBase(_tokenPool).addOperater(_pledge); } /** * @dev Update the basic data of the pledge contract. * @param _pledgeId index number of the pledge contract. * @param _tokenName pledge contract supported token type. */ function updatePledgeType(uint256 _pledgeId, string _tokenName) public hasOperationPermission { require(_pledgeId > 0 && bytes(_tokenName).length > 0 && address(msg.sender).isContract()); pledgeEscrowById[_pledgeId].tokenName = _tokenName; } }
/** * @title PledgeFactory * @dev Pledge factory contract. * @dev Specially provides the pledge guarantee creation and the statistics function. */
NatSpecMultiLine
batchCreatePledgeContract
function batchCreatePledgeContract(uint256[] _pledgeIds, address _escrowPartner) public onlyPartner { require(_pledgeIds.length > 0 && _escrowPartner.isContract()); for (uint i = 0; i < _pledgeIds.length; i++) { require(createPledgeContract(_pledgeIds[i],_escrowPartner)); } }
/** * @dev Batch create a pledge subcontract * @param _pledgeIds index number of the pledge contract. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 1659, 1963 ] }
3,757
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeFactory
contract PledgeFactory is RBACOperator { using AddressUtils for address; // initial type of pledge contract. string internal constant INIT_TOKEN_NAME = "UNKNOWN"; mapping(uint256 => EscrowPledge) internal pledgeEscrowById; // pledge number unique screening. mapping(uint256 => bool) internal isPledgeId; /** * @dev Pledge guarantee statistics. */ struct EscrowPledge { address pledgeContract; string tokenName; } /** * Event for createOrderContract logging. * @param pledgeId management contract id. * @param newPledgeAddress pledge management contract address. */ event CreatePledgeContract(uint256 indexed pledgeId, address newPledgeAddress); /** * @dev Create a pledge subcontract * @param _pledgeId index number of the pledge contract. */ function createPledgeContract(uint256 _pledgeId, address _escrowPartner) public onlyPartner returns(bool) { require(_pledgeId > 0 && !isPledgeId[_pledgeId] && _escrowPartner!=address(0)); // Give the pledge contract the right to update statistics. PledgeContract pledgeAddress = new PledgeContract(_pledgeId, address(this),partner); pledgeAddress.transferOwnership(_escrowPartner); addOperater(address(pledgeAddress)); // update pledge contract info isPledgeId[_pledgeId] = true; pledgeEscrowById[_pledgeId] = EscrowPledge(pledgeAddress, INIT_TOKEN_NAME); emit CreatePledgeContract(_pledgeId, address(pledgeAddress)); return true; } /** * @dev Batch create a pledge subcontract * @param _pledgeIds index number of the pledge contract. */ function batchCreatePledgeContract(uint256[] _pledgeIds, address _escrowPartner) public onlyPartner { require(_pledgeIds.length > 0 && _escrowPartner.isContract()); for (uint i = 0; i < _pledgeIds.length; i++) { require(createPledgeContract(_pledgeIds[i],_escrowPartner)); } } /** * @dev Use the index to get the basic information of the corresponding pledge contract. * @param _pledgeId index number of the pledge contract */ function getEscrowPledge(uint256 _pledgeId) public view returns(string tokenName, address pledgeContract) { require(_pledgeId > 0); tokenName = pledgeEscrowById[_pledgeId].tokenName; pledgeContract = pledgeEscrowById[_pledgeId].pledgeContract; } // ----------------------------------------- // Internal interface (Only the pledge contract has authority to operate) // ----------------------------------------- /** * @dev Configure permissions to operate on the token pool. * @param _tokenPool token pool contract address. * @param _pledge pledge contract address. */ function tokenPoolOperater(address _tokenPool, address _pledge) public hasOperationPermission { require(_pledge != address(0) && address(msg.sender).isContract() && address(msg.sender) == _pledge); PledgePoolBase(_tokenPool).addOperater(_pledge); } /** * @dev Update the basic data of the pledge contract. * @param _pledgeId index number of the pledge contract. * @param _tokenName pledge contract supported token type. */ function updatePledgeType(uint256 _pledgeId, string _tokenName) public hasOperationPermission { require(_pledgeId > 0 && bytes(_tokenName).length > 0 && address(msg.sender).isContract()); pledgeEscrowById[_pledgeId].tokenName = _tokenName; } }
/** * @title PledgeFactory * @dev Pledge factory contract. * @dev Specially provides the pledge guarantee creation and the statistics function. */
NatSpecMultiLine
getEscrowPledge
function getEscrowPledge(uint256 _pledgeId) public view returns(string tokenName, address pledgeContract) { require(_pledgeId > 0); tokenName = pledgeEscrowById[_pledgeId].tokenName; pledgeContract = pledgeEscrowById[_pledgeId].pledgeContract; }
/** * @dev Use the index to get the basic information of the corresponding pledge contract. * @param _pledgeId index number of the pledge contract */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 2131, 2397 ] }
3,758
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeFactory
contract PledgeFactory is RBACOperator { using AddressUtils for address; // initial type of pledge contract. string internal constant INIT_TOKEN_NAME = "UNKNOWN"; mapping(uint256 => EscrowPledge) internal pledgeEscrowById; // pledge number unique screening. mapping(uint256 => bool) internal isPledgeId; /** * @dev Pledge guarantee statistics. */ struct EscrowPledge { address pledgeContract; string tokenName; } /** * Event for createOrderContract logging. * @param pledgeId management contract id. * @param newPledgeAddress pledge management contract address. */ event CreatePledgeContract(uint256 indexed pledgeId, address newPledgeAddress); /** * @dev Create a pledge subcontract * @param _pledgeId index number of the pledge contract. */ function createPledgeContract(uint256 _pledgeId, address _escrowPartner) public onlyPartner returns(bool) { require(_pledgeId > 0 && !isPledgeId[_pledgeId] && _escrowPartner!=address(0)); // Give the pledge contract the right to update statistics. PledgeContract pledgeAddress = new PledgeContract(_pledgeId, address(this),partner); pledgeAddress.transferOwnership(_escrowPartner); addOperater(address(pledgeAddress)); // update pledge contract info isPledgeId[_pledgeId] = true; pledgeEscrowById[_pledgeId] = EscrowPledge(pledgeAddress, INIT_TOKEN_NAME); emit CreatePledgeContract(_pledgeId, address(pledgeAddress)); return true; } /** * @dev Batch create a pledge subcontract * @param _pledgeIds index number of the pledge contract. */ function batchCreatePledgeContract(uint256[] _pledgeIds, address _escrowPartner) public onlyPartner { require(_pledgeIds.length > 0 && _escrowPartner.isContract()); for (uint i = 0; i < _pledgeIds.length; i++) { require(createPledgeContract(_pledgeIds[i],_escrowPartner)); } } /** * @dev Use the index to get the basic information of the corresponding pledge contract. * @param _pledgeId index number of the pledge contract */ function getEscrowPledge(uint256 _pledgeId) public view returns(string tokenName, address pledgeContract) { require(_pledgeId > 0); tokenName = pledgeEscrowById[_pledgeId].tokenName; pledgeContract = pledgeEscrowById[_pledgeId].pledgeContract; } // ----------------------------------------- // Internal interface (Only the pledge contract has authority to operate) // ----------------------------------------- /** * @dev Configure permissions to operate on the token pool. * @param _tokenPool token pool contract address. * @param _pledge pledge contract address. */ function tokenPoolOperater(address _tokenPool, address _pledge) public hasOperationPermission { require(_pledge != address(0) && address(msg.sender).isContract() && address(msg.sender) == _pledge); PledgePoolBase(_tokenPool).addOperater(_pledge); } /** * @dev Update the basic data of the pledge contract. * @param _pledgeId index number of the pledge contract. * @param _tokenName pledge contract supported token type. */ function updatePledgeType(uint256 _pledgeId, string _tokenName) public hasOperationPermission { require(_pledgeId > 0 && bytes(_tokenName).length > 0 && address(msg.sender).isContract()); pledgeEscrowById[_pledgeId].tokenName = _tokenName; } }
/** * @title PledgeFactory * @dev Pledge factory contract. * @dev Specially provides the pledge guarantee creation and the statistics function. */
NatSpecMultiLine
tokenPoolOperater
function tokenPoolOperater(address _tokenPool, address _pledge) public hasOperationPermission { require(_pledge != address(0) && address(msg.sender).isContract() && address(msg.sender) == _pledge); PledgePoolBase(_tokenPool).addOperater(_pledge); }
/** * @dev Configure permissions to operate on the token pool. * @param _tokenPool token pool contract address. * @param _pledge pledge contract address. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 2759, 3023 ] }
3,759
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeFactory
contract PledgeFactory is RBACOperator { using AddressUtils for address; // initial type of pledge contract. string internal constant INIT_TOKEN_NAME = "UNKNOWN"; mapping(uint256 => EscrowPledge) internal pledgeEscrowById; // pledge number unique screening. mapping(uint256 => bool) internal isPledgeId; /** * @dev Pledge guarantee statistics. */ struct EscrowPledge { address pledgeContract; string tokenName; } /** * Event for createOrderContract logging. * @param pledgeId management contract id. * @param newPledgeAddress pledge management contract address. */ event CreatePledgeContract(uint256 indexed pledgeId, address newPledgeAddress); /** * @dev Create a pledge subcontract * @param _pledgeId index number of the pledge contract. */ function createPledgeContract(uint256 _pledgeId, address _escrowPartner) public onlyPartner returns(bool) { require(_pledgeId > 0 && !isPledgeId[_pledgeId] && _escrowPartner!=address(0)); // Give the pledge contract the right to update statistics. PledgeContract pledgeAddress = new PledgeContract(_pledgeId, address(this),partner); pledgeAddress.transferOwnership(_escrowPartner); addOperater(address(pledgeAddress)); // update pledge contract info isPledgeId[_pledgeId] = true; pledgeEscrowById[_pledgeId] = EscrowPledge(pledgeAddress, INIT_TOKEN_NAME); emit CreatePledgeContract(_pledgeId, address(pledgeAddress)); return true; } /** * @dev Batch create a pledge subcontract * @param _pledgeIds index number of the pledge contract. */ function batchCreatePledgeContract(uint256[] _pledgeIds, address _escrowPartner) public onlyPartner { require(_pledgeIds.length > 0 && _escrowPartner.isContract()); for (uint i = 0; i < _pledgeIds.length; i++) { require(createPledgeContract(_pledgeIds[i],_escrowPartner)); } } /** * @dev Use the index to get the basic information of the corresponding pledge contract. * @param _pledgeId index number of the pledge contract */ function getEscrowPledge(uint256 _pledgeId) public view returns(string tokenName, address pledgeContract) { require(_pledgeId > 0); tokenName = pledgeEscrowById[_pledgeId].tokenName; pledgeContract = pledgeEscrowById[_pledgeId].pledgeContract; } // ----------------------------------------- // Internal interface (Only the pledge contract has authority to operate) // ----------------------------------------- /** * @dev Configure permissions to operate on the token pool. * @param _tokenPool token pool contract address. * @param _pledge pledge contract address. */ function tokenPoolOperater(address _tokenPool, address _pledge) public hasOperationPermission { require(_pledge != address(0) && address(msg.sender).isContract() && address(msg.sender) == _pledge); PledgePoolBase(_tokenPool).addOperater(_pledge); } /** * @dev Update the basic data of the pledge contract. * @param _pledgeId index number of the pledge contract. * @param _tokenName pledge contract supported token type. */ function updatePledgeType(uint256 _pledgeId, string _tokenName) public hasOperationPermission { require(_pledgeId > 0 && bytes(_tokenName).length > 0 && address(msg.sender).isContract()); pledgeEscrowById[_pledgeId].tokenName = _tokenName; } }
/** * @title PledgeFactory * @dev Pledge factory contract. * @dev Specially provides the pledge guarantee creation and the statistics function. */
NatSpecMultiLine
updatePledgeType
function updatePledgeType(uint256 _pledgeId, string _tokenName) public hasOperationPermission { require(_pledgeId > 0 && bytes(_tokenName).length > 0 && address(msg.sender).isContract()); pledgeEscrowById[_pledgeId].tokenName = _tokenName; }
/** * @dev Update the basic data of the pledge contract. * @param _pledgeId index number of the pledge contract. * @param _tokenName pledge contract supported token type. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 3221, 3478 ] }
3,760
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
EscrowMaintainContract
contract EscrowMaintainContract is PartnerAuthority { address public pledgeFactory; // map of token name to token pool address; mapping(string => address) internal nameByPool; // map of token name to erc20 token address; mapping(string => address) internal nameByToken; // ----------------------------------------- // External interface // ----------------------------------------- /** * @dev Create a pledge subcontract * @param _pledgeId index number of the pledge contract. */ function createPledgeContract(uint256 _pledgeId) public onlyPartner returns(bool) { require(_pledgeId > 0 && pledgeFactory!=address(0)); require(PledgeFactory(pledgeFactory).createPledgeContract(_pledgeId,partner)); return true; } /** * @dev Batch create a pledge subcontract * @param _pledgeIds index number of the pledge contract. */ function batchCreatePledgeContract(uint256[] _pledgeIds) public onlyPartner { require(_pledgeIds.length > 0); PledgeFactory(pledgeFactory).batchCreatePledgeContract(_pledgeIds,partner); } /** * @dev Use the index to get the basic information of the corresponding pledge contract. * @param _pledgeId index number of the pledge contract */ function getEscrowPledge(uint256 _pledgeId) public view returns(string tokenName, address pledgeContract) { require(_pledgeId > 0); (tokenName,pledgeContract) = PledgeFactory(pledgeFactory).getEscrowPledge(_pledgeId); } /** * @dev setTokenPool, set the token pool contract address of a token name. * @param _tokenName set token pool name. * @param _address the token pool contract address. */ function setTokenPool(string _tokenName, address _address) public onlyOwner { require(_address != address(0) && bytes(_tokenName).length > 0); nameByPool[_tokenName] = _address; } /** * @dev setToken, set the token contract address of a token name. * @param _tokenName token name * @param _address the ERC20 token contract address. */ function setToken(string _tokenName, address _address) public onlyOwner { require(_address != address(0) && bytes(_tokenName).length > 0); nameByToken[_tokenName] = _address; } /** * @dev setPledgeFactory, Plant contract for configuration management pledge business. * @param _factory pledge factory contract. */ function setPledgeFactory(address _factory) public onlyOwner { require(_factory != address(0)); pledgeFactory = _factory; } /** * @dev Checks whether the current token pool is supported. * @param _tokenName token name */ function includeTokenPool(string _tokenName) view public returns(address) { require(bytes(_tokenName).length > 0); return nameByPool[_tokenName]; } /** * @dev Checks whether the current erc20 token is supported. * @param _tokenName token name */ function includeToken(string _tokenName) view public returns(address) { require(bytes(_tokenName).length > 0); return nameByToken[_tokenName]; } }
/** * @title EscrowMaintainContract * @dev Provides configuration and external interfaces. */
NatSpecMultiLine
createPledgeContract
function createPledgeContract(uint256 _pledgeId) public onlyPartner returns(bool) { require(_pledgeId > 0 && pledgeFactory!=address(0)); require(PledgeFactory(pledgeFactory).createPledgeContract(_pledgeId,partner)); return true; }
/** * @dev Create a pledge subcontract * @param _pledgeId index number of the pledge contract. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 530, 781 ] }
3,761
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
EscrowMaintainContract
contract EscrowMaintainContract is PartnerAuthority { address public pledgeFactory; // map of token name to token pool address; mapping(string => address) internal nameByPool; // map of token name to erc20 token address; mapping(string => address) internal nameByToken; // ----------------------------------------- // External interface // ----------------------------------------- /** * @dev Create a pledge subcontract * @param _pledgeId index number of the pledge contract. */ function createPledgeContract(uint256 _pledgeId) public onlyPartner returns(bool) { require(_pledgeId > 0 && pledgeFactory!=address(0)); require(PledgeFactory(pledgeFactory).createPledgeContract(_pledgeId,partner)); return true; } /** * @dev Batch create a pledge subcontract * @param _pledgeIds index number of the pledge contract. */ function batchCreatePledgeContract(uint256[] _pledgeIds) public onlyPartner { require(_pledgeIds.length > 0); PledgeFactory(pledgeFactory).batchCreatePledgeContract(_pledgeIds,partner); } /** * @dev Use the index to get the basic information of the corresponding pledge contract. * @param _pledgeId index number of the pledge contract */ function getEscrowPledge(uint256 _pledgeId) public view returns(string tokenName, address pledgeContract) { require(_pledgeId > 0); (tokenName,pledgeContract) = PledgeFactory(pledgeFactory).getEscrowPledge(_pledgeId); } /** * @dev setTokenPool, set the token pool contract address of a token name. * @param _tokenName set token pool name. * @param _address the token pool contract address. */ function setTokenPool(string _tokenName, address _address) public onlyOwner { require(_address != address(0) && bytes(_tokenName).length > 0); nameByPool[_tokenName] = _address; } /** * @dev setToken, set the token contract address of a token name. * @param _tokenName token name * @param _address the ERC20 token contract address. */ function setToken(string _tokenName, address _address) public onlyOwner { require(_address != address(0) && bytes(_tokenName).length > 0); nameByToken[_tokenName] = _address; } /** * @dev setPledgeFactory, Plant contract for configuration management pledge business. * @param _factory pledge factory contract. */ function setPledgeFactory(address _factory) public onlyOwner { require(_factory != address(0)); pledgeFactory = _factory; } /** * @dev Checks whether the current token pool is supported. * @param _tokenName token name */ function includeTokenPool(string _tokenName) view public returns(address) { require(bytes(_tokenName).length > 0); return nameByPool[_tokenName]; } /** * @dev Checks whether the current erc20 token is supported. * @param _tokenName token name */ function includeToken(string _tokenName) view public returns(address) { require(bytes(_tokenName).length > 0); return nameByToken[_tokenName]; } }
/** * @title EscrowMaintainContract * @dev Provides configuration and external interfaces. */
NatSpecMultiLine
batchCreatePledgeContract
function batchCreatePledgeContract(uint256[] _pledgeIds) public onlyPartner { require(_pledgeIds.length > 0); PledgeFactory(pledgeFactory).batchCreatePledgeContract(_pledgeIds,partner); }
/** * @dev Batch create a pledge subcontract * @param _pledgeIds index number of the pledge contract. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 906, 1109 ] }
3,762
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
EscrowMaintainContract
contract EscrowMaintainContract is PartnerAuthority { address public pledgeFactory; // map of token name to token pool address; mapping(string => address) internal nameByPool; // map of token name to erc20 token address; mapping(string => address) internal nameByToken; // ----------------------------------------- // External interface // ----------------------------------------- /** * @dev Create a pledge subcontract * @param _pledgeId index number of the pledge contract. */ function createPledgeContract(uint256 _pledgeId) public onlyPartner returns(bool) { require(_pledgeId > 0 && pledgeFactory!=address(0)); require(PledgeFactory(pledgeFactory).createPledgeContract(_pledgeId,partner)); return true; } /** * @dev Batch create a pledge subcontract * @param _pledgeIds index number of the pledge contract. */ function batchCreatePledgeContract(uint256[] _pledgeIds) public onlyPartner { require(_pledgeIds.length > 0); PledgeFactory(pledgeFactory).batchCreatePledgeContract(_pledgeIds,partner); } /** * @dev Use the index to get the basic information of the corresponding pledge contract. * @param _pledgeId index number of the pledge contract */ function getEscrowPledge(uint256 _pledgeId) public view returns(string tokenName, address pledgeContract) { require(_pledgeId > 0); (tokenName,pledgeContract) = PledgeFactory(pledgeFactory).getEscrowPledge(_pledgeId); } /** * @dev setTokenPool, set the token pool contract address of a token name. * @param _tokenName set token pool name. * @param _address the token pool contract address. */ function setTokenPool(string _tokenName, address _address) public onlyOwner { require(_address != address(0) && bytes(_tokenName).length > 0); nameByPool[_tokenName] = _address; } /** * @dev setToken, set the token contract address of a token name. * @param _tokenName token name * @param _address the ERC20 token contract address. */ function setToken(string _tokenName, address _address) public onlyOwner { require(_address != address(0) && bytes(_tokenName).length > 0); nameByToken[_tokenName] = _address; } /** * @dev setPledgeFactory, Plant contract for configuration management pledge business. * @param _factory pledge factory contract. */ function setPledgeFactory(address _factory) public onlyOwner { require(_factory != address(0)); pledgeFactory = _factory; } /** * @dev Checks whether the current token pool is supported. * @param _tokenName token name */ function includeTokenPool(string _tokenName) view public returns(address) { require(bytes(_tokenName).length > 0); return nameByPool[_tokenName]; } /** * @dev Checks whether the current erc20 token is supported. * @param _tokenName token name */ function includeToken(string _tokenName) view public returns(address) { require(bytes(_tokenName).length > 0); return nameByToken[_tokenName]; } }
/** * @title EscrowMaintainContract * @dev Provides configuration and external interfaces. */
NatSpecMultiLine
getEscrowPledge
function getEscrowPledge(uint256 _pledgeId) public view returns(string tokenName, address pledgeContract) { require(_pledgeId > 0); (tokenName,pledgeContract) = PledgeFactory(pledgeFactory).getEscrowPledge(_pledgeId); }
/** * @dev Use the index to get the basic information of the corresponding pledge contract. * @param _pledgeId index number of the pledge contract */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 1279, 1514 ] }
3,763
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
EscrowMaintainContract
contract EscrowMaintainContract is PartnerAuthority { address public pledgeFactory; // map of token name to token pool address; mapping(string => address) internal nameByPool; // map of token name to erc20 token address; mapping(string => address) internal nameByToken; // ----------------------------------------- // External interface // ----------------------------------------- /** * @dev Create a pledge subcontract * @param _pledgeId index number of the pledge contract. */ function createPledgeContract(uint256 _pledgeId) public onlyPartner returns(bool) { require(_pledgeId > 0 && pledgeFactory!=address(0)); require(PledgeFactory(pledgeFactory).createPledgeContract(_pledgeId,partner)); return true; } /** * @dev Batch create a pledge subcontract * @param _pledgeIds index number of the pledge contract. */ function batchCreatePledgeContract(uint256[] _pledgeIds) public onlyPartner { require(_pledgeIds.length > 0); PledgeFactory(pledgeFactory).batchCreatePledgeContract(_pledgeIds,partner); } /** * @dev Use the index to get the basic information of the corresponding pledge contract. * @param _pledgeId index number of the pledge contract */ function getEscrowPledge(uint256 _pledgeId) public view returns(string tokenName, address pledgeContract) { require(_pledgeId > 0); (tokenName,pledgeContract) = PledgeFactory(pledgeFactory).getEscrowPledge(_pledgeId); } /** * @dev setTokenPool, set the token pool contract address of a token name. * @param _tokenName set token pool name. * @param _address the token pool contract address. */ function setTokenPool(string _tokenName, address _address) public onlyOwner { require(_address != address(0) && bytes(_tokenName).length > 0); nameByPool[_tokenName] = _address; } /** * @dev setToken, set the token contract address of a token name. * @param _tokenName token name * @param _address the ERC20 token contract address. */ function setToken(string _tokenName, address _address) public onlyOwner { require(_address != address(0) && bytes(_tokenName).length > 0); nameByToken[_tokenName] = _address; } /** * @dev setPledgeFactory, Plant contract for configuration management pledge business. * @param _factory pledge factory contract. */ function setPledgeFactory(address _factory) public onlyOwner { require(_factory != address(0)); pledgeFactory = _factory; } /** * @dev Checks whether the current token pool is supported. * @param _tokenName token name */ function includeTokenPool(string _tokenName) view public returns(address) { require(bytes(_tokenName).length > 0); return nameByPool[_tokenName]; } /** * @dev Checks whether the current erc20 token is supported. * @param _tokenName token name */ function includeToken(string _tokenName) view public returns(address) { require(bytes(_tokenName).length > 0); return nameByToken[_tokenName]; } }
/** * @title EscrowMaintainContract * @dev Provides configuration and external interfaces. */
NatSpecMultiLine
setTokenPool
function setTokenPool(string _tokenName, address _address) public onlyOwner { require(_address != address(0) && bytes(_tokenName).length > 0); nameByPool[_tokenName] = _address; }
/** * @dev setTokenPool, set the token pool contract address of a token name. * @param _tokenName set token pool name. * @param _address the token pool contract address. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 1711, 1906 ] }
3,764
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
EscrowMaintainContract
contract EscrowMaintainContract is PartnerAuthority { address public pledgeFactory; // map of token name to token pool address; mapping(string => address) internal nameByPool; // map of token name to erc20 token address; mapping(string => address) internal nameByToken; // ----------------------------------------- // External interface // ----------------------------------------- /** * @dev Create a pledge subcontract * @param _pledgeId index number of the pledge contract. */ function createPledgeContract(uint256 _pledgeId) public onlyPartner returns(bool) { require(_pledgeId > 0 && pledgeFactory!=address(0)); require(PledgeFactory(pledgeFactory).createPledgeContract(_pledgeId,partner)); return true; } /** * @dev Batch create a pledge subcontract * @param _pledgeIds index number of the pledge contract. */ function batchCreatePledgeContract(uint256[] _pledgeIds) public onlyPartner { require(_pledgeIds.length > 0); PledgeFactory(pledgeFactory).batchCreatePledgeContract(_pledgeIds,partner); } /** * @dev Use the index to get the basic information of the corresponding pledge contract. * @param _pledgeId index number of the pledge contract */ function getEscrowPledge(uint256 _pledgeId) public view returns(string tokenName, address pledgeContract) { require(_pledgeId > 0); (tokenName,pledgeContract) = PledgeFactory(pledgeFactory).getEscrowPledge(_pledgeId); } /** * @dev setTokenPool, set the token pool contract address of a token name. * @param _tokenName set token pool name. * @param _address the token pool contract address. */ function setTokenPool(string _tokenName, address _address) public onlyOwner { require(_address != address(0) && bytes(_tokenName).length > 0); nameByPool[_tokenName] = _address; } /** * @dev setToken, set the token contract address of a token name. * @param _tokenName token name * @param _address the ERC20 token contract address. */ function setToken(string _tokenName, address _address) public onlyOwner { require(_address != address(0) && bytes(_tokenName).length > 0); nameByToken[_tokenName] = _address; } /** * @dev setPledgeFactory, Plant contract for configuration management pledge business. * @param _factory pledge factory contract. */ function setPledgeFactory(address _factory) public onlyOwner { require(_factory != address(0)); pledgeFactory = _factory; } /** * @dev Checks whether the current token pool is supported. * @param _tokenName token name */ function includeTokenPool(string _tokenName) view public returns(address) { require(bytes(_tokenName).length > 0); return nameByPool[_tokenName]; } /** * @dev Checks whether the current erc20 token is supported. * @param _tokenName token name */ function includeToken(string _tokenName) view public returns(address) { require(bytes(_tokenName).length > 0); return nameByToken[_tokenName]; } }
/** * @title EscrowMaintainContract * @dev Provides configuration and external interfaces. */
NatSpecMultiLine
setToken
function setToken(string _tokenName, address _address) public onlyOwner { require(_address != address(0) && bytes(_tokenName).length > 0); nameByToken[_tokenName] = _address; }
/** * @dev setToken, set the token contract address of a token name. * @param _tokenName token name * @param _address the ERC20 token contract address. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 2084, 2276 ] }
3,765
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
EscrowMaintainContract
contract EscrowMaintainContract is PartnerAuthority { address public pledgeFactory; // map of token name to token pool address; mapping(string => address) internal nameByPool; // map of token name to erc20 token address; mapping(string => address) internal nameByToken; // ----------------------------------------- // External interface // ----------------------------------------- /** * @dev Create a pledge subcontract * @param _pledgeId index number of the pledge contract. */ function createPledgeContract(uint256 _pledgeId) public onlyPartner returns(bool) { require(_pledgeId > 0 && pledgeFactory!=address(0)); require(PledgeFactory(pledgeFactory).createPledgeContract(_pledgeId,partner)); return true; } /** * @dev Batch create a pledge subcontract * @param _pledgeIds index number of the pledge contract. */ function batchCreatePledgeContract(uint256[] _pledgeIds) public onlyPartner { require(_pledgeIds.length > 0); PledgeFactory(pledgeFactory).batchCreatePledgeContract(_pledgeIds,partner); } /** * @dev Use the index to get the basic information of the corresponding pledge contract. * @param _pledgeId index number of the pledge contract */ function getEscrowPledge(uint256 _pledgeId) public view returns(string tokenName, address pledgeContract) { require(_pledgeId > 0); (tokenName,pledgeContract) = PledgeFactory(pledgeFactory).getEscrowPledge(_pledgeId); } /** * @dev setTokenPool, set the token pool contract address of a token name. * @param _tokenName set token pool name. * @param _address the token pool contract address. */ function setTokenPool(string _tokenName, address _address) public onlyOwner { require(_address != address(0) && bytes(_tokenName).length > 0); nameByPool[_tokenName] = _address; } /** * @dev setToken, set the token contract address of a token name. * @param _tokenName token name * @param _address the ERC20 token contract address. */ function setToken(string _tokenName, address _address) public onlyOwner { require(_address != address(0) && bytes(_tokenName).length > 0); nameByToken[_tokenName] = _address; } /** * @dev setPledgeFactory, Plant contract for configuration management pledge business. * @param _factory pledge factory contract. */ function setPledgeFactory(address _factory) public onlyOwner { require(_factory != address(0)); pledgeFactory = _factory; } /** * @dev Checks whether the current token pool is supported. * @param _tokenName token name */ function includeTokenPool(string _tokenName) view public returns(address) { require(bytes(_tokenName).length > 0); return nameByPool[_tokenName]; } /** * @dev Checks whether the current erc20 token is supported. * @param _tokenName token name */ function includeToken(string _tokenName) view public returns(address) { require(bytes(_tokenName).length > 0); return nameByToken[_tokenName]; } }
/** * @title EscrowMaintainContract * @dev Provides configuration and external interfaces. */
NatSpecMultiLine
setPledgeFactory
function setPledgeFactory(address _factory) public onlyOwner { require(_factory != address(0)); pledgeFactory = _factory; }
/** * @dev setPledgeFactory, Plant contract for configuration management pledge business. * @param _factory pledge factory contract. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 2429, 2568 ] }
3,766
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
EscrowMaintainContract
contract EscrowMaintainContract is PartnerAuthority { address public pledgeFactory; // map of token name to token pool address; mapping(string => address) internal nameByPool; // map of token name to erc20 token address; mapping(string => address) internal nameByToken; // ----------------------------------------- // External interface // ----------------------------------------- /** * @dev Create a pledge subcontract * @param _pledgeId index number of the pledge contract. */ function createPledgeContract(uint256 _pledgeId) public onlyPartner returns(bool) { require(_pledgeId > 0 && pledgeFactory!=address(0)); require(PledgeFactory(pledgeFactory).createPledgeContract(_pledgeId,partner)); return true; } /** * @dev Batch create a pledge subcontract * @param _pledgeIds index number of the pledge contract. */ function batchCreatePledgeContract(uint256[] _pledgeIds) public onlyPartner { require(_pledgeIds.length > 0); PledgeFactory(pledgeFactory).batchCreatePledgeContract(_pledgeIds,partner); } /** * @dev Use the index to get the basic information of the corresponding pledge contract. * @param _pledgeId index number of the pledge contract */ function getEscrowPledge(uint256 _pledgeId) public view returns(string tokenName, address pledgeContract) { require(_pledgeId > 0); (tokenName,pledgeContract) = PledgeFactory(pledgeFactory).getEscrowPledge(_pledgeId); } /** * @dev setTokenPool, set the token pool contract address of a token name. * @param _tokenName set token pool name. * @param _address the token pool contract address. */ function setTokenPool(string _tokenName, address _address) public onlyOwner { require(_address != address(0) && bytes(_tokenName).length > 0); nameByPool[_tokenName] = _address; } /** * @dev setToken, set the token contract address of a token name. * @param _tokenName token name * @param _address the ERC20 token contract address. */ function setToken(string _tokenName, address _address) public onlyOwner { require(_address != address(0) && bytes(_tokenName).length > 0); nameByToken[_tokenName] = _address; } /** * @dev setPledgeFactory, Plant contract for configuration management pledge business. * @param _factory pledge factory contract. */ function setPledgeFactory(address _factory) public onlyOwner { require(_factory != address(0)); pledgeFactory = _factory; } /** * @dev Checks whether the current token pool is supported. * @param _tokenName token name */ function includeTokenPool(string _tokenName) view public returns(address) { require(bytes(_tokenName).length > 0); return nameByPool[_tokenName]; } /** * @dev Checks whether the current erc20 token is supported. * @param _tokenName token name */ function includeToken(string _tokenName) view public returns(address) { require(bytes(_tokenName).length > 0); return nameByToken[_tokenName]; } }
/** * @title EscrowMaintainContract * @dev Provides configuration and external interfaces. */
NatSpecMultiLine
includeTokenPool
function includeTokenPool(string _tokenName) view public returns(address) { require(bytes(_tokenName).length > 0); return nameByPool[_tokenName]; }
/** * @dev Checks whether the current token pool is supported. * @param _tokenName token name */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 2683, 2846 ] }
3,767
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
EscrowMaintainContract
contract EscrowMaintainContract is PartnerAuthority { address public pledgeFactory; // map of token name to token pool address; mapping(string => address) internal nameByPool; // map of token name to erc20 token address; mapping(string => address) internal nameByToken; // ----------------------------------------- // External interface // ----------------------------------------- /** * @dev Create a pledge subcontract * @param _pledgeId index number of the pledge contract. */ function createPledgeContract(uint256 _pledgeId) public onlyPartner returns(bool) { require(_pledgeId > 0 && pledgeFactory!=address(0)); require(PledgeFactory(pledgeFactory).createPledgeContract(_pledgeId,partner)); return true; } /** * @dev Batch create a pledge subcontract * @param _pledgeIds index number of the pledge contract. */ function batchCreatePledgeContract(uint256[] _pledgeIds) public onlyPartner { require(_pledgeIds.length > 0); PledgeFactory(pledgeFactory).batchCreatePledgeContract(_pledgeIds,partner); } /** * @dev Use the index to get the basic information of the corresponding pledge contract. * @param _pledgeId index number of the pledge contract */ function getEscrowPledge(uint256 _pledgeId) public view returns(string tokenName, address pledgeContract) { require(_pledgeId > 0); (tokenName,pledgeContract) = PledgeFactory(pledgeFactory).getEscrowPledge(_pledgeId); } /** * @dev setTokenPool, set the token pool contract address of a token name. * @param _tokenName set token pool name. * @param _address the token pool contract address. */ function setTokenPool(string _tokenName, address _address) public onlyOwner { require(_address != address(0) && bytes(_tokenName).length > 0); nameByPool[_tokenName] = _address; } /** * @dev setToken, set the token contract address of a token name. * @param _tokenName token name * @param _address the ERC20 token contract address. */ function setToken(string _tokenName, address _address) public onlyOwner { require(_address != address(0) && bytes(_tokenName).length > 0); nameByToken[_tokenName] = _address; } /** * @dev setPledgeFactory, Plant contract for configuration management pledge business. * @param _factory pledge factory contract. */ function setPledgeFactory(address _factory) public onlyOwner { require(_factory != address(0)); pledgeFactory = _factory; } /** * @dev Checks whether the current token pool is supported. * @param _tokenName token name */ function includeTokenPool(string _tokenName) view public returns(address) { require(bytes(_tokenName).length > 0); return nameByPool[_tokenName]; } /** * @dev Checks whether the current erc20 token is supported. * @param _tokenName token name */ function includeToken(string _tokenName) view public returns(address) { require(bytes(_tokenName).length > 0); return nameByToken[_tokenName]; } }
/** * @title EscrowMaintainContract * @dev Provides configuration and external interfaces. */
NatSpecMultiLine
includeToken
function includeToken(string _tokenName) view public returns(address) { require(bytes(_tokenName).length > 0); return nameByToken[_tokenName]; }
/** * @dev Checks whether the current erc20 token is supported. * @param _tokenName token name */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 2964, 3124 ] }
3,768
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeContract
contract PledgeContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Type of execution state of the pledge contract(irreversible) */ enum StatusChoices { NO_PLEDGE_INFO, PLEDGE_CREATE_MATCHING, PLEDGE_REFUND } string public pledgeTokenName; uint256 public pledgeId; address internal maker; address internal token20; address internal factory; address internal escrowContract; uint256 internal pledgeAccountSum; // order contract address address internal orderContract; string internal loanTokenName; StatusChoices internal status; address internal tokenPoolAddress; string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; // ETH pledge account mapping(address => uint256) internal verifyEthAccount; /** * Event for createOrderContract logging. * @param newOrderContract management contract address. */ event CreateOrderContract(address newOrderContract); /** * Event for WithdrawToken logging. * @param maker address of investor. * @param pledgeTokenName token name. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed maker, string pledgeTokenName, uint256 refundSum); /** * Event for appendEscrow logging. * @param maker address of borrower. * @param appendSum append amount. */ event AppendEscrow(address indexed maker, uint256 appendSum); /** * @dev Constructor initial contract configuration parameters */ constructor(uint256 _pledgeId, address _factory , address _escrowContract) public { require(_pledgeId > 0 && _factory != address(0) && _escrowContract != address(0)); pledgeId = _pledgeId; factory = _factory; status = StatusChoices.NO_PLEDGE_INFO; escrowContract = _escrowContract; } // ----------------------------------------- // external interface // ----------------------------------------- function() external payable { require(status != StatusChoices.PLEDGE_REFUND); // Identify the borrower. if (maker != address(0)) { require(address(msg.sender) == maker); } // Record basic information about the borrower's pledge ETH verifyEthAccount[msg.sender] = verifyEthAccount[msg.sender].add(msg.value); } /** * @dev Add the pledge information and transfer the pledged token into the corresponding currency pool. * @param _pledgeTokenName maker pledge token name. * @param _maker borrower address. * @param _pledgeSum pledge amount. * @param _loanTokenName pledge token type. */ function addRecord(string _pledgeTokenName, address _maker, uint256 _pledgeSum, string _loanTokenName) public onlyOwner { require(_maker != address(0) && _pledgeSum > 0 && status != StatusChoices.PLEDGE_REFUND); // Add the pledge information for the first time. if (status == StatusChoices.NO_PLEDGE_INFO) { // public data init. maker = _maker; pledgeTokenName = _pledgeTokenName; tokenPoolAddress = checkedTokenPool(pledgeTokenName); PledgeFactory(factory).updatePledgeType(pledgeId, pledgeTokenName); // Assign rights to the operation of the contract pool PledgeFactory(factory).tokenPoolOperater(tokenPoolAddress, address(this)); // Create order management contracts. createOrderContract(_loanTokenName); } // Record information of each pledge. pledgeAccountSum = pledgeAccountSum.add(_pledgeSum); PledgePoolBase(tokenPoolAddress).addRecord(maker, pledgeAccountSum, pledgeId, pledgeTokenName); // Transfer the pledge token to the appropriate token pool. if (pledgeTokenName.stringCompare(TOKEN_ETH)) { require(verifyEthAccount[maker] >= _pledgeSum); tokenPoolAddress.transfer(_pledgeSum); } else { token20 = checkedToken(pledgeTokenName); require(ERC20(token20).balanceOf(address(this)) >= _pledgeSum); require(safeErc20Transfer(token20,tokenPoolAddress, _pledgeSum)); } } /** * @dev Increase the number of pledged tokens. * @param _appendSum append amount. */ function appendEscrow(uint256 _appendSum) public onlyOwner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); addRecord(pledgeTokenName, maker, _appendSum, loanTokenName); emit AppendEscrow(maker, _appendSum); } /** * @dev Withdraw pledge behavior. * @param _maker borrower address. */ function withdrawToken(address _maker) public onlyOwner { require(status != StatusChoices.PLEDGE_REFUND); uint256 pledgeSum = 0; // there are two types of retractions. if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeSum = classifySquareUp(_maker); } else { status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).withdrawToken(pledgeId, maker, pledgeAccountSum)); pledgeSum = pledgeAccountSum; } emit WithdrawToken(_maker, pledgeTokenName, pledgeSum); } /** * @dev Executed in some extreme unforsee cases, to avoid eth locked. * @param _tokenName recycle token type. * @param _amount Number of eth to recycle. */ function recycle(string _tokenName, uint256 _amount) public onlyOwner { require(status != StatusChoices.NO_PLEDGE_INFO && _amount>0); if (_tokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _amount); owner.transfer(_amount); } else { address token = checkedToken(_tokenName); require(ERC20(token).balanceOf(address(this)) >= _amount); require(safeErc20Transfer(token,owner, _amount)); } } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _token20,address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(_token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(_token20).transfer(_toAddress, _transferSum)); } return true; } // ----------------------------------------- // internal interface // ----------------------------------------- /** * @dev Create an order process management contract for the match and repayment business. * @param _loanTokenName expect loan token type. */ function createOrderContract(string _loanTokenName) internal { require(bytes(_loanTokenName).length > 0); status = StatusChoices.PLEDGE_CREATE_MATCHING; address loanToken20 = checkedToken(_loanTokenName); OrderManageContract newOrder = new OrderManageContract(_loanTokenName, loanToken20, maker); setPartner(address(newOrder)); newOrder.setPartner(owner); // update contract public data. orderContract = newOrder; loanTokenName = _loanTokenName; emit CreateOrderContract(address(newOrder)); } /** * @dev classification withdraw. * @dev Execute without changing the current contract data state. * @param _maker borrower address. */ function classifySquareUp(address _maker) internal returns(uint256 sum) { if (pledgeTokenName.stringCompare(TOKEN_ETH)) { uint256 pledgeSum = verifyEthAccount[_maker]; require(pledgeSum > 0 && address(this).balance >= pledgeSum); _maker.transfer(pledgeSum); verifyEthAccount[_maker] = 0; sum = pledgeSum; } else { uint256 balance = ERC20(token20).balanceOf(address(this)); require(balance > 0); require(safeErc20Transfer(token20,_maker, balance)); sum = balance; } } /** * @dev Check wether the token is included for a token name. * @param _tokenName token name. */ function checkedToken(string _tokenName) internal view returns(address) { address tokenAddress = EscrowMaintainContract(escrowContract).includeToken(_tokenName); require(tokenAddress != address(0)); return tokenAddress; } /** * @dev Check wether the token pool is included for a token name. * @param _tokenName pledge token name. */ function checkedTokenPool(string _tokenName) internal view returns(address) { address tokenPool = EscrowMaintainContract(escrowContract).includeTokenPool(_tokenName); require(tokenPool != address(0)); return tokenPool; } // ----------------------------------------- // business relationship interface // (Only the order contract has authority to operate) // ----------------------------------------- /** * @dev Refund of the borrower’s pledge. */ function _conclude() public onlyPartner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, maker)); } /** * @dev Expired for repayment or close position. * @param _taker address of investor. */ function _forceConclude(address _taker) public onlyPartner { require(_taker != address(0) && status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, _taker)); } // ----------------------------------------- // query interface (use no gas) // ----------------------------------------- /** * @dev Get current contract order status. * @return pledgeStatus state indicate. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeStatus = "NO_PLEDGE_INFO"; } else if (status == StatusChoices.PLEDGE_CREATE_MATCHING) { pledgeStatus = "PLEDGE_CREATE_MATCHING"; } else { pledgeStatus = "PLEDGE_REFUND"; } } /** * @dev get order contract address. use no gas. */ function getOrderContract() public view returns(address) { return orderContract; } /** * @dev Gets the total number of tokens pledged under the current contract. */ function getPledgeAccountSum() public view returns(uint256) { return pledgeAccountSum; } /** * @dev get current contract borrower address. */ function getMakerAddress() public view returns(address) { return maker; } /** * @dev get current contract pledge Id. */ function getPledgeId() external view returns(uint256) { return pledgeId; } }
/** * @title PledgeContract * @dev Pledge process management contract */
NatSpecMultiLine
function() external payable { require(status != StatusChoices.PLEDGE_REFUND); // Identify the borrower. if (maker != address(0)) { require(address(msg.sender) == maker); } // Record basic information about the borrower's pledge ETH verifyEthAccount[msg.sender] = verifyEthAccount[msg.sender].add(msg.value); }
// ----------------------------------------- // external interface // -----------------------------------------
LineComment
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 2058, 2410 ] }
3,769
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeContract
contract PledgeContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Type of execution state of the pledge contract(irreversible) */ enum StatusChoices { NO_PLEDGE_INFO, PLEDGE_CREATE_MATCHING, PLEDGE_REFUND } string public pledgeTokenName; uint256 public pledgeId; address internal maker; address internal token20; address internal factory; address internal escrowContract; uint256 internal pledgeAccountSum; // order contract address address internal orderContract; string internal loanTokenName; StatusChoices internal status; address internal tokenPoolAddress; string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; // ETH pledge account mapping(address => uint256) internal verifyEthAccount; /** * Event for createOrderContract logging. * @param newOrderContract management contract address. */ event CreateOrderContract(address newOrderContract); /** * Event for WithdrawToken logging. * @param maker address of investor. * @param pledgeTokenName token name. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed maker, string pledgeTokenName, uint256 refundSum); /** * Event for appendEscrow logging. * @param maker address of borrower. * @param appendSum append amount. */ event AppendEscrow(address indexed maker, uint256 appendSum); /** * @dev Constructor initial contract configuration parameters */ constructor(uint256 _pledgeId, address _factory , address _escrowContract) public { require(_pledgeId > 0 && _factory != address(0) && _escrowContract != address(0)); pledgeId = _pledgeId; factory = _factory; status = StatusChoices.NO_PLEDGE_INFO; escrowContract = _escrowContract; } // ----------------------------------------- // external interface // ----------------------------------------- function() external payable { require(status != StatusChoices.PLEDGE_REFUND); // Identify the borrower. if (maker != address(0)) { require(address(msg.sender) == maker); } // Record basic information about the borrower's pledge ETH verifyEthAccount[msg.sender] = verifyEthAccount[msg.sender].add(msg.value); } /** * @dev Add the pledge information and transfer the pledged token into the corresponding currency pool. * @param _pledgeTokenName maker pledge token name. * @param _maker borrower address. * @param _pledgeSum pledge amount. * @param _loanTokenName pledge token type. */ function addRecord(string _pledgeTokenName, address _maker, uint256 _pledgeSum, string _loanTokenName) public onlyOwner { require(_maker != address(0) && _pledgeSum > 0 && status != StatusChoices.PLEDGE_REFUND); // Add the pledge information for the first time. if (status == StatusChoices.NO_PLEDGE_INFO) { // public data init. maker = _maker; pledgeTokenName = _pledgeTokenName; tokenPoolAddress = checkedTokenPool(pledgeTokenName); PledgeFactory(factory).updatePledgeType(pledgeId, pledgeTokenName); // Assign rights to the operation of the contract pool PledgeFactory(factory).tokenPoolOperater(tokenPoolAddress, address(this)); // Create order management contracts. createOrderContract(_loanTokenName); } // Record information of each pledge. pledgeAccountSum = pledgeAccountSum.add(_pledgeSum); PledgePoolBase(tokenPoolAddress).addRecord(maker, pledgeAccountSum, pledgeId, pledgeTokenName); // Transfer the pledge token to the appropriate token pool. if (pledgeTokenName.stringCompare(TOKEN_ETH)) { require(verifyEthAccount[maker] >= _pledgeSum); tokenPoolAddress.transfer(_pledgeSum); } else { token20 = checkedToken(pledgeTokenName); require(ERC20(token20).balanceOf(address(this)) >= _pledgeSum); require(safeErc20Transfer(token20,tokenPoolAddress, _pledgeSum)); } } /** * @dev Increase the number of pledged tokens. * @param _appendSum append amount. */ function appendEscrow(uint256 _appendSum) public onlyOwner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); addRecord(pledgeTokenName, maker, _appendSum, loanTokenName); emit AppendEscrow(maker, _appendSum); } /** * @dev Withdraw pledge behavior. * @param _maker borrower address. */ function withdrawToken(address _maker) public onlyOwner { require(status != StatusChoices.PLEDGE_REFUND); uint256 pledgeSum = 0; // there are two types of retractions. if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeSum = classifySquareUp(_maker); } else { status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).withdrawToken(pledgeId, maker, pledgeAccountSum)); pledgeSum = pledgeAccountSum; } emit WithdrawToken(_maker, pledgeTokenName, pledgeSum); } /** * @dev Executed in some extreme unforsee cases, to avoid eth locked. * @param _tokenName recycle token type. * @param _amount Number of eth to recycle. */ function recycle(string _tokenName, uint256 _amount) public onlyOwner { require(status != StatusChoices.NO_PLEDGE_INFO && _amount>0); if (_tokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _amount); owner.transfer(_amount); } else { address token = checkedToken(_tokenName); require(ERC20(token).balanceOf(address(this)) >= _amount); require(safeErc20Transfer(token,owner, _amount)); } } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _token20,address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(_token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(_token20).transfer(_toAddress, _transferSum)); } return true; } // ----------------------------------------- // internal interface // ----------------------------------------- /** * @dev Create an order process management contract for the match and repayment business. * @param _loanTokenName expect loan token type. */ function createOrderContract(string _loanTokenName) internal { require(bytes(_loanTokenName).length > 0); status = StatusChoices.PLEDGE_CREATE_MATCHING; address loanToken20 = checkedToken(_loanTokenName); OrderManageContract newOrder = new OrderManageContract(_loanTokenName, loanToken20, maker); setPartner(address(newOrder)); newOrder.setPartner(owner); // update contract public data. orderContract = newOrder; loanTokenName = _loanTokenName; emit CreateOrderContract(address(newOrder)); } /** * @dev classification withdraw. * @dev Execute without changing the current contract data state. * @param _maker borrower address. */ function classifySquareUp(address _maker) internal returns(uint256 sum) { if (pledgeTokenName.stringCompare(TOKEN_ETH)) { uint256 pledgeSum = verifyEthAccount[_maker]; require(pledgeSum > 0 && address(this).balance >= pledgeSum); _maker.transfer(pledgeSum); verifyEthAccount[_maker] = 0; sum = pledgeSum; } else { uint256 balance = ERC20(token20).balanceOf(address(this)); require(balance > 0); require(safeErc20Transfer(token20,_maker, balance)); sum = balance; } } /** * @dev Check wether the token is included for a token name. * @param _tokenName token name. */ function checkedToken(string _tokenName) internal view returns(address) { address tokenAddress = EscrowMaintainContract(escrowContract).includeToken(_tokenName); require(tokenAddress != address(0)); return tokenAddress; } /** * @dev Check wether the token pool is included for a token name. * @param _tokenName pledge token name. */ function checkedTokenPool(string _tokenName) internal view returns(address) { address tokenPool = EscrowMaintainContract(escrowContract).includeTokenPool(_tokenName); require(tokenPool != address(0)); return tokenPool; } // ----------------------------------------- // business relationship interface // (Only the order contract has authority to operate) // ----------------------------------------- /** * @dev Refund of the borrower’s pledge. */ function _conclude() public onlyPartner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, maker)); } /** * @dev Expired for repayment or close position. * @param _taker address of investor. */ function _forceConclude(address _taker) public onlyPartner { require(_taker != address(0) && status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, _taker)); } // ----------------------------------------- // query interface (use no gas) // ----------------------------------------- /** * @dev Get current contract order status. * @return pledgeStatus state indicate. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeStatus = "NO_PLEDGE_INFO"; } else if (status == StatusChoices.PLEDGE_CREATE_MATCHING) { pledgeStatus = "PLEDGE_CREATE_MATCHING"; } else { pledgeStatus = "PLEDGE_REFUND"; } } /** * @dev get order contract address. use no gas. */ function getOrderContract() public view returns(address) { return orderContract; } /** * @dev Gets the total number of tokens pledged under the current contract. */ function getPledgeAccountSum() public view returns(uint256) { return pledgeAccountSum; } /** * @dev get current contract borrower address. */ function getMakerAddress() public view returns(address) { return maker; } /** * @dev get current contract pledge Id. */ function getPledgeId() external view returns(uint256) { return pledgeId; } }
/** * @title PledgeContract * @dev Pledge process management contract */
NatSpecMultiLine
addRecord
function addRecord(string _pledgeTokenName, address _maker, uint256 _pledgeSum, string _loanTokenName) public onlyOwner { require(_maker != address(0) && _pledgeSum > 0 && status != StatusChoices.PLEDGE_REFUND); // Add the pledge information for the first time. if (status == StatusChoices.NO_PLEDGE_INFO) { // public data init. maker = _maker; pledgeTokenName = _pledgeTokenName; tokenPoolAddress = checkedTokenPool(pledgeTokenName); PledgeFactory(factory).updatePledgeType(pledgeId, pledgeTokenName); // Assign rights to the operation of the contract pool PledgeFactory(factory).tokenPoolOperater(tokenPoolAddress, address(this)); // Create order management contracts. createOrderContract(_loanTokenName); } // Record information of each pledge. pledgeAccountSum = pledgeAccountSum.add(_pledgeSum); PledgePoolBase(tokenPoolAddress).addRecord(maker, pledgeAccountSum, pledgeId, pledgeTokenName); // Transfer the pledge token to the appropriate token pool. if (pledgeTokenName.stringCompare(TOKEN_ETH)) { require(verifyEthAccount[maker] >= _pledgeSum); tokenPoolAddress.transfer(_pledgeSum); } else { token20 = checkedToken(pledgeTokenName); require(ERC20(token20).balanceOf(address(this)) >= _pledgeSum); require(safeErc20Transfer(token20,tokenPoolAddress, _pledgeSum)); } }
/** * @dev Add the pledge information and transfer the pledged token into the corresponding currency pool. * @param _pledgeTokenName maker pledge token name. * @param _maker borrower address. * @param _pledgeSum pledge amount. * @param _loanTokenName pledge token type. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 2715, 4149 ] }
3,770
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeContract
contract PledgeContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Type of execution state of the pledge contract(irreversible) */ enum StatusChoices { NO_PLEDGE_INFO, PLEDGE_CREATE_MATCHING, PLEDGE_REFUND } string public pledgeTokenName; uint256 public pledgeId; address internal maker; address internal token20; address internal factory; address internal escrowContract; uint256 internal pledgeAccountSum; // order contract address address internal orderContract; string internal loanTokenName; StatusChoices internal status; address internal tokenPoolAddress; string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; // ETH pledge account mapping(address => uint256) internal verifyEthAccount; /** * Event for createOrderContract logging. * @param newOrderContract management contract address. */ event CreateOrderContract(address newOrderContract); /** * Event for WithdrawToken logging. * @param maker address of investor. * @param pledgeTokenName token name. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed maker, string pledgeTokenName, uint256 refundSum); /** * Event for appendEscrow logging. * @param maker address of borrower. * @param appendSum append amount. */ event AppendEscrow(address indexed maker, uint256 appendSum); /** * @dev Constructor initial contract configuration parameters */ constructor(uint256 _pledgeId, address _factory , address _escrowContract) public { require(_pledgeId > 0 && _factory != address(0) && _escrowContract != address(0)); pledgeId = _pledgeId; factory = _factory; status = StatusChoices.NO_PLEDGE_INFO; escrowContract = _escrowContract; } // ----------------------------------------- // external interface // ----------------------------------------- function() external payable { require(status != StatusChoices.PLEDGE_REFUND); // Identify the borrower. if (maker != address(0)) { require(address(msg.sender) == maker); } // Record basic information about the borrower's pledge ETH verifyEthAccount[msg.sender] = verifyEthAccount[msg.sender].add(msg.value); } /** * @dev Add the pledge information and transfer the pledged token into the corresponding currency pool. * @param _pledgeTokenName maker pledge token name. * @param _maker borrower address. * @param _pledgeSum pledge amount. * @param _loanTokenName pledge token type. */ function addRecord(string _pledgeTokenName, address _maker, uint256 _pledgeSum, string _loanTokenName) public onlyOwner { require(_maker != address(0) && _pledgeSum > 0 && status != StatusChoices.PLEDGE_REFUND); // Add the pledge information for the first time. if (status == StatusChoices.NO_PLEDGE_INFO) { // public data init. maker = _maker; pledgeTokenName = _pledgeTokenName; tokenPoolAddress = checkedTokenPool(pledgeTokenName); PledgeFactory(factory).updatePledgeType(pledgeId, pledgeTokenName); // Assign rights to the operation of the contract pool PledgeFactory(factory).tokenPoolOperater(tokenPoolAddress, address(this)); // Create order management contracts. createOrderContract(_loanTokenName); } // Record information of each pledge. pledgeAccountSum = pledgeAccountSum.add(_pledgeSum); PledgePoolBase(tokenPoolAddress).addRecord(maker, pledgeAccountSum, pledgeId, pledgeTokenName); // Transfer the pledge token to the appropriate token pool. if (pledgeTokenName.stringCompare(TOKEN_ETH)) { require(verifyEthAccount[maker] >= _pledgeSum); tokenPoolAddress.transfer(_pledgeSum); } else { token20 = checkedToken(pledgeTokenName); require(ERC20(token20).balanceOf(address(this)) >= _pledgeSum); require(safeErc20Transfer(token20,tokenPoolAddress, _pledgeSum)); } } /** * @dev Increase the number of pledged tokens. * @param _appendSum append amount. */ function appendEscrow(uint256 _appendSum) public onlyOwner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); addRecord(pledgeTokenName, maker, _appendSum, loanTokenName); emit AppendEscrow(maker, _appendSum); } /** * @dev Withdraw pledge behavior. * @param _maker borrower address. */ function withdrawToken(address _maker) public onlyOwner { require(status != StatusChoices.PLEDGE_REFUND); uint256 pledgeSum = 0; // there are two types of retractions. if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeSum = classifySquareUp(_maker); } else { status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).withdrawToken(pledgeId, maker, pledgeAccountSum)); pledgeSum = pledgeAccountSum; } emit WithdrawToken(_maker, pledgeTokenName, pledgeSum); } /** * @dev Executed in some extreme unforsee cases, to avoid eth locked. * @param _tokenName recycle token type. * @param _amount Number of eth to recycle. */ function recycle(string _tokenName, uint256 _amount) public onlyOwner { require(status != StatusChoices.NO_PLEDGE_INFO && _amount>0); if (_tokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _amount); owner.transfer(_amount); } else { address token = checkedToken(_tokenName); require(ERC20(token).balanceOf(address(this)) >= _amount); require(safeErc20Transfer(token,owner, _amount)); } } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _token20,address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(_token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(_token20).transfer(_toAddress, _transferSum)); } return true; } // ----------------------------------------- // internal interface // ----------------------------------------- /** * @dev Create an order process management contract for the match and repayment business. * @param _loanTokenName expect loan token type. */ function createOrderContract(string _loanTokenName) internal { require(bytes(_loanTokenName).length > 0); status = StatusChoices.PLEDGE_CREATE_MATCHING; address loanToken20 = checkedToken(_loanTokenName); OrderManageContract newOrder = new OrderManageContract(_loanTokenName, loanToken20, maker); setPartner(address(newOrder)); newOrder.setPartner(owner); // update contract public data. orderContract = newOrder; loanTokenName = _loanTokenName; emit CreateOrderContract(address(newOrder)); } /** * @dev classification withdraw. * @dev Execute without changing the current contract data state. * @param _maker borrower address. */ function classifySquareUp(address _maker) internal returns(uint256 sum) { if (pledgeTokenName.stringCompare(TOKEN_ETH)) { uint256 pledgeSum = verifyEthAccount[_maker]; require(pledgeSum > 0 && address(this).balance >= pledgeSum); _maker.transfer(pledgeSum); verifyEthAccount[_maker] = 0; sum = pledgeSum; } else { uint256 balance = ERC20(token20).balanceOf(address(this)); require(balance > 0); require(safeErc20Transfer(token20,_maker, balance)); sum = balance; } } /** * @dev Check wether the token is included for a token name. * @param _tokenName token name. */ function checkedToken(string _tokenName) internal view returns(address) { address tokenAddress = EscrowMaintainContract(escrowContract).includeToken(_tokenName); require(tokenAddress != address(0)); return tokenAddress; } /** * @dev Check wether the token pool is included for a token name. * @param _tokenName pledge token name. */ function checkedTokenPool(string _tokenName) internal view returns(address) { address tokenPool = EscrowMaintainContract(escrowContract).includeTokenPool(_tokenName); require(tokenPool != address(0)); return tokenPool; } // ----------------------------------------- // business relationship interface // (Only the order contract has authority to operate) // ----------------------------------------- /** * @dev Refund of the borrower’s pledge. */ function _conclude() public onlyPartner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, maker)); } /** * @dev Expired for repayment or close position. * @param _taker address of investor. */ function _forceConclude(address _taker) public onlyPartner { require(_taker != address(0) && status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, _taker)); } // ----------------------------------------- // query interface (use no gas) // ----------------------------------------- /** * @dev Get current contract order status. * @return pledgeStatus state indicate. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeStatus = "NO_PLEDGE_INFO"; } else if (status == StatusChoices.PLEDGE_CREATE_MATCHING) { pledgeStatus = "PLEDGE_CREATE_MATCHING"; } else { pledgeStatus = "PLEDGE_REFUND"; } } /** * @dev get order contract address. use no gas. */ function getOrderContract() public view returns(address) { return orderContract; } /** * @dev Gets the total number of tokens pledged under the current contract. */ function getPledgeAccountSum() public view returns(uint256) { return pledgeAccountSum; } /** * @dev get current contract borrower address. */ function getMakerAddress() public view returns(address) { return maker; } /** * @dev get current contract pledge Id. */ function getPledgeId() external view returns(uint256) { return pledgeId; } }
/** * @title PledgeContract * @dev Pledge process management contract */
NatSpecMultiLine
appendEscrow
function appendEscrow(uint256 _appendSum) public onlyOwner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); addRecord(pledgeTokenName, maker, _appendSum, loanTokenName); emit AppendEscrow(maker, _appendSum); }
/** * @dev Increase the number of pledged tokens. * @param _appendSum append amount. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 4255, 4495 ] }
3,771
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeContract
contract PledgeContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Type of execution state of the pledge contract(irreversible) */ enum StatusChoices { NO_PLEDGE_INFO, PLEDGE_CREATE_MATCHING, PLEDGE_REFUND } string public pledgeTokenName; uint256 public pledgeId; address internal maker; address internal token20; address internal factory; address internal escrowContract; uint256 internal pledgeAccountSum; // order contract address address internal orderContract; string internal loanTokenName; StatusChoices internal status; address internal tokenPoolAddress; string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; // ETH pledge account mapping(address => uint256) internal verifyEthAccount; /** * Event for createOrderContract logging. * @param newOrderContract management contract address. */ event CreateOrderContract(address newOrderContract); /** * Event for WithdrawToken logging. * @param maker address of investor. * @param pledgeTokenName token name. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed maker, string pledgeTokenName, uint256 refundSum); /** * Event for appendEscrow logging. * @param maker address of borrower. * @param appendSum append amount. */ event AppendEscrow(address indexed maker, uint256 appendSum); /** * @dev Constructor initial contract configuration parameters */ constructor(uint256 _pledgeId, address _factory , address _escrowContract) public { require(_pledgeId > 0 && _factory != address(0) && _escrowContract != address(0)); pledgeId = _pledgeId; factory = _factory; status = StatusChoices.NO_PLEDGE_INFO; escrowContract = _escrowContract; } // ----------------------------------------- // external interface // ----------------------------------------- function() external payable { require(status != StatusChoices.PLEDGE_REFUND); // Identify the borrower. if (maker != address(0)) { require(address(msg.sender) == maker); } // Record basic information about the borrower's pledge ETH verifyEthAccount[msg.sender] = verifyEthAccount[msg.sender].add(msg.value); } /** * @dev Add the pledge information and transfer the pledged token into the corresponding currency pool. * @param _pledgeTokenName maker pledge token name. * @param _maker borrower address. * @param _pledgeSum pledge amount. * @param _loanTokenName pledge token type. */ function addRecord(string _pledgeTokenName, address _maker, uint256 _pledgeSum, string _loanTokenName) public onlyOwner { require(_maker != address(0) && _pledgeSum > 0 && status != StatusChoices.PLEDGE_REFUND); // Add the pledge information for the first time. if (status == StatusChoices.NO_PLEDGE_INFO) { // public data init. maker = _maker; pledgeTokenName = _pledgeTokenName; tokenPoolAddress = checkedTokenPool(pledgeTokenName); PledgeFactory(factory).updatePledgeType(pledgeId, pledgeTokenName); // Assign rights to the operation of the contract pool PledgeFactory(factory).tokenPoolOperater(tokenPoolAddress, address(this)); // Create order management contracts. createOrderContract(_loanTokenName); } // Record information of each pledge. pledgeAccountSum = pledgeAccountSum.add(_pledgeSum); PledgePoolBase(tokenPoolAddress).addRecord(maker, pledgeAccountSum, pledgeId, pledgeTokenName); // Transfer the pledge token to the appropriate token pool. if (pledgeTokenName.stringCompare(TOKEN_ETH)) { require(verifyEthAccount[maker] >= _pledgeSum); tokenPoolAddress.transfer(_pledgeSum); } else { token20 = checkedToken(pledgeTokenName); require(ERC20(token20).balanceOf(address(this)) >= _pledgeSum); require(safeErc20Transfer(token20,tokenPoolAddress, _pledgeSum)); } } /** * @dev Increase the number of pledged tokens. * @param _appendSum append amount. */ function appendEscrow(uint256 _appendSum) public onlyOwner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); addRecord(pledgeTokenName, maker, _appendSum, loanTokenName); emit AppendEscrow(maker, _appendSum); } /** * @dev Withdraw pledge behavior. * @param _maker borrower address. */ function withdrawToken(address _maker) public onlyOwner { require(status != StatusChoices.PLEDGE_REFUND); uint256 pledgeSum = 0; // there are two types of retractions. if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeSum = classifySquareUp(_maker); } else { status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).withdrawToken(pledgeId, maker, pledgeAccountSum)); pledgeSum = pledgeAccountSum; } emit WithdrawToken(_maker, pledgeTokenName, pledgeSum); } /** * @dev Executed in some extreme unforsee cases, to avoid eth locked. * @param _tokenName recycle token type. * @param _amount Number of eth to recycle. */ function recycle(string _tokenName, uint256 _amount) public onlyOwner { require(status != StatusChoices.NO_PLEDGE_INFO && _amount>0); if (_tokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _amount); owner.transfer(_amount); } else { address token = checkedToken(_tokenName); require(ERC20(token).balanceOf(address(this)) >= _amount); require(safeErc20Transfer(token,owner, _amount)); } } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _token20,address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(_token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(_token20).transfer(_toAddress, _transferSum)); } return true; } // ----------------------------------------- // internal interface // ----------------------------------------- /** * @dev Create an order process management contract for the match and repayment business. * @param _loanTokenName expect loan token type. */ function createOrderContract(string _loanTokenName) internal { require(bytes(_loanTokenName).length > 0); status = StatusChoices.PLEDGE_CREATE_MATCHING; address loanToken20 = checkedToken(_loanTokenName); OrderManageContract newOrder = new OrderManageContract(_loanTokenName, loanToken20, maker); setPartner(address(newOrder)); newOrder.setPartner(owner); // update contract public data. orderContract = newOrder; loanTokenName = _loanTokenName; emit CreateOrderContract(address(newOrder)); } /** * @dev classification withdraw. * @dev Execute without changing the current contract data state. * @param _maker borrower address. */ function classifySquareUp(address _maker) internal returns(uint256 sum) { if (pledgeTokenName.stringCompare(TOKEN_ETH)) { uint256 pledgeSum = verifyEthAccount[_maker]; require(pledgeSum > 0 && address(this).balance >= pledgeSum); _maker.transfer(pledgeSum); verifyEthAccount[_maker] = 0; sum = pledgeSum; } else { uint256 balance = ERC20(token20).balanceOf(address(this)); require(balance > 0); require(safeErc20Transfer(token20,_maker, balance)); sum = balance; } } /** * @dev Check wether the token is included for a token name. * @param _tokenName token name. */ function checkedToken(string _tokenName) internal view returns(address) { address tokenAddress = EscrowMaintainContract(escrowContract).includeToken(_tokenName); require(tokenAddress != address(0)); return tokenAddress; } /** * @dev Check wether the token pool is included for a token name. * @param _tokenName pledge token name. */ function checkedTokenPool(string _tokenName) internal view returns(address) { address tokenPool = EscrowMaintainContract(escrowContract).includeTokenPool(_tokenName); require(tokenPool != address(0)); return tokenPool; } // ----------------------------------------- // business relationship interface // (Only the order contract has authority to operate) // ----------------------------------------- /** * @dev Refund of the borrower’s pledge. */ function _conclude() public onlyPartner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, maker)); } /** * @dev Expired for repayment or close position. * @param _taker address of investor. */ function _forceConclude(address _taker) public onlyPartner { require(_taker != address(0) && status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, _taker)); } // ----------------------------------------- // query interface (use no gas) // ----------------------------------------- /** * @dev Get current contract order status. * @return pledgeStatus state indicate. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeStatus = "NO_PLEDGE_INFO"; } else if (status == StatusChoices.PLEDGE_CREATE_MATCHING) { pledgeStatus = "PLEDGE_CREATE_MATCHING"; } else { pledgeStatus = "PLEDGE_REFUND"; } } /** * @dev get order contract address. use no gas. */ function getOrderContract() public view returns(address) { return orderContract; } /** * @dev Gets the total number of tokens pledged under the current contract. */ function getPledgeAccountSum() public view returns(uint256) { return pledgeAccountSum; } /** * @dev get current contract borrower address. */ function getMakerAddress() public view returns(address) { return maker; } /** * @dev get current contract pledge Id. */ function getPledgeId() external view returns(uint256) { return pledgeId; } }
/** * @title PledgeContract * @dev Pledge process management contract */
NatSpecMultiLine
withdrawToken
function withdrawToken(address _maker) public onlyOwner { require(status != StatusChoices.PLEDGE_REFUND); uint256 pledgeSum = 0; // there are two types of retractions. if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeSum = classifySquareUp(_maker); } else { status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).withdrawToken(pledgeId, maker, pledgeAccountSum)); pledgeSum = pledgeAccountSum; } emit WithdrawToken(_maker, pledgeTokenName, pledgeSum); }
/** * @dev Withdraw pledge behavior. * @param _maker borrower address. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 4589, 5138 ] }
3,772
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeContract
contract PledgeContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Type of execution state of the pledge contract(irreversible) */ enum StatusChoices { NO_PLEDGE_INFO, PLEDGE_CREATE_MATCHING, PLEDGE_REFUND } string public pledgeTokenName; uint256 public pledgeId; address internal maker; address internal token20; address internal factory; address internal escrowContract; uint256 internal pledgeAccountSum; // order contract address address internal orderContract; string internal loanTokenName; StatusChoices internal status; address internal tokenPoolAddress; string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; // ETH pledge account mapping(address => uint256) internal verifyEthAccount; /** * Event for createOrderContract logging. * @param newOrderContract management contract address. */ event CreateOrderContract(address newOrderContract); /** * Event for WithdrawToken logging. * @param maker address of investor. * @param pledgeTokenName token name. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed maker, string pledgeTokenName, uint256 refundSum); /** * Event for appendEscrow logging. * @param maker address of borrower. * @param appendSum append amount. */ event AppendEscrow(address indexed maker, uint256 appendSum); /** * @dev Constructor initial contract configuration parameters */ constructor(uint256 _pledgeId, address _factory , address _escrowContract) public { require(_pledgeId > 0 && _factory != address(0) && _escrowContract != address(0)); pledgeId = _pledgeId; factory = _factory; status = StatusChoices.NO_PLEDGE_INFO; escrowContract = _escrowContract; } // ----------------------------------------- // external interface // ----------------------------------------- function() external payable { require(status != StatusChoices.PLEDGE_REFUND); // Identify the borrower. if (maker != address(0)) { require(address(msg.sender) == maker); } // Record basic information about the borrower's pledge ETH verifyEthAccount[msg.sender] = verifyEthAccount[msg.sender].add(msg.value); } /** * @dev Add the pledge information and transfer the pledged token into the corresponding currency pool. * @param _pledgeTokenName maker pledge token name. * @param _maker borrower address. * @param _pledgeSum pledge amount. * @param _loanTokenName pledge token type. */ function addRecord(string _pledgeTokenName, address _maker, uint256 _pledgeSum, string _loanTokenName) public onlyOwner { require(_maker != address(0) && _pledgeSum > 0 && status != StatusChoices.PLEDGE_REFUND); // Add the pledge information for the first time. if (status == StatusChoices.NO_PLEDGE_INFO) { // public data init. maker = _maker; pledgeTokenName = _pledgeTokenName; tokenPoolAddress = checkedTokenPool(pledgeTokenName); PledgeFactory(factory).updatePledgeType(pledgeId, pledgeTokenName); // Assign rights to the operation of the contract pool PledgeFactory(factory).tokenPoolOperater(tokenPoolAddress, address(this)); // Create order management contracts. createOrderContract(_loanTokenName); } // Record information of each pledge. pledgeAccountSum = pledgeAccountSum.add(_pledgeSum); PledgePoolBase(tokenPoolAddress).addRecord(maker, pledgeAccountSum, pledgeId, pledgeTokenName); // Transfer the pledge token to the appropriate token pool. if (pledgeTokenName.stringCompare(TOKEN_ETH)) { require(verifyEthAccount[maker] >= _pledgeSum); tokenPoolAddress.transfer(_pledgeSum); } else { token20 = checkedToken(pledgeTokenName); require(ERC20(token20).balanceOf(address(this)) >= _pledgeSum); require(safeErc20Transfer(token20,tokenPoolAddress, _pledgeSum)); } } /** * @dev Increase the number of pledged tokens. * @param _appendSum append amount. */ function appendEscrow(uint256 _appendSum) public onlyOwner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); addRecord(pledgeTokenName, maker, _appendSum, loanTokenName); emit AppendEscrow(maker, _appendSum); } /** * @dev Withdraw pledge behavior. * @param _maker borrower address. */ function withdrawToken(address _maker) public onlyOwner { require(status != StatusChoices.PLEDGE_REFUND); uint256 pledgeSum = 0; // there are two types of retractions. if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeSum = classifySquareUp(_maker); } else { status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).withdrawToken(pledgeId, maker, pledgeAccountSum)); pledgeSum = pledgeAccountSum; } emit WithdrawToken(_maker, pledgeTokenName, pledgeSum); } /** * @dev Executed in some extreme unforsee cases, to avoid eth locked. * @param _tokenName recycle token type. * @param _amount Number of eth to recycle. */ function recycle(string _tokenName, uint256 _amount) public onlyOwner { require(status != StatusChoices.NO_PLEDGE_INFO && _amount>0); if (_tokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _amount); owner.transfer(_amount); } else { address token = checkedToken(_tokenName); require(ERC20(token).balanceOf(address(this)) >= _amount); require(safeErc20Transfer(token,owner, _amount)); } } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _token20,address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(_token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(_token20).transfer(_toAddress, _transferSum)); } return true; } // ----------------------------------------- // internal interface // ----------------------------------------- /** * @dev Create an order process management contract for the match and repayment business. * @param _loanTokenName expect loan token type. */ function createOrderContract(string _loanTokenName) internal { require(bytes(_loanTokenName).length > 0); status = StatusChoices.PLEDGE_CREATE_MATCHING; address loanToken20 = checkedToken(_loanTokenName); OrderManageContract newOrder = new OrderManageContract(_loanTokenName, loanToken20, maker); setPartner(address(newOrder)); newOrder.setPartner(owner); // update contract public data. orderContract = newOrder; loanTokenName = _loanTokenName; emit CreateOrderContract(address(newOrder)); } /** * @dev classification withdraw. * @dev Execute without changing the current contract data state. * @param _maker borrower address. */ function classifySquareUp(address _maker) internal returns(uint256 sum) { if (pledgeTokenName.stringCompare(TOKEN_ETH)) { uint256 pledgeSum = verifyEthAccount[_maker]; require(pledgeSum > 0 && address(this).balance >= pledgeSum); _maker.transfer(pledgeSum); verifyEthAccount[_maker] = 0; sum = pledgeSum; } else { uint256 balance = ERC20(token20).balanceOf(address(this)); require(balance > 0); require(safeErc20Transfer(token20,_maker, balance)); sum = balance; } } /** * @dev Check wether the token is included for a token name. * @param _tokenName token name. */ function checkedToken(string _tokenName) internal view returns(address) { address tokenAddress = EscrowMaintainContract(escrowContract).includeToken(_tokenName); require(tokenAddress != address(0)); return tokenAddress; } /** * @dev Check wether the token pool is included for a token name. * @param _tokenName pledge token name. */ function checkedTokenPool(string _tokenName) internal view returns(address) { address tokenPool = EscrowMaintainContract(escrowContract).includeTokenPool(_tokenName); require(tokenPool != address(0)); return tokenPool; } // ----------------------------------------- // business relationship interface // (Only the order contract has authority to operate) // ----------------------------------------- /** * @dev Refund of the borrower’s pledge. */ function _conclude() public onlyPartner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, maker)); } /** * @dev Expired for repayment or close position. * @param _taker address of investor. */ function _forceConclude(address _taker) public onlyPartner { require(_taker != address(0) && status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, _taker)); } // ----------------------------------------- // query interface (use no gas) // ----------------------------------------- /** * @dev Get current contract order status. * @return pledgeStatus state indicate. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeStatus = "NO_PLEDGE_INFO"; } else if (status == StatusChoices.PLEDGE_CREATE_MATCHING) { pledgeStatus = "PLEDGE_CREATE_MATCHING"; } else { pledgeStatus = "PLEDGE_REFUND"; } } /** * @dev get order contract address. use no gas. */ function getOrderContract() public view returns(address) { return orderContract; } /** * @dev Gets the total number of tokens pledged under the current contract. */ function getPledgeAccountSum() public view returns(uint256) { return pledgeAccountSum; } /** * @dev get current contract borrower address. */ function getMakerAddress() public view returns(address) { return maker; } /** * @dev get current contract pledge Id. */ function getPledgeId() external view returns(uint256) { return pledgeId; } }
/** * @title PledgeContract * @dev Pledge process management contract */
NatSpecMultiLine
recycle
function recycle(string _tokenName, uint256 _amount) public onlyOwner { require(status != StatusChoices.NO_PLEDGE_INFO && _amount>0); if (_tokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _amount); owner.transfer(_amount); } else { address token = checkedToken(_tokenName); require(ERC20(token).balanceOf(address(this)) >= _amount); require(safeErc20Transfer(token,owner, _amount)); } }
/** * @dev Executed in some extreme unforsee cases, to avoid eth locked. * @param _tokenName recycle token type. * @param _amount Number of eth to recycle. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 5321, 5790 ] }
3,773
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeContract
contract PledgeContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Type of execution state of the pledge contract(irreversible) */ enum StatusChoices { NO_PLEDGE_INFO, PLEDGE_CREATE_MATCHING, PLEDGE_REFUND } string public pledgeTokenName; uint256 public pledgeId; address internal maker; address internal token20; address internal factory; address internal escrowContract; uint256 internal pledgeAccountSum; // order contract address address internal orderContract; string internal loanTokenName; StatusChoices internal status; address internal tokenPoolAddress; string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; // ETH pledge account mapping(address => uint256) internal verifyEthAccount; /** * Event for createOrderContract logging. * @param newOrderContract management contract address. */ event CreateOrderContract(address newOrderContract); /** * Event for WithdrawToken logging. * @param maker address of investor. * @param pledgeTokenName token name. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed maker, string pledgeTokenName, uint256 refundSum); /** * Event for appendEscrow logging. * @param maker address of borrower. * @param appendSum append amount. */ event AppendEscrow(address indexed maker, uint256 appendSum); /** * @dev Constructor initial contract configuration parameters */ constructor(uint256 _pledgeId, address _factory , address _escrowContract) public { require(_pledgeId > 0 && _factory != address(0) && _escrowContract != address(0)); pledgeId = _pledgeId; factory = _factory; status = StatusChoices.NO_PLEDGE_INFO; escrowContract = _escrowContract; } // ----------------------------------------- // external interface // ----------------------------------------- function() external payable { require(status != StatusChoices.PLEDGE_REFUND); // Identify the borrower. if (maker != address(0)) { require(address(msg.sender) == maker); } // Record basic information about the borrower's pledge ETH verifyEthAccount[msg.sender] = verifyEthAccount[msg.sender].add(msg.value); } /** * @dev Add the pledge information and transfer the pledged token into the corresponding currency pool. * @param _pledgeTokenName maker pledge token name. * @param _maker borrower address. * @param _pledgeSum pledge amount. * @param _loanTokenName pledge token type. */ function addRecord(string _pledgeTokenName, address _maker, uint256 _pledgeSum, string _loanTokenName) public onlyOwner { require(_maker != address(0) && _pledgeSum > 0 && status != StatusChoices.PLEDGE_REFUND); // Add the pledge information for the first time. if (status == StatusChoices.NO_PLEDGE_INFO) { // public data init. maker = _maker; pledgeTokenName = _pledgeTokenName; tokenPoolAddress = checkedTokenPool(pledgeTokenName); PledgeFactory(factory).updatePledgeType(pledgeId, pledgeTokenName); // Assign rights to the operation of the contract pool PledgeFactory(factory).tokenPoolOperater(tokenPoolAddress, address(this)); // Create order management contracts. createOrderContract(_loanTokenName); } // Record information of each pledge. pledgeAccountSum = pledgeAccountSum.add(_pledgeSum); PledgePoolBase(tokenPoolAddress).addRecord(maker, pledgeAccountSum, pledgeId, pledgeTokenName); // Transfer the pledge token to the appropriate token pool. if (pledgeTokenName.stringCompare(TOKEN_ETH)) { require(verifyEthAccount[maker] >= _pledgeSum); tokenPoolAddress.transfer(_pledgeSum); } else { token20 = checkedToken(pledgeTokenName); require(ERC20(token20).balanceOf(address(this)) >= _pledgeSum); require(safeErc20Transfer(token20,tokenPoolAddress, _pledgeSum)); } } /** * @dev Increase the number of pledged tokens. * @param _appendSum append amount. */ function appendEscrow(uint256 _appendSum) public onlyOwner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); addRecord(pledgeTokenName, maker, _appendSum, loanTokenName); emit AppendEscrow(maker, _appendSum); } /** * @dev Withdraw pledge behavior. * @param _maker borrower address. */ function withdrawToken(address _maker) public onlyOwner { require(status != StatusChoices.PLEDGE_REFUND); uint256 pledgeSum = 0; // there are two types of retractions. if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeSum = classifySquareUp(_maker); } else { status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).withdrawToken(pledgeId, maker, pledgeAccountSum)); pledgeSum = pledgeAccountSum; } emit WithdrawToken(_maker, pledgeTokenName, pledgeSum); } /** * @dev Executed in some extreme unforsee cases, to avoid eth locked. * @param _tokenName recycle token type. * @param _amount Number of eth to recycle. */ function recycle(string _tokenName, uint256 _amount) public onlyOwner { require(status != StatusChoices.NO_PLEDGE_INFO && _amount>0); if (_tokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _amount); owner.transfer(_amount); } else { address token = checkedToken(_tokenName); require(ERC20(token).balanceOf(address(this)) >= _amount); require(safeErc20Transfer(token,owner, _amount)); } } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _token20,address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(_token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(_token20).transfer(_toAddress, _transferSum)); } return true; } // ----------------------------------------- // internal interface // ----------------------------------------- /** * @dev Create an order process management contract for the match and repayment business. * @param _loanTokenName expect loan token type. */ function createOrderContract(string _loanTokenName) internal { require(bytes(_loanTokenName).length > 0); status = StatusChoices.PLEDGE_CREATE_MATCHING; address loanToken20 = checkedToken(_loanTokenName); OrderManageContract newOrder = new OrderManageContract(_loanTokenName, loanToken20, maker); setPartner(address(newOrder)); newOrder.setPartner(owner); // update contract public data. orderContract = newOrder; loanTokenName = _loanTokenName; emit CreateOrderContract(address(newOrder)); } /** * @dev classification withdraw. * @dev Execute without changing the current contract data state. * @param _maker borrower address. */ function classifySquareUp(address _maker) internal returns(uint256 sum) { if (pledgeTokenName.stringCompare(TOKEN_ETH)) { uint256 pledgeSum = verifyEthAccount[_maker]; require(pledgeSum > 0 && address(this).balance >= pledgeSum); _maker.transfer(pledgeSum); verifyEthAccount[_maker] = 0; sum = pledgeSum; } else { uint256 balance = ERC20(token20).balanceOf(address(this)); require(balance > 0); require(safeErc20Transfer(token20,_maker, balance)); sum = balance; } } /** * @dev Check wether the token is included for a token name. * @param _tokenName token name. */ function checkedToken(string _tokenName) internal view returns(address) { address tokenAddress = EscrowMaintainContract(escrowContract).includeToken(_tokenName); require(tokenAddress != address(0)); return tokenAddress; } /** * @dev Check wether the token pool is included for a token name. * @param _tokenName pledge token name. */ function checkedTokenPool(string _tokenName) internal view returns(address) { address tokenPool = EscrowMaintainContract(escrowContract).includeTokenPool(_tokenName); require(tokenPool != address(0)); return tokenPool; } // ----------------------------------------- // business relationship interface // (Only the order contract has authority to operate) // ----------------------------------------- /** * @dev Refund of the borrower’s pledge. */ function _conclude() public onlyPartner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, maker)); } /** * @dev Expired for repayment or close position. * @param _taker address of investor. */ function _forceConclude(address _taker) public onlyPartner { require(_taker != address(0) && status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, _taker)); } // ----------------------------------------- // query interface (use no gas) // ----------------------------------------- /** * @dev Get current contract order status. * @return pledgeStatus state indicate. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeStatus = "NO_PLEDGE_INFO"; } else if (status == StatusChoices.PLEDGE_CREATE_MATCHING) { pledgeStatus = "PLEDGE_CREATE_MATCHING"; } else { pledgeStatus = "PLEDGE_REFUND"; } } /** * @dev get order contract address. use no gas. */ function getOrderContract() public view returns(address) { return orderContract; } /** * @dev Gets the total number of tokens pledged under the current contract. */ function getPledgeAccountSum() public view returns(uint256) { return pledgeAccountSum; } /** * @dev get current contract borrower address. */ function getMakerAddress() public view returns(address) { return maker; } /** * @dev get current contract pledge Id. */ function getPledgeId() external view returns(uint256) { return pledgeId; } }
/** * @title PledgeContract * @dev Pledge process management contract */
NatSpecMultiLine
safeErc20Transfer
function safeErc20Transfer(address _token20,address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(_token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(_token20).transfer(_toAddress, _transferSum)); } return true; }
/** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 6181, 6517 ] }
3,774
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeContract
contract PledgeContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Type of execution state of the pledge contract(irreversible) */ enum StatusChoices { NO_PLEDGE_INFO, PLEDGE_CREATE_MATCHING, PLEDGE_REFUND } string public pledgeTokenName; uint256 public pledgeId; address internal maker; address internal token20; address internal factory; address internal escrowContract; uint256 internal pledgeAccountSum; // order contract address address internal orderContract; string internal loanTokenName; StatusChoices internal status; address internal tokenPoolAddress; string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; // ETH pledge account mapping(address => uint256) internal verifyEthAccount; /** * Event for createOrderContract logging. * @param newOrderContract management contract address. */ event CreateOrderContract(address newOrderContract); /** * Event for WithdrawToken logging. * @param maker address of investor. * @param pledgeTokenName token name. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed maker, string pledgeTokenName, uint256 refundSum); /** * Event for appendEscrow logging. * @param maker address of borrower. * @param appendSum append amount. */ event AppendEscrow(address indexed maker, uint256 appendSum); /** * @dev Constructor initial contract configuration parameters */ constructor(uint256 _pledgeId, address _factory , address _escrowContract) public { require(_pledgeId > 0 && _factory != address(0) && _escrowContract != address(0)); pledgeId = _pledgeId; factory = _factory; status = StatusChoices.NO_PLEDGE_INFO; escrowContract = _escrowContract; } // ----------------------------------------- // external interface // ----------------------------------------- function() external payable { require(status != StatusChoices.PLEDGE_REFUND); // Identify the borrower. if (maker != address(0)) { require(address(msg.sender) == maker); } // Record basic information about the borrower's pledge ETH verifyEthAccount[msg.sender] = verifyEthAccount[msg.sender].add(msg.value); } /** * @dev Add the pledge information and transfer the pledged token into the corresponding currency pool. * @param _pledgeTokenName maker pledge token name. * @param _maker borrower address. * @param _pledgeSum pledge amount. * @param _loanTokenName pledge token type. */ function addRecord(string _pledgeTokenName, address _maker, uint256 _pledgeSum, string _loanTokenName) public onlyOwner { require(_maker != address(0) && _pledgeSum > 0 && status != StatusChoices.PLEDGE_REFUND); // Add the pledge information for the first time. if (status == StatusChoices.NO_PLEDGE_INFO) { // public data init. maker = _maker; pledgeTokenName = _pledgeTokenName; tokenPoolAddress = checkedTokenPool(pledgeTokenName); PledgeFactory(factory).updatePledgeType(pledgeId, pledgeTokenName); // Assign rights to the operation of the contract pool PledgeFactory(factory).tokenPoolOperater(tokenPoolAddress, address(this)); // Create order management contracts. createOrderContract(_loanTokenName); } // Record information of each pledge. pledgeAccountSum = pledgeAccountSum.add(_pledgeSum); PledgePoolBase(tokenPoolAddress).addRecord(maker, pledgeAccountSum, pledgeId, pledgeTokenName); // Transfer the pledge token to the appropriate token pool. if (pledgeTokenName.stringCompare(TOKEN_ETH)) { require(verifyEthAccount[maker] >= _pledgeSum); tokenPoolAddress.transfer(_pledgeSum); } else { token20 = checkedToken(pledgeTokenName); require(ERC20(token20).balanceOf(address(this)) >= _pledgeSum); require(safeErc20Transfer(token20,tokenPoolAddress, _pledgeSum)); } } /** * @dev Increase the number of pledged tokens. * @param _appendSum append amount. */ function appendEscrow(uint256 _appendSum) public onlyOwner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); addRecord(pledgeTokenName, maker, _appendSum, loanTokenName); emit AppendEscrow(maker, _appendSum); } /** * @dev Withdraw pledge behavior. * @param _maker borrower address. */ function withdrawToken(address _maker) public onlyOwner { require(status != StatusChoices.PLEDGE_REFUND); uint256 pledgeSum = 0; // there are two types of retractions. if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeSum = classifySquareUp(_maker); } else { status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).withdrawToken(pledgeId, maker, pledgeAccountSum)); pledgeSum = pledgeAccountSum; } emit WithdrawToken(_maker, pledgeTokenName, pledgeSum); } /** * @dev Executed in some extreme unforsee cases, to avoid eth locked. * @param _tokenName recycle token type. * @param _amount Number of eth to recycle. */ function recycle(string _tokenName, uint256 _amount) public onlyOwner { require(status != StatusChoices.NO_PLEDGE_INFO && _amount>0); if (_tokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _amount); owner.transfer(_amount); } else { address token = checkedToken(_tokenName); require(ERC20(token).balanceOf(address(this)) >= _amount); require(safeErc20Transfer(token,owner, _amount)); } } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _token20,address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(_token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(_token20).transfer(_toAddress, _transferSum)); } return true; } // ----------------------------------------- // internal interface // ----------------------------------------- /** * @dev Create an order process management contract for the match and repayment business. * @param _loanTokenName expect loan token type. */ function createOrderContract(string _loanTokenName) internal { require(bytes(_loanTokenName).length > 0); status = StatusChoices.PLEDGE_CREATE_MATCHING; address loanToken20 = checkedToken(_loanTokenName); OrderManageContract newOrder = new OrderManageContract(_loanTokenName, loanToken20, maker); setPartner(address(newOrder)); newOrder.setPartner(owner); // update contract public data. orderContract = newOrder; loanTokenName = _loanTokenName; emit CreateOrderContract(address(newOrder)); } /** * @dev classification withdraw. * @dev Execute without changing the current contract data state. * @param _maker borrower address. */ function classifySquareUp(address _maker) internal returns(uint256 sum) { if (pledgeTokenName.stringCompare(TOKEN_ETH)) { uint256 pledgeSum = verifyEthAccount[_maker]; require(pledgeSum > 0 && address(this).balance >= pledgeSum); _maker.transfer(pledgeSum); verifyEthAccount[_maker] = 0; sum = pledgeSum; } else { uint256 balance = ERC20(token20).balanceOf(address(this)); require(balance > 0); require(safeErc20Transfer(token20,_maker, balance)); sum = balance; } } /** * @dev Check wether the token is included for a token name. * @param _tokenName token name. */ function checkedToken(string _tokenName) internal view returns(address) { address tokenAddress = EscrowMaintainContract(escrowContract).includeToken(_tokenName); require(tokenAddress != address(0)); return tokenAddress; } /** * @dev Check wether the token pool is included for a token name. * @param _tokenName pledge token name. */ function checkedTokenPool(string _tokenName) internal view returns(address) { address tokenPool = EscrowMaintainContract(escrowContract).includeTokenPool(_tokenName); require(tokenPool != address(0)); return tokenPool; } // ----------------------------------------- // business relationship interface // (Only the order contract has authority to operate) // ----------------------------------------- /** * @dev Refund of the borrower’s pledge. */ function _conclude() public onlyPartner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, maker)); } /** * @dev Expired for repayment or close position. * @param _taker address of investor. */ function _forceConclude(address _taker) public onlyPartner { require(_taker != address(0) && status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, _taker)); } // ----------------------------------------- // query interface (use no gas) // ----------------------------------------- /** * @dev Get current contract order status. * @return pledgeStatus state indicate. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeStatus = "NO_PLEDGE_INFO"; } else if (status == StatusChoices.PLEDGE_CREATE_MATCHING) { pledgeStatus = "PLEDGE_CREATE_MATCHING"; } else { pledgeStatus = "PLEDGE_REFUND"; } } /** * @dev get order contract address. use no gas. */ function getOrderContract() public view returns(address) { return orderContract; } /** * @dev Gets the total number of tokens pledged under the current contract. */ function getPledgeAccountSum() public view returns(uint256) { return pledgeAccountSum; } /** * @dev get current contract borrower address. */ function getMakerAddress() public view returns(address) { return maker; } /** * @dev get current contract pledge Id. */ function getPledgeId() external view returns(uint256) { return pledgeId; } }
/** * @title PledgeContract * @dev Pledge process management contract */
NatSpecMultiLine
createOrderContract
function createOrderContract(string _loanTokenName) internal { require(bytes(_loanTokenName).length > 0); status = StatusChoices.PLEDGE_CREATE_MATCHING; address loanToken20 = checkedToken(_loanTokenName); OrderManageContract newOrder = new OrderManageContract(_loanTokenName, loanToken20, maker); setPartner(address(newOrder)); newOrder.setPartner(owner); // update contract public data. orderContract = newOrder; loanTokenName = _loanTokenName; emit CreateOrderContract(address(newOrder)); }
/** * @dev Create an order process management contract for the match and repayment business. * @param _loanTokenName expect loan token type. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 6810, 7358 ] }
3,775
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeContract
contract PledgeContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Type of execution state of the pledge contract(irreversible) */ enum StatusChoices { NO_PLEDGE_INFO, PLEDGE_CREATE_MATCHING, PLEDGE_REFUND } string public pledgeTokenName; uint256 public pledgeId; address internal maker; address internal token20; address internal factory; address internal escrowContract; uint256 internal pledgeAccountSum; // order contract address address internal orderContract; string internal loanTokenName; StatusChoices internal status; address internal tokenPoolAddress; string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; // ETH pledge account mapping(address => uint256) internal verifyEthAccount; /** * Event for createOrderContract logging. * @param newOrderContract management contract address. */ event CreateOrderContract(address newOrderContract); /** * Event for WithdrawToken logging. * @param maker address of investor. * @param pledgeTokenName token name. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed maker, string pledgeTokenName, uint256 refundSum); /** * Event for appendEscrow logging. * @param maker address of borrower. * @param appendSum append amount. */ event AppendEscrow(address indexed maker, uint256 appendSum); /** * @dev Constructor initial contract configuration parameters */ constructor(uint256 _pledgeId, address _factory , address _escrowContract) public { require(_pledgeId > 0 && _factory != address(0) && _escrowContract != address(0)); pledgeId = _pledgeId; factory = _factory; status = StatusChoices.NO_PLEDGE_INFO; escrowContract = _escrowContract; } // ----------------------------------------- // external interface // ----------------------------------------- function() external payable { require(status != StatusChoices.PLEDGE_REFUND); // Identify the borrower. if (maker != address(0)) { require(address(msg.sender) == maker); } // Record basic information about the borrower's pledge ETH verifyEthAccount[msg.sender] = verifyEthAccount[msg.sender].add(msg.value); } /** * @dev Add the pledge information and transfer the pledged token into the corresponding currency pool. * @param _pledgeTokenName maker pledge token name. * @param _maker borrower address. * @param _pledgeSum pledge amount. * @param _loanTokenName pledge token type. */ function addRecord(string _pledgeTokenName, address _maker, uint256 _pledgeSum, string _loanTokenName) public onlyOwner { require(_maker != address(0) && _pledgeSum > 0 && status != StatusChoices.PLEDGE_REFUND); // Add the pledge information for the first time. if (status == StatusChoices.NO_PLEDGE_INFO) { // public data init. maker = _maker; pledgeTokenName = _pledgeTokenName; tokenPoolAddress = checkedTokenPool(pledgeTokenName); PledgeFactory(factory).updatePledgeType(pledgeId, pledgeTokenName); // Assign rights to the operation of the contract pool PledgeFactory(factory).tokenPoolOperater(tokenPoolAddress, address(this)); // Create order management contracts. createOrderContract(_loanTokenName); } // Record information of each pledge. pledgeAccountSum = pledgeAccountSum.add(_pledgeSum); PledgePoolBase(tokenPoolAddress).addRecord(maker, pledgeAccountSum, pledgeId, pledgeTokenName); // Transfer the pledge token to the appropriate token pool. if (pledgeTokenName.stringCompare(TOKEN_ETH)) { require(verifyEthAccount[maker] >= _pledgeSum); tokenPoolAddress.transfer(_pledgeSum); } else { token20 = checkedToken(pledgeTokenName); require(ERC20(token20).balanceOf(address(this)) >= _pledgeSum); require(safeErc20Transfer(token20,tokenPoolAddress, _pledgeSum)); } } /** * @dev Increase the number of pledged tokens. * @param _appendSum append amount. */ function appendEscrow(uint256 _appendSum) public onlyOwner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); addRecord(pledgeTokenName, maker, _appendSum, loanTokenName); emit AppendEscrow(maker, _appendSum); } /** * @dev Withdraw pledge behavior. * @param _maker borrower address. */ function withdrawToken(address _maker) public onlyOwner { require(status != StatusChoices.PLEDGE_REFUND); uint256 pledgeSum = 0; // there are two types of retractions. if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeSum = classifySquareUp(_maker); } else { status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).withdrawToken(pledgeId, maker, pledgeAccountSum)); pledgeSum = pledgeAccountSum; } emit WithdrawToken(_maker, pledgeTokenName, pledgeSum); } /** * @dev Executed in some extreme unforsee cases, to avoid eth locked. * @param _tokenName recycle token type. * @param _amount Number of eth to recycle. */ function recycle(string _tokenName, uint256 _amount) public onlyOwner { require(status != StatusChoices.NO_PLEDGE_INFO && _amount>0); if (_tokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _amount); owner.transfer(_amount); } else { address token = checkedToken(_tokenName); require(ERC20(token).balanceOf(address(this)) >= _amount); require(safeErc20Transfer(token,owner, _amount)); } } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _token20,address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(_token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(_token20).transfer(_toAddress, _transferSum)); } return true; } // ----------------------------------------- // internal interface // ----------------------------------------- /** * @dev Create an order process management contract for the match and repayment business. * @param _loanTokenName expect loan token type. */ function createOrderContract(string _loanTokenName) internal { require(bytes(_loanTokenName).length > 0); status = StatusChoices.PLEDGE_CREATE_MATCHING; address loanToken20 = checkedToken(_loanTokenName); OrderManageContract newOrder = new OrderManageContract(_loanTokenName, loanToken20, maker); setPartner(address(newOrder)); newOrder.setPartner(owner); // update contract public data. orderContract = newOrder; loanTokenName = _loanTokenName; emit CreateOrderContract(address(newOrder)); } /** * @dev classification withdraw. * @dev Execute without changing the current contract data state. * @param _maker borrower address. */ function classifySquareUp(address _maker) internal returns(uint256 sum) { if (pledgeTokenName.stringCompare(TOKEN_ETH)) { uint256 pledgeSum = verifyEthAccount[_maker]; require(pledgeSum > 0 && address(this).balance >= pledgeSum); _maker.transfer(pledgeSum); verifyEthAccount[_maker] = 0; sum = pledgeSum; } else { uint256 balance = ERC20(token20).balanceOf(address(this)); require(balance > 0); require(safeErc20Transfer(token20,_maker, balance)); sum = balance; } } /** * @dev Check wether the token is included for a token name. * @param _tokenName token name. */ function checkedToken(string _tokenName) internal view returns(address) { address tokenAddress = EscrowMaintainContract(escrowContract).includeToken(_tokenName); require(tokenAddress != address(0)); return tokenAddress; } /** * @dev Check wether the token pool is included for a token name. * @param _tokenName pledge token name. */ function checkedTokenPool(string _tokenName) internal view returns(address) { address tokenPool = EscrowMaintainContract(escrowContract).includeTokenPool(_tokenName); require(tokenPool != address(0)); return tokenPool; } // ----------------------------------------- // business relationship interface // (Only the order contract has authority to operate) // ----------------------------------------- /** * @dev Refund of the borrower’s pledge. */ function _conclude() public onlyPartner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, maker)); } /** * @dev Expired for repayment or close position. * @param _taker address of investor. */ function _forceConclude(address _taker) public onlyPartner { require(_taker != address(0) && status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, _taker)); } // ----------------------------------------- // query interface (use no gas) // ----------------------------------------- /** * @dev Get current contract order status. * @return pledgeStatus state indicate. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeStatus = "NO_PLEDGE_INFO"; } else if (status == StatusChoices.PLEDGE_CREATE_MATCHING) { pledgeStatus = "PLEDGE_CREATE_MATCHING"; } else { pledgeStatus = "PLEDGE_REFUND"; } } /** * @dev get order contract address. use no gas. */ function getOrderContract() public view returns(address) { return orderContract; } /** * @dev Gets the total number of tokens pledged under the current contract. */ function getPledgeAccountSum() public view returns(uint256) { return pledgeAccountSum; } /** * @dev get current contract borrower address. */ function getMakerAddress() public view returns(address) { return maker; } /** * @dev get current contract pledge Id. */ function getPledgeId() external view returns(uint256) { return pledgeId; } }
/** * @title PledgeContract * @dev Pledge process management contract */
NatSpecMultiLine
classifySquareUp
function classifySquareUp(address _maker) internal returns(uint256 sum) { if (pledgeTokenName.stringCompare(TOKEN_ETH)) { uint256 pledgeSum = verifyEthAccount[_maker]; require(pledgeSum > 0 && address(this).balance >= pledgeSum); _maker.transfer(pledgeSum); verifyEthAccount[_maker] = 0; sum = pledgeSum; } else { uint256 balance = ERC20(token20).balanceOf(address(this)); require(balance > 0); require(safeErc20Transfer(token20,_maker, balance)); sum = balance; } }
/** * @dev classification withdraw. * @dev Execute without changing the current contract data state. * @param _maker borrower address. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 7518, 8068 ] }
3,776
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeContract
contract PledgeContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Type of execution state of the pledge contract(irreversible) */ enum StatusChoices { NO_PLEDGE_INFO, PLEDGE_CREATE_MATCHING, PLEDGE_REFUND } string public pledgeTokenName; uint256 public pledgeId; address internal maker; address internal token20; address internal factory; address internal escrowContract; uint256 internal pledgeAccountSum; // order contract address address internal orderContract; string internal loanTokenName; StatusChoices internal status; address internal tokenPoolAddress; string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; // ETH pledge account mapping(address => uint256) internal verifyEthAccount; /** * Event for createOrderContract logging. * @param newOrderContract management contract address. */ event CreateOrderContract(address newOrderContract); /** * Event for WithdrawToken logging. * @param maker address of investor. * @param pledgeTokenName token name. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed maker, string pledgeTokenName, uint256 refundSum); /** * Event for appendEscrow logging. * @param maker address of borrower. * @param appendSum append amount. */ event AppendEscrow(address indexed maker, uint256 appendSum); /** * @dev Constructor initial contract configuration parameters */ constructor(uint256 _pledgeId, address _factory , address _escrowContract) public { require(_pledgeId > 0 && _factory != address(0) && _escrowContract != address(0)); pledgeId = _pledgeId; factory = _factory; status = StatusChoices.NO_PLEDGE_INFO; escrowContract = _escrowContract; } // ----------------------------------------- // external interface // ----------------------------------------- function() external payable { require(status != StatusChoices.PLEDGE_REFUND); // Identify the borrower. if (maker != address(0)) { require(address(msg.sender) == maker); } // Record basic information about the borrower's pledge ETH verifyEthAccount[msg.sender] = verifyEthAccount[msg.sender].add(msg.value); } /** * @dev Add the pledge information and transfer the pledged token into the corresponding currency pool. * @param _pledgeTokenName maker pledge token name. * @param _maker borrower address. * @param _pledgeSum pledge amount. * @param _loanTokenName pledge token type. */ function addRecord(string _pledgeTokenName, address _maker, uint256 _pledgeSum, string _loanTokenName) public onlyOwner { require(_maker != address(0) && _pledgeSum > 0 && status != StatusChoices.PLEDGE_REFUND); // Add the pledge information for the first time. if (status == StatusChoices.NO_PLEDGE_INFO) { // public data init. maker = _maker; pledgeTokenName = _pledgeTokenName; tokenPoolAddress = checkedTokenPool(pledgeTokenName); PledgeFactory(factory).updatePledgeType(pledgeId, pledgeTokenName); // Assign rights to the operation of the contract pool PledgeFactory(factory).tokenPoolOperater(tokenPoolAddress, address(this)); // Create order management contracts. createOrderContract(_loanTokenName); } // Record information of each pledge. pledgeAccountSum = pledgeAccountSum.add(_pledgeSum); PledgePoolBase(tokenPoolAddress).addRecord(maker, pledgeAccountSum, pledgeId, pledgeTokenName); // Transfer the pledge token to the appropriate token pool. if (pledgeTokenName.stringCompare(TOKEN_ETH)) { require(verifyEthAccount[maker] >= _pledgeSum); tokenPoolAddress.transfer(_pledgeSum); } else { token20 = checkedToken(pledgeTokenName); require(ERC20(token20).balanceOf(address(this)) >= _pledgeSum); require(safeErc20Transfer(token20,tokenPoolAddress, _pledgeSum)); } } /** * @dev Increase the number of pledged tokens. * @param _appendSum append amount. */ function appendEscrow(uint256 _appendSum) public onlyOwner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); addRecord(pledgeTokenName, maker, _appendSum, loanTokenName); emit AppendEscrow(maker, _appendSum); } /** * @dev Withdraw pledge behavior. * @param _maker borrower address. */ function withdrawToken(address _maker) public onlyOwner { require(status != StatusChoices.PLEDGE_REFUND); uint256 pledgeSum = 0; // there are two types of retractions. if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeSum = classifySquareUp(_maker); } else { status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).withdrawToken(pledgeId, maker, pledgeAccountSum)); pledgeSum = pledgeAccountSum; } emit WithdrawToken(_maker, pledgeTokenName, pledgeSum); } /** * @dev Executed in some extreme unforsee cases, to avoid eth locked. * @param _tokenName recycle token type. * @param _amount Number of eth to recycle. */ function recycle(string _tokenName, uint256 _amount) public onlyOwner { require(status != StatusChoices.NO_PLEDGE_INFO && _amount>0); if (_tokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _amount); owner.transfer(_amount); } else { address token = checkedToken(_tokenName); require(ERC20(token).balanceOf(address(this)) >= _amount); require(safeErc20Transfer(token,owner, _amount)); } } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _token20,address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(_token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(_token20).transfer(_toAddress, _transferSum)); } return true; } // ----------------------------------------- // internal interface // ----------------------------------------- /** * @dev Create an order process management contract for the match and repayment business. * @param _loanTokenName expect loan token type. */ function createOrderContract(string _loanTokenName) internal { require(bytes(_loanTokenName).length > 0); status = StatusChoices.PLEDGE_CREATE_MATCHING; address loanToken20 = checkedToken(_loanTokenName); OrderManageContract newOrder = new OrderManageContract(_loanTokenName, loanToken20, maker); setPartner(address(newOrder)); newOrder.setPartner(owner); // update contract public data. orderContract = newOrder; loanTokenName = _loanTokenName; emit CreateOrderContract(address(newOrder)); } /** * @dev classification withdraw. * @dev Execute without changing the current contract data state. * @param _maker borrower address. */ function classifySquareUp(address _maker) internal returns(uint256 sum) { if (pledgeTokenName.stringCompare(TOKEN_ETH)) { uint256 pledgeSum = verifyEthAccount[_maker]; require(pledgeSum > 0 && address(this).balance >= pledgeSum); _maker.transfer(pledgeSum); verifyEthAccount[_maker] = 0; sum = pledgeSum; } else { uint256 balance = ERC20(token20).balanceOf(address(this)); require(balance > 0); require(safeErc20Transfer(token20,_maker, balance)); sum = balance; } } /** * @dev Check wether the token is included for a token name. * @param _tokenName token name. */ function checkedToken(string _tokenName) internal view returns(address) { address tokenAddress = EscrowMaintainContract(escrowContract).includeToken(_tokenName); require(tokenAddress != address(0)); return tokenAddress; } /** * @dev Check wether the token pool is included for a token name. * @param _tokenName pledge token name. */ function checkedTokenPool(string _tokenName) internal view returns(address) { address tokenPool = EscrowMaintainContract(escrowContract).includeTokenPool(_tokenName); require(tokenPool != address(0)); return tokenPool; } // ----------------------------------------- // business relationship interface // (Only the order contract has authority to operate) // ----------------------------------------- /** * @dev Refund of the borrower’s pledge. */ function _conclude() public onlyPartner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, maker)); } /** * @dev Expired for repayment or close position. * @param _taker address of investor. */ function _forceConclude(address _taker) public onlyPartner { require(_taker != address(0) && status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, _taker)); } // ----------------------------------------- // query interface (use no gas) // ----------------------------------------- /** * @dev Get current contract order status. * @return pledgeStatus state indicate. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeStatus = "NO_PLEDGE_INFO"; } else if (status == StatusChoices.PLEDGE_CREATE_MATCHING) { pledgeStatus = "PLEDGE_CREATE_MATCHING"; } else { pledgeStatus = "PLEDGE_REFUND"; } } /** * @dev get order contract address. use no gas. */ function getOrderContract() public view returns(address) { return orderContract; } /** * @dev Gets the total number of tokens pledged under the current contract. */ function getPledgeAccountSum() public view returns(uint256) { return pledgeAccountSum; } /** * @dev get current contract borrower address. */ function getMakerAddress() public view returns(address) { return maker; } /** * @dev get current contract pledge Id. */ function getPledgeId() external view returns(uint256) { return pledgeId; } }
/** * @title PledgeContract * @dev Pledge process management contract */
NatSpecMultiLine
checkedToken
function checkedToken(string _tokenName) internal view returns(address) { address tokenAddress = EscrowMaintainContract(escrowContract).includeToken(_tokenName); require(tokenAddress != address(0)); return tokenAddress; }
/** * @dev Check wether the token is included for a token name. * @param _tokenName token name. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 8185, 8427 ] }
3,777
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeContract
contract PledgeContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Type of execution state of the pledge contract(irreversible) */ enum StatusChoices { NO_PLEDGE_INFO, PLEDGE_CREATE_MATCHING, PLEDGE_REFUND } string public pledgeTokenName; uint256 public pledgeId; address internal maker; address internal token20; address internal factory; address internal escrowContract; uint256 internal pledgeAccountSum; // order contract address address internal orderContract; string internal loanTokenName; StatusChoices internal status; address internal tokenPoolAddress; string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; // ETH pledge account mapping(address => uint256) internal verifyEthAccount; /** * Event for createOrderContract logging. * @param newOrderContract management contract address. */ event CreateOrderContract(address newOrderContract); /** * Event for WithdrawToken logging. * @param maker address of investor. * @param pledgeTokenName token name. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed maker, string pledgeTokenName, uint256 refundSum); /** * Event for appendEscrow logging. * @param maker address of borrower. * @param appendSum append amount. */ event AppendEscrow(address indexed maker, uint256 appendSum); /** * @dev Constructor initial contract configuration parameters */ constructor(uint256 _pledgeId, address _factory , address _escrowContract) public { require(_pledgeId > 0 && _factory != address(0) && _escrowContract != address(0)); pledgeId = _pledgeId; factory = _factory; status = StatusChoices.NO_PLEDGE_INFO; escrowContract = _escrowContract; } // ----------------------------------------- // external interface // ----------------------------------------- function() external payable { require(status != StatusChoices.PLEDGE_REFUND); // Identify the borrower. if (maker != address(0)) { require(address(msg.sender) == maker); } // Record basic information about the borrower's pledge ETH verifyEthAccount[msg.sender] = verifyEthAccount[msg.sender].add(msg.value); } /** * @dev Add the pledge information and transfer the pledged token into the corresponding currency pool. * @param _pledgeTokenName maker pledge token name. * @param _maker borrower address. * @param _pledgeSum pledge amount. * @param _loanTokenName pledge token type. */ function addRecord(string _pledgeTokenName, address _maker, uint256 _pledgeSum, string _loanTokenName) public onlyOwner { require(_maker != address(0) && _pledgeSum > 0 && status != StatusChoices.PLEDGE_REFUND); // Add the pledge information for the first time. if (status == StatusChoices.NO_PLEDGE_INFO) { // public data init. maker = _maker; pledgeTokenName = _pledgeTokenName; tokenPoolAddress = checkedTokenPool(pledgeTokenName); PledgeFactory(factory).updatePledgeType(pledgeId, pledgeTokenName); // Assign rights to the operation of the contract pool PledgeFactory(factory).tokenPoolOperater(tokenPoolAddress, address(this)); // Create order management contracts. createOrderContract(_loanTokenName); } // Record information of each pledge. pledgeAccountSum = pledgeAccountSum.add(_pledgeSum); PledgePoolBase(tokenPoolAddress).addRecord(maker, pledgeAccountSum, pledgeId, pledgeTokenName); // Transfer the pledge token to the appropriate token pool. if (pledgeTokenName.stringCompare(TOKEN_ETH)) { require(verifyEthAccount[maker] >= _pledgeSum); tokenPoolAddress.transfer(_pledgeSum); } else { token20 = checkedToken(pledgeTokenName); require(ERC20(token20).balanceOf(address(this)) >= _pledgeSum); require(safeErc20Transfer(token20,tokenPoolAddress, _pledgeSum)); } } /** * @dev Increase the number of pledged tokens. * @param _appendSum append amount. */ function appendEscrow(uint256 _appendSum) public onlyOwner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); addRecord(pledgeTokenName, maker, _appendSum, loanTokenName); emit AppendEscrow(maker, _appendSum); } /** * @dev Withdraw pledge behavior. * @param _maker borrower address. */ function withdrawToken(address _maker) public onlyOwner { require(status != StatusChoices.PLEDGE_REFUND); uint256 pledgeSum = 0; // there are two types of retractions. if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeSum = classifySquareUp(_maker); } else { status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).withdrawToken(pledgeId, maker, pledgeAccountSum)); pledgeSum = pledgeAccountSum; } emit WithdrawToken(_maker, pledgeTokenName, pledgeSum); } /** * @dev Executed in some extreme unforsee cases, to avoid eth locked. * @param _tokenName recycle token type. * @param _amount Number of eth to recycle. */ function recycle(string _tokenName, uint256 _amount) public onlyOwner { require(status != StatusChoices.NO_PLEDGE_INFO && _amount>0); if (_tokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _amount); owner.transfer(_amount); } else { address token = checkedToken(_tokenName); require(ERC20(token).balanceOf(address(this)) >= _amount); require(safeErc20Transfer(token,owner, _amount)); } } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _token20,address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(_token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(_token20).transfer(_toAddress, _transferSum)); } return true; } // ----------------------------------------- // internal interface // ----------------------------------------- /** * @dev Create an order process management contract for the match and repayment business. * @param _loanTokenName expect loan token type. */ function createOrderContract(string _loanTokenName) internal { require(bytes(_loanTokenName).length > 0); status = StatusChoices.PLEDGE_CREATE_MATCHING; address loanToken20 = checkedToken(_loanTokenName); OrderManageContract newOrder = new OrderManageContract(_loanTokenName, loanToken20, maker); setPartner(address(newOrder)); newOrder.setPartner(owner); // update contract public data. orderContract = newOrder; loanTokenName = _loanTokenName; emit CreateOrderContract(address(newOrder)); } /** * @dev classification withdraw. * @dev Execute without changing the current contract data state. * @param _maker borrower address. */ function classifySquareUp(address _maker) internal returns(uint256 sum) { if (pledgeTokenName.stringCompare(TOKEN_ETH)) { uint256 pledgeSum = verifyEthAccount[_maker]; require(pledgeSum > 0 && address(this).balance >= pledgeSum); _maker.transfer(pledgeSum); verifyEthAccount[_maker] = 0; sum = pledgeSum; } else { uint256 balance = ERC20(token20).balanceOf(address(this)); require(balance > 0); require(safeErc20Transfer(token20,_maker, balance)); sum = balance; } } /** * @dev Check wether the token is included for a token name. * @param _tokenName token name. */ function checkedToken(string _tokenName) internal view returns(address) { address tokenAddress = EscrowMaintainContract(escrowContract).includeToken(_tokenName); require(tokenAddress != address(0)); return tokenAddress; } /** * @dev Check wether the token pool is included for a token name. * @param _tokenName pledge token name. */ function checkedTokenPool(string _tokenName) internal view returns(address) { address tokenPool = EscrowMaintainContract(escrowContract).includeTokenPool(_tokenName); require(tokenPool != address(0)); return tokenPool; } // ----------------------------------------- // business relationship interface // (Only the order contract has authority to operate) // ----------------------------------------- /** * @dev Refund of the borrower’s pledge. */ function _conclude() public onlyPartner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, maker)); } /** * @dev Expired for repayment or close position. * @param _taker address of investor. */ function _forceConclude(address _taker) public onlyPartner { require(_taker != address(0) && status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, _taker)); } // ----------------------------------------- // query interface (use no gas) // ----------------------------------------- /** * @dev Get current contract order status. * @return pledgeStatus state indicate. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeStatus = "NO_PLEDGE_INFO"; } else if (status == StatusChoices.PLEDGE_CREATE_MATCHING) { pledgeStatus = "PLEDGE_CREATE_MATCHING"; } else { pledgeStatus = "PLEDGE_REFUND"; } } /** * @dev get order contract address. use no gas. */ function getOrderContract() public view returns(address) { return orderContract; } /** * @dev Gets the total number of tokens pledged under the current contract. */ function getPledgeAccountSum() public view returns(uint256) { return pledgeAccountSum; } /** * @dev get current contract borrower address. */ function getMakerAddress() public view returns(address) { return maker; } /** * @dev get current contract pledge Id. */ function getPledgeId() external view returns(uint256) { return pledgeId; } }
/** * @title PledgeContract * @dev Pledge process management contract */
NatSpecMultiLine
checkedTokenPool
function checkedTokenPool(string _tokenName) internal view returns(address) { address tokenPool = EscrowMaintainContract(escrowContract).includeTokenPool(_tokenName); require(tokenPool != address(0)); return tokenPool; }
/** * @dev Check wether the token pool is included for a token name. * @param _tokenName pledge token name. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 8556, 8797 ] }
3,778
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeContract
contract PledgeContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Type of execution state of the pledge contract(irreversible) */ enum StatusChoices { NO_PLEDGE_INFO, PLEDGE_CREATE_MATCHING, PLEDGE_REFUND } string public pledgeTokenName; uint256 public pledgeId; address internal maker; address internal token20; address internal factory; address internal escrowContract; uint256 internal pledgeAccountSum; // order contract address address internal orderContract; string internal loanTokenName; StatusChoices internal status; address internal tokenPoolAddress; string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; // ETH pledge account mapping(address => uint256) internal verifyEthAccount; /** * Event for createOrderContract logging. * @param newOrderContract management contract address. */ event CreateOrderContract(address newOrderContract); /** * Event for WithdrawToken logging. * @param maker address of investor. * @param pledgeTokenName token name. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed maker, string pledgeTokenName, uint256 refundSum); /** * Event for appendEscrow logging. * @param maker address of borrower. * @param appendSum append amount. */ event AppendEscrow(address indexed maker, uint256 appendSum); /** * @dev Constructor initial contract configuration parameters */ constructor(uint256 _pledgeId, address _factory , address _escrowContract) public { require(_pledgeId > 0 && _factory != address(0) && _escrowContract != address(0)); pledgeId = _pledgeId; factory = _factory; status = StatusChoices.NO_PLEDGE_INFO; escrowContract = _escrowContract; } // ----------------------------------------- // external interface // ----------------------------------------- function() external payable { require(status != StatusChoices.PLEDGE_REFUND); // Identify the borrower. if (maker != address(0)) { require(address(msg.sender) == maker); } // Record basic information about the borrower's pledge ETH verifyEthAccount[msg.sender] = verifyEthAccount[msg.sender].add(msg.value); } /** * @dev Add the pledge information and transfer the pledged token into the corresponding currency pool. * @param _pledgeTokenName maker pledge token name. * @param _maker borrower address. * @param _pledgeSum pledge amount. * @param _loanTokenName pledge token type. */ function addRecord(string _pledgeTokenName, address _maker, uint256 _pledgeSum, string _loanTokenName) public onlyOwner { require(_maker != address(0) && _pledgeSum > 0 && status != StatusChoices.PLEDGE_REFUND); // Add the pledge information for the first time. if (status == StatusChoices.NO_PLEDGE_INFO) { // public data init. maker = _maker; pledgeTokenName = _pledgeTokenName; tokenPoolAddress = checkedTokenPool(pledgeTokenName); PledgeFactory(factory).updatePledgeType(pledgeId, pledgeTokenName); // Assign rights to the operation of the contract pool PledgeFactory(factory).tokenPoolOperater(tokenPoolAddress, address(this)); // Create order management contracts. createOrderContract(_loanTokenName); } // Record information of each pledge. pledgeAccountSum = pledgeAccountSum.add(_pledgeSum); PledgePoolBase(tokenPoolAddress).addRecord(maker, pledgeAccountSum, pledgeId, pledgeTokenName); // Transfer the pledge token to the appropriate token pool. if (pledgeTokenName.stringCompare(TOKEN_ETH)) { require(verifyEthAccount[maker] >= _pledgeSum); tokenPoolAddress.transfer(_pledgeSum); } else { token20 = checkedToken(pledgeTokenName); require(ERC20(token20).balanceOf(address(this)) >= _pledgeSum); require(safeErc20Transfer(token20,tokenPoolAddress, _pledgeSum)); } } /** * @dev Increase the number of pledged tokens. * @param _appendSum append amount. */ function appendEscrow(uint256 _appendSum) public onlyOwner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); addRecord(pledgeTokenName, maker, _appendSum, loanTokenName); emit AppendEscrow(maker, _appendSum); } /** * @dev Withdraw pledge behavior. * @param _maker borrower address. */ function withdrawToken(address _maker) public onlyOwner { require(status != StatusChoices.PLEDGE_REFUND); uint256 pledgeSum = 0; // there are two types of retractions. if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeSum = classifySquareUp(_maker); } else { status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).withdrawToken(pledgeId, maker, pledgeAccountSum)); pledgeSum = pledgeAccountSum; } emit WithdrawToken(_maker, pledgeTokenName, pledgeSum); } /** * @dev Executed in some extreme unforsee cases, to avoid eth locked. * @param _tokenName recycle token type. * @param _amount Number of eth to recycle. */ function recycle(string _tokenName, uint256 _amount) public onlyOwner { require(status != StatusChoices.NO_PLEDGE_INFO && _amount>0); if (_tokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _amount); owner.transfer(_amount); } else { address token = checkedToken(_tokenName); require(ERC20(token).balanceOf(address(this)) >= _amount); require(safeErc20Transfer(token,owner, _amount)); } } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _token20,address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(_token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(_token20).transfer(_toAddress, _transferSum)); } return true; } // ----------------------------------------- // internal interface // ----------------------------------------- /** * @dev Create an order process management contract for the match and repayment business. * @param _loanTokenName expect loan token type. */ function createOrderContract(string _loanTokenName) internal { require(bytes(_loanTokenName).length > 0); status = StatusChoices.PLEDGE_CREATE_MATCHING; address loanToken20 = checkedToken(_loanTokenName); OrderManageContract newOrder = new OrderManageContract(_loanTokenName, loanToken20, maker); setPartner(address(newOrder)); newOrder.setPartner(owner); // update contract public data. orderContract = newOrder; loanTokenName = _loanTokenName; emit CreateOrderContract(address(newOrder)); } /** * @dev classification withdraw. * @dev Execute without changing the current contract data state. * @param _maker borrower address. */ function classifySquareUp(address _maker) internal returns(uint256 sum) { if (pledgeTokenName.stringCompare(TOKEN_ETH)) { uint256 pledgeSum = verifyEthAccount[_maker]; require(pledgeSum > 0 && address(this).balance >= pledgeSum); _maker.transfer(pledgeSum); verifyEthAccount[_maker] = 0; sum = pledgeSum; } else { uint256 balance = ERC20(token20).balanceOf(address(this)); require(balance > 0); require(safeErc20Transfer(token20,_maker, balance)); sum = balance; } } /** * @dev Check wether the token is included for a token name. * @param _tokenName token name. */ function checkedToken(string _tokenName) internal view returns(address) { address tokenAddress = EscrowMaintainContract(escrowContract).includeToken(_tokenName); require(tokenAddress != address(0)); return tokenAddress; } /** * @dev Check wether the token pool is included for a token name. * @param _tokenName pledge token name. */ function checkedTokenPool(string _tokenName) internal view returns(address) { address tokenPool = EscrowMaintainContract(escrowContract).includeTokenPool(_tokenName); require(tokenPool != address(0)); return tokenPool; } // ----------------------------------------- // business relationship interface // (Only the order contract has authority to operate) // ----------------------------------------- /** * @dev Refund of the borrower’s pledge. */ function _conclude() public onlyPartner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, maker)); } /** * @dev Expired for repayment or close position. * @param _taker address of investor. */ function _forceConclude(address _taker) public onlyPartner { require(_taker != address(0) && status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, _taker)); } // ----------------------------------------- // query interface (use no gas) // ----------------------------------------- /** * @dev Get current contract order status. * @return pledgeStatus state indicate. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeStatus = "NO_PLEDGE_INFO"; } else if (status == StatusChoices.PLEDGE_CREATE_MATCHING) { pledgeStatus = "PLEDGE_CREATE_MATCHING"; } else { pledgeStatus = "PLEDGE_REFUND"; } } /** * @dev get order contract address. use no gas. */ function getOrderContract() public view returns(address) { return orderContract; } /** * @dev Gets the total number of tokens pledged under the current contract. */ function getPledgeAccountSum() public view returns(uint256) { return pledgeAccountSum; } /** * @dev get current contract borrower address. */ function getMakerAddress() public view returns(address) { return maker; } /** * @dev get current contract pledge Id. */ function getPledgeId() external view returns(uint256) { return pledgeId; } }
/** * @title PledgeContract * @dev Pledge process management contract */
NatSpecMultiLine
_conclude
function _conclude() public onlyPartner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, maker)); }
/** * @dev Refund of the borrower’s pledge. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 9059, 9309 ] }
3,779
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeContract
contract PledgeContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Type of execution state of the pledge contract(irreversible) */ enum StatusChoices { NO_PLEDGE_INFO, PLEDGE_CREATE_MATCHING, PLEDGE_REFUND } string public pledgeTokenName; uint256 public pledgeId; address internal maker; address internal token20; address internal factory; address internal escrowContract; uint256 internal pledgeAccountSum; // order contract address address internal orderContract; string internal loanTokenName; StatusChoices internal status; address internal tokenPoolAddress; string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; // ETH pledge account mapping(address => uint256) internal verifyEthAccount; /** * Event for createOrderContract logging. * @param newOrderContract management contract address. */ event CreateOrderContract(address newOrderContract); /** * Event for WithdrawToken logging. * @param maker address of investor. * @param pledgeTokenName token name. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed maker, string pledgeTokenName, uint256 refundSum); /** * Event for appendEscrow logging. * @param maker address of borrower. * @param appendSum append amount. */ event AppendEscrow(address indexed maker, uint256 appendSum); /** * @dev Constructor initial contract configuration parameters */ constructor(uint256 _pledgeId, address _factory , address _escrowContract) public { require(_pledgeId > 0 && _factory != address(0) && _escrowContract != address(0)); pledgeId = _pledgeId; factory = _factory; status = StatusChoices.NO_PLEDGE_INFO; escrowContract = _escrowContract; } // ----------------------------------------- // external interface // ----------------------------------------- function() external payable { require(status != StatusChoices.PLEDGE_REFUND); // Identify the borrower. if (maker != address(0)) { require(address(msg.sender) == maker); } // Record basic information about the borrower's pledge ETH verifyEthAccount[msg.sender] = verifyEthAccount[msg.sender].add(msg.value); } /** * @dev Add the pledge information and transfer the pledged token into the corresponding currency pool. * @param _pledgeTokenName maker pledge token name. * @param _maker borrower address. * @param _pledgeSum pledge amount. * @param _loanTokenName pledge token type. */ function addRecord(string _pledgeTokenName, address _maker, uint256 _pledgeSum, string _loanTokenName) public onlyOwner { require(_maker != address(0) && _pledgeSum > 0 && status != StatusChoices.PLEDGE_REFUND); // Add the pledge information for the first time. if (status == StatusChoices.NO_PLEDGE_INFO) { // public data init. maker = _maker; pledgeTokenName = _pledgeTokenName; tokenPoolAddress = checkedTokenPool(pledgeTokenName); PledgeFactory(factory).updatePledgeType(pledgeId, pledgeTokenName); // Assign rights to the operation of the contract pool PledgeFactory(factory).tokenPoolOperater(tokenPoolAddress, address(this)); // Create order management contracts. createOrderContract(_loanTokenName); } // Record information of each pledge. pledgeAccountSum = pledgeAccountSum.add(_pledgeSum); PledgePoolBase(tokenPoolAddress).addRecord(maker, pledgeAccountSum, pledgeId, pledgeTokenName); // Transfer the pledge token to the appropriate token pool. if (pledgeTokenName.stringCompare(TOKEN_ETH)) { require(verifyEthAccount[maker] >= _pledgeSum); tokenPoolAddress.transfer(_pledgeSum); } else { token20 = checkedToken(pledgeTokenName); require(ERC20(token20).balanceOf(address(this)) >= _pledgeSum); require(safeErc20Transfer(token20,tokenPoolAddress, _pledgeSum)); } } /** * @dev Increase the number of pledged tokens. * @param _appendSum append amount. */ function appendEscrow(uint256 _appendSum) public onlyOwner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); addRecord(pledgeTokenName, maker, _appendSum, loanTokenName); emit AppendEscrow(maker, _appendSum); } /** * @dev Withdraw pledge behavior. * @param _maker borrower address. */ function withdrawToken(address _maker) public onlyOwner { require(status != StatusChoices.PLEDGE_REFUND); uint256 pledgeSum = 0; // there are two types of retractions. if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeSum = classifySquareUp(_maker); } else { status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).withdrawToken(pledgeId, maker, pledgeAccountSum)); pledgeSum = pledgeAccountSum; } emit WithdrawToken(_maker, pledgeTokenName, pledgeSum); } /** * @dev Executed in some extreme unforsee cases, to avoid eth locked. * @param _tokenName recycle token type. * @param _amount Number of eth to recycle. */ function recycle(string _tokenName, uint256 _amount) public onlyOwner { require(status != StatusChoices.NO_PLEDGE_INFO && _amount>0); if (_tokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _amount); owner.transfer(_amount); } else { address token = checkedToken(_tokenName); require(ERC20(token).balanceOf(address(this)) >= _amount); require(safeErc20Transfer(token,owner, _amount)); } } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _token20,address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(_token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(_token20).transfer(_toAddress, _transferSum)); } return true; } // ----------------------------------------- // internal interface // ----------------------------------------- /** * @dev Create an order process management contract for the match and repayment business. * @param _loanTokenName expect loan token type. */ function createOrderContract(string _loanTokenName) internal { require(bytes(_loanTokenName).length > 0); status = StatusChoices.PLEDGE_CREATE_MATCHING; address loanToken20 = checkedToken(_loanTokenName); OrderManageContract newOrder = new OrderManageContract(_loanTokenName, loanToken20, maker); setPartner(address(newOrder)); newOrder.setPartner(owner); // update contract public data. orderContract = newOrder; loanTokenName = _loanTokenName; emit CreateOrderContract(address(newOrder)); } /** * @dev classification withdraw. * @dev Execute without changing the current contract data state. * @param _maker borrower address. */ function classifySquareUp(address _maker) internal returns(uint256 sum) { if (pledgeTokenName.stringCompare(TOKEN_ETH)) { uint256 pledgeSum = verifyEthAccount[_maker]; require(pledgeSum > 0 && address(this).balance >= pledgeSum); _maker.transfer(pledgeSum); verifyEthAccount[_maker] = 0; sum = pledgeSum; } else { uint256 balance = ERC20(token20).balanceOf(address(this)); require(balance > 0); require(safeErc20Transfer(token20,_maker, balance)); sum = balance; } } /** * @dev Check wether the token is included for a token name. * @param _tokenName token name. */ function checkedToken(string _tokenName) internal view returns(address) { address tokenAddress = EscrowMaintainContract(escrowContract).includeToken(_tokenName); require(tokenAddress != address(0)); return tokenAddress; } /** * @dev Check wether the token pool is included for a token name. * @param _tokenName pledge token name. */ function checkedTokenPool(string _tokenName) internal view returns(address) { address tokenPool = EscrowMaintainContract(escrowContract).includeTokenPool(_tokenName); require(tokenPool != address(0)); return tokenPool; } // ----------------------------------------- // business relationship interface // (Only the order contract has authority to operate) // ----------------------------------------- /** * @dev Refund of the borrower’s pledge. */ function _conclude() public onlyPartner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, maker)); } /** * @dev Expired for repayment or close position. * @param _taker address of investor. */ function _forceConclude(address _taker) public onlyPartner { require(_taker != address(0) && status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, _taker)); } // ----------------------------------------- // query interface (use no gas) // ----------------------------------------- /** * @dev Get current contract order status. * @return pledgeStatus state indicate. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeStatus = "NO_PLEDGE_INFO"; } else if (status == StatusChoices.PLEDGE_CREATE_MATCHING) { pledgeStatus = "PLEDGE_CREATE_MATCHING"; } else { pledgeStatus = "PLEDGE_REFUND"; } } /** * @dev get order contract address. use no gas. */ function getOrderContract() public view returns(address) { return orderContract; } /** * @dev Gets the total number of tokens pledged under the current contract. */ function getPledgeAccountSum() public view returns(uint256) { return pledgeAccountSum; } /** * @dev get current contract borrower address. */ function getMakerAddress() public view returns(address) { return maker; } /** * @dev get current contract pledge Id. */ function getPledgeId() external view returns(uint256) { return pledgeId; } }
/** * @title PledgeContract * @dev Pledge process management contract */
NatSpecMultiLine
_forceConclude
function _forceConclude(address _taker) public onlyPartner { require(_taker != address(0) && status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, _taker)); }
/** * @dev Expired for repayment or close position. * @param _taker address of investor. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 9419, 9713 ] }
3,780
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeContract
contract PledgeContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Type of execution state of the pledge contract(irreversible) */ enum StatusChoices { NO_PLEDGE_INFO, PLEDGE_CREATE_MATCHING, PLEDGE_REFUND } string public pledgeTokenName; uint256 public pledgeId; address internal maker; address internal token20; address internal factory; address internal escrowContract; uint256 internal pledgeAccountSum; // order contract address address internal orderContract; string internal loanTokenName; StatusChoices internal status; address internal tokenPoolAddress; string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; // ETH pledge account mapping(address => uint256) internal verifyEthAccount; /** * Event for createOrderContract logging. * @param newOrderContract management contract address. */ event CreateOrderContract(address newOrderContract); /** * Event for WithdrawToken logging. * @param maker address of investor. * @param pledgeTokenName token name. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed maker, string pledgeTokenName, uint256 refundSum); /** * Event for appendEscrow logging. * @param maker address of borrower. * @param appendSum append amount. */ event AppendEscrow(address indexed maker, uint256 appendSum); /** * @dev Constructor initial contract configuration parameters */ constructor(uint256 _pledgeId, address _factory , address _escrowContract) public { require(_pledgeId > 0 && _factory != address(0) && _escrowContract != address(0)); pledgeId = _pledgeId; factory = _factory; status = StatusChoices.NO_PLEDGE_INFO; escrowContract = _escrowContract; } // ----------------------------------------- // external interface // ----------------------------------------- function() external payable { require(status != StatusChoices.PLEDGE_REFUND); // Identify the borrower. if (maker != address(0)) { require(address(msg.sender) == maker); } // Record basic information about the borrower's pledge ETH verifyEthAccount[msg.sender] = verifyEthAccount[msg.sender].add(msg.value); } /** * @dev Add the pledge information and transfer the pledged token into the corresponding currency pool. * @param _pledgeTokenName maker pledge token name. * @param _maker borrower address. * @param _pledgeSum pledge amount. * @param _loanTokenName pledge token type. */ function addRecord(string _pledgeTokenName, address _maker, uint256 _pledgeSum, string _loanTokenName) public onlyOwner { require(_maker != address(0) && _pledgeSum > 0 && status != StatusChoices.PLEDGE_REFUND); // Add the pledge information for the first time. if (status == StatusChoices.NO_PLEDGE_INFO) { // public data init. maker = _maker; pledgeTokenName = _pledgeTokenName; tokenPoolAddress = checkedTokenPool(pledgeTokenName); PledgeFactory(factory).updatePledgeType(pledgeId, pledgeTokenName); // Assign rights to the operation of the contract pool PledgeFactory(factory).tokenPoolOperater(tokenPoolAddress, address(this)); // Create order management contracts. createOrderContract(_loanTokenName); } // Record information of each pledge. pledgeAccountSum = pledgeAccountSum.add(_pledgeSum); PledgePoolBase(tokenPoolAddress).addRecord(maker, pledgeAccountSum, pledgeId, pledgeTokenName); // Transfer the pledge token to the appropriate token pool. if (pledgeTokenName.stringCompare(TOKEN_ETH)) { require(verifyEthAccount[maker] >= _pledgeSum); tokenPoolAddress.transfer(_pledgeSum); } else { token20 = checkedToken(pledgeTokenName); require(ERC20(token20).balanceOf(address(this)) >= _pledgeSum); require(safeErc20Transfer(token20,tokenPoolAddress, _pledgeSum)); } } /** * @dev Increase the number of pledged tokens. * @param _appendSum append amount. */ function appendEscrow(uint256 _appendSum) public onlyOwner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); addRecord(pledgeTokenName, maker, _appendSum, loanTokenName); emit AppendEscrow(maker, _appendSum); } /** * @dev Withdraw pledge behavior. * @param _maker borrower address. */ function withdrawToken(address _maker) public onlyOwner { require(status != StatusChoices.PLEDGE_REFUND); uint256 pledgeSum = 0; // there are two types of retractions. if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeSum = classifySquareUp(_maker); } else { status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).withdrawToken(pledgeId, maker, pledgeAccountSum)); pledgeSum = pledgeAccountSum; } emit WithdrawToken(_maker, pledgeTokenName, pledgeSum); } /** * @dev Executed in some extreme unforsee cases, to avoid eth locked. * @param _tokenName recycle token type. * @param _amount Number of eth to recycle. */ function recycle(string _tokenName, uint256 _amount) public onlyOwner { require(status != StatusChoices.NO_PLEDGE_INFO && _amount>0); if (_tokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _amount); owner.transfer(_amount); } else { address token = checkedToken(_tokenName); require(ERC20(token).balanceOf(address(this)) >= _amount); require(safeErc20Transfer(token,owner, _amount)); } } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _token20,address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(_token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(_token20).transfer(_toAddress, _transferSum)); } return true; } // ----------------------------------------- // internal interface // ----------------------------------------- /** * @dev Create an order process management contract for the match and repayment business. * @param _loanTokenName expect loan token type. */ function createOrderContract(string _loanTokenName) internal { require(bytes(_loanTokenName).length > 0); status = StatusChoices.PLEDGE_CREATE_MATCHING; address loanToken20 = checkedToken(_loanTokenName); OrderManageContract newOrder = new OrderManageContract(_loanTokenName, loanToken20, maker); setPartner(address(newOrder)); newOrder.setPartner(owner); // update contract public data. orderContract = newOrder; loanTokenName = _loanTokenName; emit CreateOrderContract(address(newOrder)); } /** * @dev classification withdraw. * @dev Execute without changing the current contract data state. * @param _maker borrower address. */ function classifySquareUp(address _maker) internal returns(uint256 sum) { if (pledgeTokenName.stringCompare(TOKEN_ETH)) { uint256 pledgeSum = verifyEthAccount[_maker]; require(pledgeSum > 0 && address(this).balance >= pledgeSum); _maker.transfer(pledgeSum); verifyEthAccount[_maker] = 0; sum = pledgeSum; } else { uint256 balance = ERC20(token20).balanceOf(address(this)); require(balance > 0); require(safeErc20Transfer(token20,_maker, balance)); sum = balance; } } /** * @dev Check wether the token is included for a token name. * @param _tokenName token name. */ function checkedToken(string _tokenName) internal view returns(address) { address tokenAddress = EscrowMaintainContract(escrowContract).includeToken(_tokenName); require(tokenAddress != address(0)); return tokenAddress; } /** * @dev Check wether the token pool is included for a token name. * @param _tokenName pledge token name. */ function checkedTokenPool(string _tokenName) internal view returns(address) { address tokenPool = EscrowMaintainContract(escrowContract).includeTokenPool(_tokenName); require(tokenPool != address(0)); return tokenPool; } // ----------------------------------------- // business relationship interface // (Only the order contract has authority to operate) // ----------------------------------------- /** * @dev Refund of the borrower’s pledge. */ function _conclude() public onlyPartner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, maker)); } /** * @dev Expired for repayment or close position. * @param _taker address of investor. */ function _forceConclude(address _taker) public onlyPartner { require(_taker != address(0) && status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, _taker)); } // ----------------------------------------- // query interface (use no gas) // ----------------------------------------- /** * @dev Get current contract order status. * @return pledgeStatus state indicate. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeStatus = "NO_PLEDGE_INFO"; } else if (status == StatusChoices.PLEDGE_CREATE_MATCHING) { pledgeStatus = "PLEDGE_CREATE_MATCHING"; } else { pledgeStatus = "PLEDGE_REFUND"; } } /** * @dev get order contract address. use no gas. */ function getOrderContract() public view returns(address) { return orderContract; } /** * @dev Gets the total number of tokens pledged under the current contract. */ function getPledgeAccountSum() public view returns(uint256) { return pledgeAccountSum; } /** * @dev get current contract borrower address. */ function getMakerAddress() public view returns(address) { return maker; } /** * @dev get current contract pledge Id. */ function getPledgeId() external view returns(uint256) { return pledgeId; } }
/** * @title PledgeContract * @dev Pledge process management contract */
NatSpecMultiLine
getPledgeStatus
function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeStatus = "NO_PLEDGE_INFO"; } else if (status == StatusChoices.PLEDGE_CREATE_MATCHING) { pledgeStatus = "PLEDGE_CREATE_MATCHING"; } else { pledgeStatus = "PLEDGE_REFUND"; } }
/** * @dev Get current contract order status. * @return pledgeStatus state indicate. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 9960, 10302 ] }
3,781
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeContract
contract PledgeContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Type of execution state of the pledge contract(irreversible) */ enum StatusChoices { NO_PLEDGE_INFO, PLEDGE_CREATE_MATCHING, PLEDGE_REFUND } string public pledgeTokenName; uint256 public pledgeId; address internal maker; address internal token20; address internal factory; address internal escrowContract; uint256 internal pledgeAccountSum; // order contract address address internal orderContract; string internal loanTokenName; StatusChoices internal status; address internal tokenPoolAddress; string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; // ETH pledge account mapping(address => uint256) internal verifyEthAccount; /** * Event for createOrderContract logging. * @param newOrderContract management contract address. */ event CreateOrderContract(address newOrderContract); /** * Event for WithdrawToken logging. * @param maker address of investor. * @param pledgeTokenName token name. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed maker, string pledgeTokenName, uint256 refundSum); /** * Event for appendEscrow logging. * @param maker address of borrower. * @param appendSum append amount. */ event AppendEscrow(address indexed maker, uint256 appendSum); /** * @dev Constructor initial contract configuration parameters */ constructor(uint256 _pledgeId, address _factory , address _escrowContract) public { require(_pledgeId > 0 && _factory != address(0) && _escrowContract != address(0)); pledgeId = _pledgeId; factory = _factory; status = StatusChoices.NO_PLEDGE_INFO; escrowContract = _escrowContract; } // ----------------------------------------- // external interface // ----------------------------------------- function() external payable { require(status != StatusChoices.PLEDGE_REFUND); // Identify the borrower. if (maker != address(0)) { require(address(msg.sender) == maker); } // Record basic information about the borrower's pledge ETH verifyEthAccount[msg.sender] = verifyEthAccount[msg.sender].add(msg.value); } /** * @dev Add the pledge information and transfer the pledged token into the corresponding currency pool. * @param _pledgeTokenName maker pledge token name. * @param _maker borrower address. * @param _pledgeSum pledge amount. * @param _loanTokenName pledge token type. */ function addRecord(string _pledgeTokenName, address _maker, uint256 _pledgeSum, string _loanTokenName) public onlyOwner { require(_maker != address(0) && _pledgeSum > 0 && status != StatusChoices.PLEDGE_REFUND); // Add the pledge information for the first time. if (status == StatusChoices.NO_PLEDGE_INFO) { // public data init. maker = _maker; pledgeTokenName = _pledgeTokenName; tokenPoolAddress = checkedTokenPool(pledgeTokenName); PledgeFactory(factory).updatePledgeType(pledgeId, pledgeTokenName); // Assign rights to the operation of the contract pool PledgeFactory(factory).tokenPoolOperater(tokenPoolAddress, address(this)); // Create order management contracts. createOrderContract(_loanTokenName); } // Record information of each pledge. pledgeAccountSum = pledgeAccountSum.add(_pledgeSum); PledgePoolBase(tokenPoolAddress).addRecord(maker, pledgeAccountSum, pledgeId, pledgeTokenName); // Transfer the pledge token to the appropriate token pool. if (pledgeTokenName.stringCompare(TOKEN_ETH)) { require(verifyEthAccount[maker] >= _pledgeSum); tokenPoolAddress.transfer(_pledgeSum); } else { token20 = checkedToken(pledgeTokenName); require(ERC20(token20).balanceOf(address(this)) >= _pledgeSum); require(safeErc20Transfer(token20,tokenPoolAddress, _pledgeSum)); } } /** * @dev Increase the number of pledged tokens. * @param _appendSum append amount. */ function appendEscrow(uint256 _appendSum) public onlyOwner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); addRecord(pledgeTokenName, maker, _appendSum, loanTokenName); emit AppendEscrow(maker, _appendSum); } /** * @dev Withdraw pledge behavior. * @param _maker borrower address. */ function withdrawToken(address _maker) public onlyOwner { require(status != StatusChoices.PLEDGE_REFUND); uint256 pledgeSum = 0; // there are two types of retractions. if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeSum = classifySquareUp(_maker); } else { status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).withdrawToken(pledgeId, maker, pledgeAccountSum)); pledgeSum = pledgeAccountSum; } emit WithdrawToken(_maker, pledgeTokenName, pledgeSum); } /** * @dev Executed in some extreme unforsee cases, to avoid eth locked. * @param _tokenName recycle token type. * @param _amount Number of eth to recycle. */ function recycle(string _tokenName, uint256 _amount) public onlyOwner { require(status != StatusChoices.NO_PLEDGE_INFO && _amount>0); if (_tokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _amount); owner.transfer(_amount); } else { address token = checkedToken(_tokenName); require(ERC20(token).balanceOf(address(this)) >= _amount); require(safeErc20Transfer(token,owner, _amount)); } } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _token20,address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(_token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(_token20).transfer(_toAddress, _transferSum)); } return true; } // ----------------------------------------- // internal interface // ----------------------------------------- /** * @dev Create an order process management contract for the match and repayment business. * @param _loanTokenName expect loan token type. */ function createOrderContract(string _loanTokenName) internal { require(bytes(_loanTokenName).length > 0); status = StatusChoices.PLEDGE_CREATE_MATCHING; address loanToken20 = checkedToken(_loanTokenName); OrderManageContract newOrder = new OrderManageContract(_loanTokenName, loanToken20, maker); setPartner(address(newOrder)); newOrder.setPartner(owner); // update contract public data. orderContract = newOrder; loanTokenName = _loanTokenName; emit CreateOrderContract(address(newOrder)); } /** * @dev classification withdraw. * @dev Execute without changing the current contract data state. * @param _maker borrower address. */ function classifySquareUp(address _maker) internal returns(uint256 sum) { if (pledgeTokenName.stringCompare(TOKEN_ETH)) { uint256 pledgeSum = verifyEthAccount[_maker]; require(pledgeSum > 0 && address(this).balance >= pledgeSum); _maker.transfer(pledgeSum); verifyEthAccount[_maker] = 0; sum = pledgeSum; } else { uint256 balance = ERC20(token20).balanceOf(address(this)); require(balance > 0); require(safeErc20Transfer(token20,_maker, balance)); sum = balance; } } /** * @dev Check wether the token is included for a token name. * @param _tokenName token name. */ function checkedToken(string _tokenName) internal view returns(address) { address tokenAddress = EscrowMaintainContract(escrowContract).includeToken(_tokenName); require(tokenAddress != address(0)); return tokenAddress; } /** * @dev Check wether the token pool is included for a token name. * @param _tokenName pledge token name. */ function checkedTokenPool(string _tokenName) internal view returns(address) { address tokenPool = EscrowMaintainContract(escrowContract).includeTokenPool(_tokenName); require(tokenPool != address(0)); return tokenPool; } // ----------------------------------------- // business relationship interface // (Only the order contract has authority to operate) // ----------------------------------------- /** * @dev Refund of the borrower’s pledge. */ function _conclude() public onlyPartner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, maker)); } /** * @dev Expired for repayment or close position. * @param _taker address of investor. */ function _forceConclude(address _taker) public onlyPartner { require(_taker != address(0) && status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, _taker)); } // ----------------------------------------- // query interface (use no gas) // ----------------------------------------- /** * @dev Get current contract order status. * @return pledgeStatus state indicate. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeStatus = "NO_PLEDGE_INFO"; } else if (status == StatusChoices.PLEDGE_CREATE_MATCHING) { pledgeStatus = "PLEDGE_CREATE_MATCHING"; } else { pledgeStatus = "PLEDGE_REFUND"; } } /** * @dev get order contract address. use no gas. */ function getOrderContract() public view returns(address) { return orderContract; } /** * @dev Gets the total number of tokens pledged under the current contract. */ function getPledgeAccountSum() public view returns(uint256) { return pledgeAccountSum; } /** * @dev get current contract borrower address. */ function getMakerAddress() public view returns(address) { return maker; } /** * @dev get current contract pledge Id. */ function getPledgeId() external view returns(uint256) { return pledgeId; } }
/** * @title PledgeContract * @dev Pledge process management contract */
NatSpecMultiLine
getOrderContract
function getOrderContract() public view returns(address) { return orderContract; }
/** * @dev get order contract address. use no gas. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 10370, 10463 ] }
3,782
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeContract
contract PledgeContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Type of execution state of the pledge contract(irreversible) */ enum StatusChoices { NO_PLEDGE_INFO, PLEDGE_CREATE_MATCHING, PLEDGE_REFUND } string public pledgeTokenName; uint256 public pledgeId; address internal maker; address internal token20; address internal factory; address internal escrowContract; uint256 internal pledgeAccountSum; // order contract address address internal orderContract; string internal loanTokenName; StatusChoices internal status; address internal tokenPoolAddress; string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; // ETH pledge account mapping(address => uint256) internal verifyEthAccount; /** * Event for createOrderContract logging. * @param newOrderContract management contract address. */ event CreateOrderContract(address newOrderContract); /** * Event for WithdrawToken logging. * @param maker address of investor. * @param pledgeTokenName token name. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed maker, string pledgeTokenName, uint256 refundSum); /** * Event for appendEscrow logging. * @param maker address of borrower. * @param appendSum append amount. */ event AppendEscrow(address indexed maker, uint256 appendSum); /** * @dev Constructor initial contract configuration parameters */ constructor(uint256 _pledgeId, address _factory , address _escrowContract) public { require(_pledgeId > 0 && _factory != address(0) && _escrowContract != address(0)); pledgeId = _pledgeId; factory = _factory; status = StatusChoices.NO_PLEDGE_INFO; escrowContract = _escrowContract; } // ----------------------------------------- // external interface // ----------------------------------------- function() external payable { require(status != StatusChoices.PLEDGE_REFUND); // Identify the borrower. if (maker != address(0)) { require(address(msg.sender) == maker); } // Record basic information about the borrower's pledge ETH verifyEthAccount[msg.sender] = verifyEthAccount[msg.sender].add(msg.value); } /** * @dev Add the pledge information and transfer the pledged token into the corresponding currency pool. * @param _pledgeTokenName maker pledge token name. * @param _maker borrower address. * @param _pledgeSum pledge amount. * @param _loanTokenName pledge token type. */ function addRecord(string _pledgeTokenName, address _maker, uint256 _pledgeSum, string _loanTokenName) public onlyOwner { require(_maker != address(0) && _pledgeSum > 0 && status != StatusChoices.PLEDGE_REFUND); // Add the pledge information for the first time. if (status == StatusChoices.NO_PLEDGE_INFO) { // public data init. maker = _maker; pledgeTokenName = _pledgeTokenName; tokenPoolAddress = checkedTokenPool(pledgeTokenName); PledgeFactory(factory).updatePledgeType(pledgeId, pledgeTokenName); // Assign rights to the operation of the contract pool PledgeFactory(factory).tokenPoolOperater(tokenPoolAddress, address(this)); // Create order management contracts. createOrderContract(_loanTokenName); } // Record information of each pledge. pledgeAccountSum = pledgeAccountSum.add(_pledgeSum); PledgePoolBase(tokenPoolAddress).addRecord(maker, pledgeAccountSum, pledgeId, pledgeTokenName); // Transfer the pledge token to the appropriate token pool. if (pledgeTokenName.stringCompare(TOKEN_ETH)) { require(verifyEthAccount[maker] >= _pledgeSum); tokenPoolAddress.transfer(_pledgeSum); } else { token20 = checkedToken(pledgeTokenName); require(ERC20(token20).balanceOf(address(this)) >= _pledgeSum); require(safeErc20Transfer(token20,tokenPoolAddress, _pledgeSum)); } } /** * @dev Increase the number of pledged tokens. * @param _appendSum append amount. */ function appendEscrow(uint256 _appendSum) public onlyOwner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); addRecord(pledgeTokenName, maker, _appendSum, loanTokenName); emit AppendEscrow(maker, _appendSum); } /** * @dev Withdraw pledge behavior. * @param _maker borrower address. */ function withdrawToken(address _maker) public onlyOwner { require(status != StatusChoices.PLEDGE_REFUND); uint256 pledgeSum = 0; // there are two types of retractions. if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeSum = classifySquareUp(_maker); } else { status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).withdrawToken(pledgeId, maker, pledgeAccountSum)); pledgeSum = pledgeAccountSum; } emit WithdrawToken(_maker, pledgeTokenName, pledgeSum); } /** * @dev Executed in some extreme unforsee cases, to avoid eth locked. * @param _tokenName recycle token type. * @param _amount Number of eth to recycle. */ function recycle(string _tokenName, uint256 _amount) public onlyOwner { require(status != StatusChoices.NO_PLEDGE_INFO && _amount>0); if (_tokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _amount); owner.transfer(_amount); } else { address token = checkedToken(_tokenName); require(ERC20(token).balanceOf(address(this)) >= _amount); require(safeErc20Transfer(token,owner, _amount)); } } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _token20,address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(_token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(_token20).transfer(_toAddress, _transferSum)); } return true; } // ----------------------------------------- // internal interface // ----------------------------------------- /** * @dev Create an order process management contract for the match and repayment business. * @param _loanTokenName expect loan token type. */ function createOrderContract(string _loanTokenName) internal { require(bytes(_loanTokenName).length > 0); status = StatusChoices.PLEDGE_CREATE_MATCHING; address loanToken20 = checkedToken(_loanTokenName); OrderManageContract newOrder = new OrderManageContract(_loanTokenName, loanToken20, maker); setPartner(address(newOrder)); newOrder.setPartner(owner); // update contract public data. orderContract = newOrder; loanTokenName = _loanTokenName; emit CreateOrderContract(address(newOrder)); } /** * @dev classification withdraw. * @dev Execute without changing the current contract data state. * @param _maker borrower address. */ function classifySquareUp(address _maker) internal returns(uint256 sum) { if (pledgeTokenName.stringCompare(TOKEN_ETH)) { uint256 pledgeSum = verifyEthAccount[_maker]; require(pledgeSum > 0 && address(this).balance >= pledgeSum); _maker.transfer(pledgeSum); verifyEthAccount[_maker] = 0; sum = pledgeSum; } else { uint256 balance = ERC20(token20).balanceOf(address(this)); require(balance > 0); require(safeErc20Transfer(token20,_maker, balance)); sum = balance; } } /** * @dev Check wether the token is included for a token name. * @param _tokenName token name. */ function checkedToken(string _tokenName) internal view returns(address) { address tokenAddress = EscrowMaintainContract(escrowContract).includeToken(_tokenName); require(tokenAddress != address(0)); return tokenAddress; } /** * @dev Check wether the token pool is included for a token name. * @param _tokenName pledge token name. */ function checkedTokenPool(string _tokenName) internal view returns(address) { address tokenPool = EscrowMaintainContract(escrowContract).includeTokenPool(_tokenName); require(tokenPool != address(0)); return tokenPool; } // ----------------------------------------- // business relationship interface // (Only the order contract has authority to operate) // ----------------------------------------- /** * @dev Refund of the borrower’s pledge. */ function _conclude() public onlyPartner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, maker)); } /** * @dev Expired for repayment or close position. * @param _taker address of investor. */ function _forceConclude(address _taker) public onlyPartner { require(_taker != address(0) && status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, _taker)); } // ----------------------------------------- // query interface (use no gas) // ----------------------------------------- /** * @dev Get current contract order status. * @return pledgeStatus state indicate. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeStatus = "NO_PLEDGE_INFO"; } else if (status == StatusChoices.PLEDGE_CREATE_MATCHING) { pledgeStatus = "PLEDGE_CREATE_MATCHING"; } else { pledgeStatus = "PLEDGE_REFUND"; } } /** * @dev get order contract address. use no gas. */ function getOrderContract() public view returns(address) { return orderContract; } /** * @dev Gets the total number of tokens pledged under the current contract. */ function getPledgeAccountSum() public view returns(uint256) { return pledgeAccountSum; } /** * @dev get current contract borrower address. */ function getMakerAddress() public view returns(address) { return maker; } /** * @dev get current contract pledge Id. */ function getPledgeId() external view returns(uint256) { return pledgeId; } }
/** * @title PledgeContract * @dev Pledge process management contract */
NatSpecMultiLine
getPledgeAccountSum
function getPledgeAccountSum() public view returns(uint256) { return pledgeAccountSum; }
/** * @dev Gets the total number of tokens pledged under the current contract. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 10559, 10658 ] }
3,783
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeContract
contract PledgeContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Type of execution state of the pledge contract(irreversible) */ enum StatusChoices { NO_PLEDGE_INFO, PLEDGE_CREATE_MATCHING, PLEDGE_REFUND } string public pledgeTokenName; uint256 public pledgeId; address internal maker; address internal token20; address internal factory; address internal escrowContract; uint256 internal pledgeAccountSum; // order contract address address internal orderContract; string internal loanTokenName; StatusChoices internal status; address internal tokenPoolAddress; string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; // ETH pledge account mapping(address => uint256) internal verifyEthAccount; /** * Event for createOrderContract logging. * @param newOrderContract management contract address. */ event CreateOrderContract(address newOrderContract); /** * Event for WithdrawToken logging. * @param maker address of investor. * @param pledgeTokenName token name. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed maker, string pledgeTokenName, uint256 refundSum); /** * Event for appendEscrow logging. * @param maker address of borrower. * @param appendSum append amount. */ event AppendEscrow(address indexed maker, uint256 appendSum); /** * @dev Constructor initial contract configuration parameters */ constructor(uint256 _pledgeId, address _factory , address _escrowContract) public { require(_pledgeId > 0 && _factory != address(0) && _escrowContract != address(0)); pledgeId = _pledgeId; factory = _factory; status = StatusChoices.NO_PLEDGE_INFO; escrowContract = _escrowContract; } // ----------------------------------------- // external interface // ----------------------------------------- function() external payable { require(status != StatusChoices.PLEDGE_REFUND); // Identify the borrower. if (maker != address(0)) { require(address(msg.sender) == maker); } // Record basic information about the borrower's pledge ETH verifyEthAccount[msg.sender] = verifyEthAccount[msg.sender].add(msg.value); } /** * @dev Add the pledge information and transfer the pledged token into the corresponding currency pool. * @param _pledgeTokenName maker pledge token name. * @param _maker borrower address. * @param _pledgeSum pledge amount. * @param _loanTokenName pledge token type. */ function addRecord(string _pledgeTokenName, address _maker, uint256 _pledgeSum, string _loanTokenName) public onlyOwner { require(_maker != address(0) && _pledgeSum > 0 && status != StatusChoices.PLEDGE_REFUND); // Add the pledge information for the first time. if (status == StatusChoices.NO_PLEDGE_INFO) { // public data init. maker = _maker; pledgeTokenName = _pledgeTokenName; tokenPoolAddress = checkedTokenPool(pledgeTokenName); PledgeFactory(factory).updatePledgeType(pledgeId, pledgeTokenName); // Assign rights to the operation of the contract pool PledgeFactory(factory).tokenPoolOperater(tokenPoolAddress, address(this)); // Create order management contracts. createOrderContract(_loanTokenName); } // Record information of each pledge. pledgeAccountSum = pledgeAccountSum.add(_pledgeSum); PledgePoolBase(tokenPoolAddress).addRecord(maker, pledgeAccountSum, pledgeId, pledgeTokenName); // Transfer the pledge token to the appropriate token pool. if (pledgeTokenName.stringCompare(TOKEN_ETH)) { require(verifyEthAccount[maker] >= _pledgeSum); tokenPoolAddress.transfer(_pledgeSum); } else { token20 = checkedToken(pledgeTokenName); require(ERC20(token20).balanceOf(address(this)) >= _pledgeSum); require(safeErc20Transfer(token20,tokenPoolAddress, _pledgeSum)); } } /** * @dev Increase the number of pledged tokens. * @param _appendSum append amount. */ function appendEscrow(uint256 _appendSum) public onlyOwner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); addRecord(pledgeTokenName, maker, _appendSum, loanTokenName); emit AppendEscrow(maker, _appendSum); } /** * @dev Withdraw pledge behavior. * @param _maker borrower address. */ function withdrawToken(address _maker) public onlyOwner { require(status != StatusChoices.PLEDGE_REFUND); uint256 pledgeSum = 0; // there are two types of retractions. if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeSum = classifySquareUp(_maker); } else { status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).withdrawToken(pledgeId, maker, pledgeAccountSum)); pledgeSum = pledgeAccountSum; } emit WithdrawToken(_maker, pledgeTokenName, pledgeSum); } /** * @dev Executed in some extreme unforsee cases, to avoid eth locked. * @param _tokenName recycle token type. * @param _amount Number of eth to recycle. */ function recycle(string _tokenName, uint256 _amount) public onlyOwner { require(status != StatusChoices.NO_PLEDGE_INFO && _amount>0); if (_tokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _amount); owner.transfer(_amount); } else { address token = checkedToken(_tokenName); require(ERC20(token).balanceOf(address(this)) >= _amount); require(safeErc20Transfer(token,owner, _amount)); } } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _token20,address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(_token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(_token20).transfer(_toAddress, _transferSum)); } return true; } // ----------------------------------------- // internal interface // ----------------------------------------- /** * @dev Create an order process management contract for the match and repayment business. * @param _loanTokenName expect loan token type. */ function createOrderContract(string _loanTokenName) internal { require(bytes(_loanTokenName).length > 0); status = StatusChoices.PLEDGE_CREATE_MATCHING; address loanToken20 = checkedToken(_loanTokenName); OrderManageContract newOrder = new OrderManageContract(_loanTokenName, loanToken20, maker); setPartner(address(newOrder)); newOrder.setPartner(owner); // update contract public data. orderContract = newOrder; loanTokenName = _loanTokenName; emit CreateOrderContract(address(newOrder)); } /** * @dev classification withdraw. * @dev Execute without changing the current contract data state. * @param _maker borrower address. */ function classifySquareUp(address _maker) internal returns(uint256 sum) { if (pledgeTokenName.stringCompare(TOKEN_ETH)) { uint256 pledgeSum = verifyEthAccount[_maker]; require(pledgeSum > 0 && address(this).balance >= pledgeSum); _maker.transfer(pledgeSum); verifyEthAccount[_maker] = 0; sum = pledgeSum; } else { uint256 balance = ERC20(token20).balanceOf(address(this)); require(balance > 0); require(safeErc20Transfer(token20,_maker, balance)); sum = balance; } } /** * @dev Check wether the token is included for a token name. * @param _tokenName token name. */ function checkedToken(string _tokenName) internal view returns(address) { address tokenAddress = EscrowMaintainContract(escrowContract).includeToken(_tokenName); require(tokenAddress != address(0)); return tokenAddress; } /** * @dev Check wether the token pool is included for a token name. * @param _tokenName pledge token name. */ function checkedTokenPool(string _tokenName) internal view returns(address) { address tokenPool = EscrowMaintainContract(escrowContract).includeTokenPool(_tokenName); require(tokenPool != address(0)); return tokenPool; } // ----------------------------------------- // business relationship interface // (Only the order contract has authority to operate) // ----------------------------------------- /** * @dev Refund of the borrower’s pledge. */ function _conclude() public onlyPartner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, maker)); } /** * @dev Expired for repayment or close position. * @param _taker address of investor. */ function _forceConclude(address _taker) public onlyPartner { require(_taker != address(0) && status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, _taker)); } // ----------------------------------------- // query interface (use no gas) // ----------------------------------------- /** * @dev Get current contract order status. * @return pledgeStatus state indicate. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeStatus = "NO_PLEDGE_INFO"; } else if (status == StatusChoices.PLEDGE_CREATE_MATCHING) { pledgeStatus = "PLEDGE_CREATE_MATCHING"; } else { pledgeStatus = "PLEDGE_REFUND"; } } /** * @dev get order contract address. use no gas. */ function getOrderContract() public view returns(address) { return orderContract; } /** * @dev Gets the total number of tokens pledged under the current contract. */ function getPledgeAccountSum() public view returns(uint256) { return pledgeAccountSum; } /** * @dev get current contract borrower address. */ function getMakerAddress() public view returns(address) { return maker; } /** * @dev get current contract pledge Id. */ function getPledgeId() external view returns(uint256) { return pledgeId; } }
/** * @title PledgeContract * @dev Pledge process management contract */
NatSpecMultiLine
getMakerAddress
function getMakerAddress() public view returns(address) { return maker; }
/** * @dev get current contract borrower address. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 10725, 10809 ] }
3,784
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgeContract
contract PledgeContract is PartnerAuthority { using SafeMath for uint256; using SafeCompare for string; /** * @dev Type of execution state of the pledge contract(irreversible) */ enum StatusChoices { NO_PLEDGE_INFO, PLEDGE_CREATE_MATCHING, PLEDGE_REFUND } string public pledgeTokenName; uint256 public pledgeId; address internal maker; address internal token20; address internal factory; address internal escrowContract; uint256 internal pledgeAccountSum; // order contract address address internal orderContract; string internal loanTokenName; StatusChoices internal status; address internal tokenPoolAddress; string internal constant TOKEN_ETH = "ETH"; string internal constant TOKEN_USDT = "USDT"; // ETH pledge account mapping(address => uint256) internal verifyEthAccount; /** * Event for createOrderContract logging. * @param newOrderContract management contract address. */ event CreateOrderContract(address newOrderContract); /** * Event for WithdrawToken logging. * @param maker address of investor. * @param pledgeTokenName token name. * @param refundSum number of tokens withdrawn. */ event WithdrawToken(address indexed maker, string pledgeTokenName, uint256 refundSum); /** * Event for appendEscrow logging. * @param maker address of borrower. * @param appendSum append amount. */ event AppendEscrow(address indexed maker, uint256 appendSum); /** * @dev Constructor initial contract configuration parameters */ constructor(uint256 _pledgeId, address _factory , address _escrowContract) public { require(_pledgeId > 0 && _factory != address(0) && _escrowContract != address(0)); pledgeId = _pledgeId; factory = _factory; status = StatusChoices.NO_PLEDGE_INFO; escrowContract = _escrowContract; } // ----------------------------------------- // external interface // ----------------------------------------- function() external payable { require(status != StatusChoices.PLEDGE_REFUND); // Identify the borrower. if (maker != address(0)) { require(address(msg.sender) == maker); } // Record basic information about the borrower's pledge ETH verifyEthAccount[msg.sender] = verifyEthAccount[msg.sender].add(msg.value); } /** * @dev Add the pledge information and transfer the pledged token into the corresponding currency pool. * @param _pledgeTokenName maker pledge token name. * @param _maker borrower address. * @param _pledgeSum pledge amount. * @param _loanTokenName pledge token type. */ function addRecord(string _pledgeTokenName, address _maker, uint256 _pledgeSum, string _loanTokenName) public onlyOwner { require(_maker != address(0) && _pledgeSum > 0 && status != StatusChoices.PLEDGE_REFUND); // Add the pledge information for the first time. if (status == StatusChoices.NO_PLEDGE_INFO) { // public data init. maker = _maker; pledgeTokenName = _pledgeTokenName; tokenPoolAddress = checkedTokenPool(pledgeTokenName); PledgeFactory(factory).updatePledgeType(pledgeId, pledgeTokenName); // Assign rights to the operation of the contract pool PledgeFactory(factory).tokenPoolOperater(tokenPoolAddress, address(this)); // Create order management contracts. createOrderContract(_loanTokenName); } // Record information of each pledge. pledgeAccountSum = pledgeAccountSum.add(_pledgeSum); PledgePoolBase(tokenPoolAddress).addRecord(maker, pledgeAccountSum, pledgeId, pledgeTokenName); // Transfer the pledge token to the appropriate token pool. if (pledgeTokenName.stringCompare(TOKEN_ETH)) { require(verifyEthAccount[maker] >= _pledgeSum); tokenPoolAddress.transfer(_pledgeSum); } else { token20 = checkedToken(pledgeTokenName); require(ERC20(token20).balanceOf(address(this)) >= _pledgeSum); require(safeErc20Transfer(token20,tokenPoolAddress, _pledgeSum)); } } /** * @dev Increase the number of pledged tokens. * @param _appendSum append amount. */ function appendEscrow(uint256 _appendSum) public onlyOwner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); addRecord(pledgeTokenName, maker, _appendSum, loanTokenName); emit AppendEscrow(maker, _appendSum); } /** * @dev Withdraw pledge behavior. * @param _maker borrower address. */ function withdrawToken(address _maker) public onlyOwner { require(status != StatusChoices.PLEDGE_REFUND); uint256 pledgeSum = 0; // there are two types of retractions. if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeSum = classifySquareUp(_maker); } else { status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).withdrawToken(pledgeId, maker, pledgeAccountSum)); pledgeSum = pledgeAccountSum; } emit WithdrawToken(_maker, pledgeTokenName, pledgeSum); } /** * @dev Executed in some extreme unforsee cases, to avoid eth locked. * @param _tokenName recycle token type. * @param _amount Number of eth to recycle. */ function recycle(string _tokenName, uint256 _amount) public onlyOwner { require(status != StatusChoices.NO_PLEDGE_INFO && _amount>0); if (_tokenName.stringCompare(TOKEN_ETH)) { require(address(this).balance >= _amount); owner.transfer(_amount); } else { address token = checkedToken(_tokenName); require(ERC20(token).balanceOf(address(this)) >= _amount); require(safeErc20Transfer(token,owner, _amount)); } } /** * @dev Since the implementation of usdt ERC20.sol transfer code does not design the return value, * @dev which is different from most ERC20 token interfaces,most erc20 transfer token agreements return bool. * @dev it is necessary to independently adapt the interface for usdt token in order to transfer successfully * @dev if not, the transfer may fail. */ function safeErc20Transfer(address _token20,address _toAddress,uint256 _transferSum) internal returns (bool) { if(loanTokenName.stringCompare(TOKEN_USDT)){ UsdtERC20(_token20).transfer(_toAddress, _transferSum); }else{ require(ERC20(_token20).transfer(_toAddress, _transferSum)); } return true; } // ----------------------------------------- // internal interface // ----------------------------------------- /** * @dev Create an order process management contract for the match and repayment business. * @param _loanTokenName expect loan token type. */ function createOrderContract(string _loanTokenName) internal { require(bytes(_loanTokenName).length > 0); status = StatusChoices.PLEDGE_CREATE_MATCHING; address loanToken20 = checkedToken(_loanTokenName); OrderManageContract newOrder = new OrderManageContract(_loanTokenName, loanToken20, maker); setPartner(address(newOrder)); newOrder.setPartner(owner); // update contract public data. orderContract = newOrder; loanTokenName = _loanTokenName; emit CreateOrderContract(address(newOrder)); } /** * @dev classification withdraw. * @dev Execute without changing the current contract data state. * @param _maker borrower address. */ function classifySquareUp(address _maker) internal returns(uint256 sum) { if (pledgeTokenName.stringCompare(TOKEN_ETH)) { uint256 pledgeSum = verifyEthAccount[_maker]; require(pledgeSum > 0 && address(this).balance >= pledgeSum); _maker.transfer(pledgeSum); verifyEthAccount[_maker] = 0; sum = pledgeSum; } else { uint256 balance = ERC20(token20).balanceOf(address(this)); require(balance > 0); require(safeErc20Transfer(token20,_maker, balance)); sum = balance; } } /** * @dev Check wether the token is included for a token name. * @param _tokenName token name. */ function checkedToken(string _tokenName) internal view returns(address) { address tokenAddress = EscrowMaintainContract(escrowContract).includeToken(_tokenName); require(tokenAddress != address(0)); return tokenAddress; } /** * @dev Check wether the token pool is included for a token name. * @param _tokenName pledge token name. */ function checkedTokenPool(string _tokenName) internal view returns(address) { address tokenPool = EscrowMaintainContract(escrowContract).includeTokenPool(_tokenName); require(tokenPool != address(0)); return tokenPool; } // ----------------------------------------- // business relationship interface // (Only the order contract has authority to operate) // ----------------------------------------- /** * @dev Refund of the borrower’s pledge. */ function _conclude() public onlyPartner { require(status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, maker)); } /** * @dev Expired for repayment or close position. * @param _taker address of investor. */ function _forceConclude(address _taker) public onlyPartner { require(_taker != address(0) && status == StatusChoices.PLEDGE_CREATE_MATCHING); status = StatusChoices.PLEDGE_REFUND; require(PledgePoolBase(tokenPoolAddress).refundTokens(pledgeId, pledgeAccountSum, _taker)); } // ----------------------------------------- // query interface (use no gas) // ----------------------------------------- /** * @dev Get current contract order status. * @return pledgeStatus state indicate. */ function getPledgeStatus() public view returns(string pledgeStatus) { if (status == StatusChoices.NO_PLEDGE_INFO) { pledgeStatus = "NO_PLEDGE_INFO"; } else if (status == StatusChoices.PLEDGE_CREATE_MATCHING) { pledgeStatus = "PLEDGE_CREATE_MATCHING"; } else { pledgeStatus = "PLEDGE_REFUND"; } } /** * @dev get order contract address. use no gas. */ function getOrderContract() public view returns(address) { return orderContract; } /** * @dev Gets the total number of tokens pledged under the current contract. */ function getPledgeAccountSum() public view returns(uint256) { return pledgeAccountSum; } /** * @dev get current contract borrower address. */ function getMakerAddress() public view returns(address) { return maker; } /** * @dev get current contract pledge Id. */ function getPledgeId() external view returns(uint256) { return pledgeId; } }
/** * @title PledgeContract * @dev Pledge process management contract */
NatSpecMultiLine
getPledgeId
function getPledgeId() external view returns(uint256) { return pledgeId; }
/** * @dev get current contract pledge Id. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 10869, 10954 ] }
3,785
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgePoolBase
contract PledgePoolBase is RBACOperator { using SafeMath for uint256; using AddressUtils for address; // Record pledge details. mapping(uint256 => Escrow) internal escrows; /** * @dev Information structure of pledge. */ struct Escrow { uint256 pledgeSum; address payerAddress; string tokenName; } // ----------------------------------------- // TokenPool external interface // ----------------------------------------- /** * @dev addRecord, interface to add record. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function addRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) public hasOperationPermission returns(bool) { _preValidateAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); _processAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); return true; } /** * @dev withdrawToken, withdraw pledge token. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function withdrawToken(uint256 _pledgeId, address _maker, uint256 _num) public hasOperationPermission returns(bool) { _preValidateWithdraw(_maker, _num, _pledgeId); _processWithdraw(_maker, _num, _pledgeId); return true; } /** * @dev refundTokens, interface to refund * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function refundTokens(uint256 _pledgeId, uint256 _returnSum, address _targetAddress) public hasOperationPermission returns(bool) { _preValidateRefund(_returnSum, _targetAddress, _pledgeId); _processRefund(_returnSum, _targetAddress, _pledgeId); return true; } /** * @dev getLedger, Query the pledge details of the pledge number in the pool. * @param _pledgeId pledge contract index number. */ function getLedger(uint256 _pledgeId) public view returns(uint256 num, address payerAddress, string tokenName) { require(_pledgeId > 0); num = escrows[_pledgeId].pledgeSum; payerAddress = escrows[_pledgeId].payerAddress; tokenName = escrows[_pledgeId].tokenName; } // ----------------------------------------- // TokenPool internal interface (extensible) // ----------------------------------------- /** * @dev _preValidateAddRecord, Validation of an incoming AddRecord. Use require statemens to revert state when conditions are not met. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function _preValidateAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) view internal { require(_pledgeSum > 0 && _pledgeId > 0 && _payerAddress != address(0) && bytes(_tokenName).length > 0 && address(msg.sender).isContract() && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processAddRecord, Executed when a AddRecord has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function _processAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) internal { Escrow memory escrow = Escrow(_pledgeSum, _payerAddress, _tokenName); escrows[_pledgeId] = escrow; } /** * @dev _preValidateRefund, Validation of an incoming refund. Use require statemens to revert state when conditions are not met. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function _preValidateRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) view internal { require(_returnSum > 0 && _pledgeId > 0 && _targetAddress != address(0) && address(msg.sender).isContract() && _returnSum <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processRefund, Executed when a Refund has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function _processRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_returnSum); } /** * @dev _preValidateWithdraw, Withdraw initiated parameter validation. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function _preValidateWithdraw(address _maker, uint256 _num, uint256 _pledgeId) view internal { require(_num > 0 && _pledgeId > 0 && _maker != address(0) && address(msg.sender).isContract() && _num <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processWithdraw, Withdraw data update. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function _processWithdraw(address _maker, uint256 _num, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_num); } }
/** * @title pledge pool base * @dev a base tokenPool, any tokenPool for a specific token should inherit from this tokenPool. */
NatSpecMultiLine
addRecord
function addRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) public hasOperationPermission returns(bool) { _preValidateAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); _processAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); return true; }
/** * @dev addRecord, interface to add record. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 743, 1066 ] }
3,786
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgePoolBase
contract PledgePoolBase is RBACOperator { using SafeMath for uint256; using AddressUtils for address; // Record pledge details. mapping(uint256 => Escrow) internal escrows; /** * @dev Information structure of pledge. */ struct Escrow { uint256 pledgeSum; address payerAddress; string tokenName; } // ----------------------------------------- // TokenPool external interface // ----------------------------------------- /** * @dev addRecord, interface to add record. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function addRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) public hasOperationPermission returns(bool) { _preValidateAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); _processAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); return true; } /** * @dev withdrawToken, withdraw pledge token. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function withdrawToken(uint256 _pledgeId, address _maker, uint256 _num) public hasOperationPermission returns(bool) { _preValidateWithdraw(_maker, _num, _pledgeId); _processWithdraw(_maker, _num, _pledgeId); return true; } /** * @dev refundTokens, interface to refund * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function refundTokens(uint256 _pledgeId, uint256 _returnSum, address _targetAddress) public hasOperationPermission returns(bool) { _preValidateRefund(_returnSum, _targetAddress, _pledgeId); _processRefund(_returnSum, _targetAddress, _pledgeId); return true; } /** * @dev getLedger, Query the pledge details of the pledge number in the pool. * @param _pledgeId pledge contract index number. */ function getLedger(uint256 _pledgeId) public view returns(uint256 num, address payerAddress, string tokenName) { require(_pledgeId > 0); num = escrows[_pledgeId].pledgeSum; payerAddress = escrows[_pledgeId].payerAddress; tokenName = escrows[_pledgeId].tokenName; } // ----------------------------------------- // TokenPool internal interface (extensible) // ----------------------------------------- /** * @dev _preValidateAddRecord, Validation of an incoming AddRecord. Use require statemens to revert state when conditions are not met. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function _preValidateAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) view internal { require(_pledgeSum > 0 && _pledgeId > 0 && _payerAddress != address(0) && bytes(_tokenName).length > 0 && address(msg.sender).isContract() && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processAddRecord, Executed when a AddRecord has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function _processAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) internal { Escrow memory escrow = Escrow(_pledgeSum, _payerAddress, _tokenName); escrows[_pledgeId] = escrow; } /** * @dev _preValidateRefund, Validation of an incoming refund. Use require statemens to revert state when conditions are not met. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function _preValidateRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) view internal { require(_returnSum > 0 && _pledgeId > 0 && _targetAddress != address(0) && address(msg.sender).isContract() && _returnSum <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processRefund, Executed when a Refund has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function _processRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_returnSum); } /** * @dev _preValidateWithdraw, Withdraw initiated parameter validation. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function _preValidateWithdraw(address _maker, uint256 _num, uint256 _pledgeId) view internal { require(_num > 0 && _pledgeId > 0 && _maker != address(0) && address(msg.sender).isContract() && _num <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processWithdraw, Withdraw data update. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function _processWithdraw(address _maker, uint256 _num, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_num); } }
/** * @title pledge pool base * @dev a base tokenPool, any tokenPool for a specific token should inherit from this tokenPool. */
NatSpecMultiLine
withdrawToken
function withdrawToken(uint256 _pledgeId, address _maker, uint256 _num) public hasOperationPermission returns(bool) { _preValidateWithdraw(_maker, _num, _pledgeId); _processWithdraw(_maker, _num, _pledgeId); return true; }
/** * @dev withdrawToken, withdraw pledge token. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 1269, 1512 ] }
3,787
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgePoolBase
contract PledgePoolBase is RBACOperator { using SafeMath for uint256; using AddressUtils for address; // Record pledge details. mapping(uint256 => Escrow) internal escrows; /** * @dev Information structure of pledge. */ struct Escrow { uint256 pledgeSum; address payerAddress; string tokenName; } // ----------------------------------------- // TokenPool external interface // ----------------------------------------- /** * @dev addRecord, interface to add record. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function addRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) public hasOperationPermission returns(bool) { _preValidateAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); _processAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); return true; } /** * @dev withdrawToken, withdraw pledge token. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function withdrawToken(uint256 _pledgeId, address _maker, uint256 _num) public hasOperationPermission returns(bool) { _preValidateWithdraw(_maker, _num, _pledgeId); _processWithdraw(_maker, _num, _pledgeId); return true; } /** * @dev refundTokens, interface to refund * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function refundTokens(uint256 _pledgeId, uint256 _returnSum, address _targetAddress) public hasOperationPermission returns(bool) { _preValidateRefund(_returnSum, _targetAddress, _pledgeId); _processRefund(_returnSum, _targetAddress, _pledgeId); return true; } /** * @dev getLedger, Query the pledge details of the pledge number in the pool. * @param _pledgeId pledge contract index number. */ function getLedger(uint256 _pledgeId) public view returns(uint256 num, address payerAddress, string tokenName) { require(_pledgeId > 0); num = escrows[_pledgeId].pledgeSum; payerAddress = escrows[_pledgeId].payerAddress; tokenName = escrows[_pledgeId].tokenName; } // ----------------------------------------- // TokenPool internal interface (extensible) // ----------------------------------------- /** * @dev _preValidateAddRecord, Validation of an incoming AddRecord. Use require statemens to revert state when conditions are not met. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function _preValidateAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) view internal { require(_pledgeSum > 0 && _pledgeId > 0 && _payerAddress != address(0) && bytes(_tokenName).length > 0 && address(msg.sender).isContract() && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processAddRecord, Executed when a AddRecord has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function _processAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) internal { Escrow memory escrow = Escrow(_pledgeSum, _payerAddress, _tokenName); escrows[_pledgeId] = escrow; } /** * @dev _preValidateRefund, Validation of an incoming refund. Use require statemens to revert state when conditions are not met. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function _preValidateRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) view internal { require(_returnSum > 0 && _pledgeId > 0 && _targetAddress != address(0) && address(msg.sender).isContract() && _returnSum <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processRefund, Executed when a Refund has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function _processRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_returnSum); } /** * @dev _preValidateWithdraw, Withdraw initiated parameter validation. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function _preValidateWithdraw(address _maker, uint256 _num, uint256 _pledgeId) view internal { require(_num > 0 && _pledgeId > 0 && _maker != address(0) && address(msg.sender).isContract() && _num <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processWithdraw, Withdraw data update. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function _processWithdraw(address _maker, uint256 _num, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_num); } }
/** * @title pledge pool base * @dev a base tokenPool, any tokenPool for a specific token should inherit from this tokenPool. */
NatSpecMultiLine
refundTokens
function refundTokens(uint256 _pledgeId, uint256 _returnSum, address _targetAddress) public hasOperationPermission returns(bool) { _preValidateRefund(_returnSum, _targetAddress, _pledgeId); _processRefund(_returnSum, _targetAddress, _pledgeId); return true; }
/** * @dev refundTokens, interface to refund * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 1724, 2004 ] }
3,788
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgePoolBase
contract PledgePoolBase is RBACOperator { using SafeMath for uint256; using AddressUtils for address; // Record pledge details. mapping(uint256 => Escrow) internal escrows; /** * @dev Information structure of pledge. */ struct Escrow { uint256 pledgeSum; address payerAddress; string tokenName; } // ----------------------------------------- // TokenPool external interface // ----------------------------------------- /** * @dev addRecord, interface to add record. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function addRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) public hasOperationPermission returns(bool) { _preValidateAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); _processAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); return true; } /** * @dev withdrawToken, withdraw pledge token. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function withdrawToken(uint256 _pledgeId, address _maker, uint256 _num) public hasOperationPermission returns(bool) { _preValidateWithdraw(_maker, _num, _pledgeId); _processWithdraw(_maker, _num, _pledgeId); return true; } /** * @dev refundTokens, interface to refund * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function refundTokens(uint256 _pledgeId, uint256 _returnSum, address _targetAddress) public hasOperationPermission returns(bool) { _preValidateRefund(_returnSum, _targetAddress, _pledgeId); _processRefund(_returnSum, _targetAddress, _pledgeId); return true; } /** * @dev getLedger, Query the pledge details of the pledge number in the pool. * @param _pledgeId pledge contract index number. */ function getLedger(uint256 _pledgeId) public view returns(uint256 num, address payerAddress, string tokenName) { require(_pledgeId > 0); num = escrows[_pledgeId].pledgeSum; payerAddress = escrows[_pledgeId].payerAddress; tokenName = escrows[_pledgeId].tokenName; } // ----------------------------------------- // TokenPool internal interface (extensible) // ----------------------------------------- /** * @dev _preValidateAddRecord, Validation of an incoming AddRecord. Use require statemens to revert state when conditions are not met. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function _preValidateAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) view internal { require(_pledgeSum > 0 && _pledgeId > 0 && _payerAddress != address(0) && bytes(_tokenName).length > 0 && address(msg.sender).isContract() && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processAddRecord, Executed when a AddRecord has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function _processAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) internal { Escrow memory escrow = Escrow(_pledgeSum, _payerAddress, _tokenName); escrows[_pledgeId] = escrow; } /** * @dev _preValidateRefund, Validation of an incoming refund. Use require statemens to revert state when conditions are not met. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function _preValidateRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) view internal { require(_returnSum > 0 && _pledgeId > 0 && _targetAddress != address(0) && address(msg.sender).isContract() && _returnSum <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processRefund, Executed when a Refund has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function _processRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_returnSum); } /** * @dev _preValidateWithdraw, Withdraw initiated parameter validation. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function _preValidateWithdraw(address _maker, uint256 _num, uint256 _pledgeId) view internal { require(_num > 0 && _pledgeId > 0 && _maker != address(0) && address(msg.sender).isContract() && _num <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processWithdraw, Withdraw data update. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function _processWithdraw(address _maker, uint256 _num, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_num); } }
/** * @title pledge pool base * @dev a base tokenPool, any tokenPool for a specific token should inherit from this tokenPool. */
NatSpecMultiLine
getLedger
function getLedger(uint256 _pledgeId) public view returns(uint256 num, address payerAddress, string tokenName) { require(_pledgeId > 0); num = escrows[_pledgeId].pledgeSum; payerAddress = escrows[_pledgeId].payerAddress; tokenName = escrows[_pledgeId].tokenName; }
/** * @dev getLedger, Query the pledge details of the pledge number in the pool. * @param _pledgeId pledge contract index number. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 2155, 2445 ] }
3,789
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgePoolBase
contract PledgePoolBase is RBACOperator { using SafeMath for uint256; using AddressUtils for address; // Record pledge details. mapping(uint256 => Escrow) internal escrows; /** * @dev Information structure of pledge. */ struct Escrow { uint256 pledgeSum; address payerAddress; string tokenName; } // ----------------------------------------- // TokenPool external interface // ----------------------------------------- /** * @dev addRecord, interface to add record. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function addRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) public hasOperationPermission returns(bool) { _preValidateAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); _processAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); return true; } /** * @dev withdrawToken, withdraw pledge token. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function withdrawToken(uint256 _pledgeId, address _maker, uint256 _num) public hasOperationPermission returns(bool) { _preValidateWithdraw(_maker, _num, _pledgeId); _processWithdraw(_maker, _num, _pledgeId); return true; } /** * @dev refundTokens, interface to refund * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function refundTokens(uint256 _pledgeId, uint256 _returnSum, address _targetAddress) public hasOperationPermission returns(bool) { _preValidateRefund(_returnSum, _targetAddress, _pledgeId); _processRefund(_returnSum, _targetAddress, _pledgeId); return true; } /** * @dev getLedger, Query the pledge details of the pledge number in the pool. * @param _pledgeId pledge contract index number. */ function getLedger(uint256 _pledgeId) public view returns(uint256 num, address payerAddress, string tokenName) { require(_pledgeId > 0); num = escrows[_pledgeId].pledgeSum; payerAddress = escrows[_pledgeId].payerAddress; tokenName = escrows[_pledgeId].tokenName; } // ----------------------------------------- // TokenPool internal interface (extensible) // ----------------------------------------- /** * @dev _preValidateAddRecord, Validation of an incoming AddRecord. Use require statemens to revert state when conditions are not met. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function _preValidateAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) view internal { require(_pledgeSum > 0 && _pledgeId > 0 && _payerAddress != address(0) && bytes(_tokenName).length > 0 && address(msg.sender).isContract() && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processAddRecord, Executed when a AddRecord has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function _processAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) internal { Escrow memory escrow = Escrow(_pledgeSum, _payerAddress, _tokenName); escrows[_pledgeId] = escrow; } /** * @dev _preValidateRefund, Validation of an incoming refund. Use require statemens to revert state when conditions are not met. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function _preValidateRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) view internal { require(_returnSum > 0 && _pledgeId > 0 && _targetAddress != address(0) && address(msg.sender).isContract() && _returnSum <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processRefund, Executed when a Refund has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function _processRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_returnSum); } /** * @dev _preValidateWithdraw, Withdraw initiated parameter validation. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function _preValidateWithdraw(address _maker, uint256 _num, uint256 _pledgeId) view internal { require(_num > 0 && _pledgeId > 0 && _maker != address(0) && address(msg.sender).isContract() && _num <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processWithdraw, Withdraw data update. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function _processWithdraw(address _maker, uint256 _num, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_num); } }
/** * @title pledge pool base * @dev a base tokenPool, any tokenPool for a specific token should inherit from this tokenPool. */
NatSpecMultiLine
_preValidateAddRecord
function _preValidateAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) view internal { require(_pledgeSum > 0 && _pledgeId > 0 && _payerAddress != address(0) && bytes(_tokenName).length > 0 && address(msg.sender).isContract() && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); }
/** * @dev _preValidateAddRecord, Validation of an incoming AddRecord. Use require statemens to revert state when conditions are not met. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 2955, 3325 ] }
3,790
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgePoolBase
contract PledgePoolBase is RBACOperator { using SafeMath for uint256; using AddressUtils for address; // Record pledge details. mapping(uint256 => Escrow) internal escrows; /** * @dev Information structure of pledge. */ struct Escrow { uint256 pledgeSum; address payerAddress; string tokenName; } // ----------------------------------------- // TokenPool external interface // ----------------------------------------- /** * @dev addRecord, interface to add record. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function addRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) public hasOperationPermission returns(bool) { _preValidateAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); _processAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); return true; } /** * @dev withdrawToken, withdraw pledge token. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function withdrawToken(uint256 _pledgeId, address _maker, uint256 _num) public hasOperationPermission returns(bool) { _preValidateWithdraw(_maker, _num, _pledgeId); _processWithdraw(_maker, _num, _pledgeId); return true; } /** * @dev refundTokens, interface to refund * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function refundTokens(uint256 _pledgeId, uint256 _returnSum, address _targetAddress) public hasOperationPermission returns(bool) { _preValidateRefund(_returnSum, _targetAddress, _pledgeId); _processRefund(_returnSum, _targetAddress, _pledgeId); return true; } /** * @dev getLedger, Query the pledge details of the pledge number in the pool. * @param _pledgeId pledge contract index number. */ function getLedger(uint256 _pledgeId) public view returns(uint256 num, address payerAddress, string tokenName) { require(_pledgeId > 0); num = escrows[_pledgeId].pledgeSum; payerAddress = escrows[_pledgeId].payerAddress; tokenName = escrows[_pledgeId].tokenName; } // ----------------------------------------- // TokenPool internal interface (extensible) // ----------------------------------------- /** * @dev _preValidateAddRecord, Validation of an incoming AddRecord. Use require statemens to revert state when conditions are not met. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function _preValidateAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) view internal { require(_pledgeSum > 0 && _pledgeId > 0 && _payerAddress != address(0) && bytes(_tokenName).length > 0 && address(msg.sender).isContract() && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processAddRecord, Executed when a AddRecord has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function _processAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) internal { Escrow memory escrow = Escrow(_pledgeSum, _payerAddress, _tokenName); escrows[_pledgeId] = escrow; } /** * @dev _preValidateRefund, Validation of an incoming refund. Use require statemens to revert state when conditions are not met. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function _preValidateRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) view internal { require(_returnSum > 0 && _pledgeId > 0 && _targetAddress != address(0) && address(msg.sender).isContract() && _returnSum <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processRefund, Executed when a Refund has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function _processRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_returnSum); } /** * @dev _preValidateWithdraw, Withdraw initiated parameter validation. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function _preValidateWithdraw(address _maker, uint256 _num, uint256 _pledgeId) view internal { require(_num > 0 && _pledgeId > 0 && _maker != address(0) && address(msg.sender).isContract() && _num <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processWithdraw, Withdraw data update. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function _processWithdraw(address _maker, uint256 _num, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_num); } }
/** * @title pledge pool base * @dev a base tokenPool, any tokenPool for a specific token should inherit from this tokenPool. */
NatSpecMultiLine
_processAddRecord
function _processAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) internal { Escrow memory escrow = Escrow(_pledgeSum, _payerAddress, _tokenName); escrows[_pledgeId] = escrow; }
/** * @dev _processAddRecord, Executed when a AddRecord has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 3683, 3918 ] }
3,791
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgePoolBase
contract PledgePoolBase is RBACOperator { using SafeMath for uint256; using AddressUtils for address; // Record pledge details. mapping(uint256 => Escrow) internal escrows; /** * @dev Information structure of pledge. */ struct Escrow { uint256 pledgeSum; address payerAddress; string tokenName; } // ----------------------------------------- // TokenPool external interface // ----------------------------------------- /** * @dev addRecord, interface to add record. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function addRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) public hasOperationPermission returns(bool) { _preValidateAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); _processAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); return true; } /** * @dev withdrawToken, withdraw pledge token. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function withdrawToken(uint256 _pledgeId, address _maker, uint256 _num) public hasOperationPermission returns(bool) { _preValidateWithdraw(_maker, _num, _pledgeId); _processWithdraw(_maker, _num, _pledgeId); return true; } /** * @dev refundTokens, interface to refund * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function refundTokens(uint256 _pledgeId, uint256 _returnSum, address _targetAddress) public hasOperationPermission returns(bool) { _preValidateRefund(_returnSum, _targetAddress, _pledgeId); _processRefund(_returnSum, _targetAddress, _pledgeId); return true; } /** * @dev getLedger, Query the pledge details of the pledge number in the pool. * @param _pledgeId pledge contract index number. */ function getLedger(uint256 _pledgeId) public view returns(uint256 num, address payerAddress, string tokenName) { require(_pledgeId > 0); num = escrows[_pledgeId].pledgeSum; payerAddress = escrows[_pledgeId].payerAddress; tokenName = escrows[_pledgeId].tokenName; } // ----------------------------------------- // TokenPool internal interface (extensible) // ----------------------------------------- /** * @dev _preValidateAddRecord, Validation of an incoming AddRecord. Use require statemens to revert state when conditions are not met. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function _preValidateAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) view internal { require(_pledgeSum > 0 && _pledgeId > 0 && _payerAddress != address(0) && bytes(_tokenName).length > 0 && address(msg.sender).isContract() && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processAddRecord, Executed when a AddRecord has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function _processAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) internal { Escrow memory escrow = Escrow(_pledgeSum, _payerAddress, _tokenName); escrows[_pledgeId] = escrow; } /** * @dev _preValidateRefund, Validation of an incoming refund. Use require statemens to revert state when conditions are not met. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function _preValidateRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) view internal { require(_returnSum > 0 && _pledgeId > 0 && _targetAddress != address(0) && address(msg.sender).isContract() && _returnSum <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processRefund, Executed when a Refund has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function _processRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_returnSum); } /** * @dev _preValidateWithdraw, Withdraw initiated parameter validation. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function _preValidateWithdraw(address _maker, uint256 _num, uint256 _pledgeId) view internal { require(_num > 0 && _pledgeId > 0 && _maker != address(0) && address(msg.sender).isContract() && _num <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processWithdraw, Withdraw data update. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function _processWithdraw(address _maker, uint256 _num, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_num); } }
/** * @title pledge pool base * @dev a base tokenPool, any tokenPool for a specific token should inherit from this tokenPool. */
NatSpecMultiLine
_preValidateRefund
function _preValidateRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) view internal { require(_returnSum > 0 && _pledgeId > 0 && _targetAddress != address(0) && address(msg.sender).isContract() && _returnSum <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); }
/** * @dev _preValidateRefund, Validation of an incoming refund. Use require statemens to revert state when conditions are not met. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 4219, 4583 ] }
3,792
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgePoolBase
contract PledgePoolBase is RBACOperator { using SafeMath for uint256; using AddressUtils for address; // Record pledge details. mapping(uint256 => Escrow) internal escrows; /** * @dev Information structure of pledge. */ struct Escrow { uint256 pledgeSum; address payerAddress; string tokenName; } // ----------------------------------------- // TokenPool external interface // ----------------------------------------- /** * @dev addRecord, interface to add record. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function addRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) public hasOperationPermission returns(bool) { _preValidateAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); _processAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); return true; } /** * @dev withdrawToken, withdraw pledge token. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function withdrawToken(uint256 _pledgeId, address _maker, uint256 _num) public hasOperationPermission returns(bool) { _preValidateWithdraw(_maker, _num, _pledgeId); _processWithdraw(_maker, _num, _pledgeId); return true; } /** * @dev refundTokens, interface to refund * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function refundTokens(uint256 _pledgeId, uint256 _returnSum, address _targetAddress) public hasOperationPermission returns(bool) { _preValidateRefund(_returnSum, _targetAddress, _pledgeId); _processRefund(_returnSum, _targetAddress, _pledgeId); return true; } /** * @dev getLedger, Query the pledge details of the pledge number in the pool. * @param _pledgeId pledge contract index number. */ function getLedger(uint256 _pledgeId) public view returns(uint256 num, address payerAddress, string tokenName) { require(_pledgeId > 0); num = escrows[_pledgeId].pledgeSum; payerAddress = escrows[_pledgeId].payerAddress; tokenName = escrows[_pledgeId].tokenName; } // ----------------------------------------- // TokenPool internal interface (extensible) // ----------------------------------------- /** * @dev _preValidateAddRecord, Validation of an incoming AddRecord. Use require statemens to revert state when conditions are not met. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function _preValidateAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) view internal { require(_pledgeSum > 0 && _pledgeId > 0 && _payerAddress != address(0) && bytes(_tokenName).length > 0 && address(msg.sender).isContract() && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processAddRecord, Executed when a AddRecord has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function _processAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) internal { Escrow memory escrow = Escrow(_pledgeSum, _payerAddress, _tokenName); escrows[_pledgeId] = escrow; } /** * @dev _preValidateRefund, Validation of an incoming refund. Use require statemens to revert state when conditions are not met. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function _preValidateRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) view internal { require(_returnSum > 0 && _pledgeId > 0 && _targetAddress != address(0) && address(msg.sender).isContract() && _returnSum <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processRefund, Executed when a Refund has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function _processRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_returnSum); } /** * @dev _preValidateWithdraw, Withdraw initiated parameter validation. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function _preValidateWithdraw(address _maker, uint256 _num, uint256 _pledgeId) view internal { require(_num > 0 && _pledgeId > 0 && _maker != address(0) && address(msg.sender).isContract() && _num <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processWithdraw, Withdraw data update. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function _processWithdraw(address _maker, uint256 _num, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_num); } }
/** * @title pledge pool base * @dev a base tokenPool, any tokenPool for a specific token should inherit from this tokenPool. */
NatSpecMultiLine
_processRefund
function _processRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_returnSum); }
/** * @dev _processRefund, Executed when a Refund has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 4884, 5071 ] }
3,793
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgePoolBase
contract PledgePoolBase is RBACOperator { using SafeMath for uint256; using AddressUtils for address; // Record pledge details. mapping(uint256 => Escrow) internal escrows; /** * @dev Information structure of pledge. */ struct Escrow { uint256 pledgeSum; address payerAddress; string tokenName; } // ----------------------------------------- // TokenPool external interface // ----------------------------------------- /** * @dev addRecord, interface to add record. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function addRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) public hasOperationPermission returns(bool) { _preValidateAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); _processAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); return true; } /** * @dev withdrawToken, withdraw pledge token. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function withdrawToken(uint256 _pledgeId, address _maker, uint256 _num) public hasOperationPermission returns(bool) { _preValidateWithdraw(_maker, _num, _pledgeId); _processWithdraw(_maker, _num, _pledgeId); return true; } /** * @dev refundTokens, interface to refund * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function refundTokens(uint256 _pledgeId, uint256 _returnSum, address _targetAddress) public hasOperationPermission returns(bool) { _preValidateRefund(_returnSum, _targetAddress, _pledgeId); _processRefund(_returnSum, _targetAddress, _pledgeId); return true; } /** * @dev getLedger, Query the pledge details of the pledge number in the pool. * @param _pledgeId pledge contract index number. */ function getLedger(uint256 _pledgeId) public view returns(uint256 num, address payerAddress, string tokenName) { require(_pledgeId > 0); num = escrows[_pledgeId].pledgeSum; payerAddress = escrows[_pledgeId].payerAddress; tokenName = escrows[_pledgeId].tokenName; } // ----------------------------------------- // TokenPool internal interface (extensible) // ----------------------------------------- /** * @dev _preValidateAddRecord, Validation of an incoming AddRecord. Use require statemens to revert state when conditions are not met. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function _preValidateAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) view internal { require(_pledgeSum > 0 && _pledgeId > 0 && _payerAddress != address(0) && bytes(_tokenName).length > 0 && address(msg.sender).isContract() && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processAddRecord, Executed when a AddRecord has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function _processAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) internal { Escrow memory escrow = Escrow(_pledgeSum, _payerAddress, _tokenName); escrows[_pledgeId] = escrow; } /** * @dev _preValidateRefund, Validation of an incoming refund. Use require statemens to revert state when conditions are not met. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function _preValidateRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) view internal { require(_returnSum > 0 && _pledgeId > 0 && _targetAddress != address(0) && address(msg.sender).isContract() && _returnSum <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processRefund, Executed when a Refund has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function _processRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_returnSum); } /** * @dev _preValidateWithdraw, Withdraw initiated parameter validation. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function _preValidateWithdraw(address _maker, uint256 _num, uint256 _pledgeId) view internal { require(_num > 0 && _pledgeId > 0 && _maker != address(0) && address(msg.sender).isContract() && _num <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processWithdraw, Withdraw data update. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function _processWithdraw(address _maker, uint256 _num, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_num); } }
/** * @title pledge pool base * @dev a base tokenPool, any tokenPool for a specific token should inherit from this tokenPool. */
NatSpecMultiLine
_preValidateWithdraw
function _preValidateWithdraw(address _maker, uint256 _num, uint256 _pledgeId) view internal { require(_num > 0 && _pledgeId > 0 && _maker != address(0) && address(msg.sender).isContract() && _num <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); }
/** * @dev _preValidateWithdraw, Withdraw initiated parameter validation. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 5295, 5631 ] }
3,794
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
PledgePoolBase
contract PledgePoolBase is RBACOperator { using SafeMath for uint256; using AddressUtils for address; // Record pledge details. mapping(uint256 => Escrow) internal escrows; /** * @dev Information structure of pledge. */ struct Escrow { uint256 pledgeSum; address payerAddress; string tokenName; } // ----------------------------------------- // TokenPool external interface // ----------------------------------------- /** * @dev addRecord, interface to add record. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function addRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) public hasOperationPermission returns(bool) { _preValidateAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); _processAddRecord(_payerAddress, _pledgeSum, _pledgeId, _tokenName); return true; } /** * @dev withdrawToken, withdraw pledge token. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function withdrawToken(uint256 _pledgeId, address _maker, uint256 _num) public hasOperationPermission returns(bool) { _preValidateWithdraw(_maker, _num, _pledgeId); _processWithdraw(_maker, _num, _pledgeId); return true; } /** * @dev refundTokens, interface to refund * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function refundTokens(uint256 _pledgeId, uint256 _returnSum, address _targetAddress) public hasOperationPermission returns(bool) { _preValidateRefund(_returnSum, _targetAddress, _pledgeId); _processRefund(_returnSum, _targetAddress, _pledgeId); return true; } /** * @dev getLedger, Query the pledge details of the pledge number in the pool. * @param _pledgeId pledge contract index number. */ function getLedger(uint256 _pledgeId) public view returns(uint256 num, address payerAddress, string tokenName) { require(_pledgeId > 0); num = escrows[_pledgeId].pledgeSum; payerAddress = escrows[_pledgeId].payerAddress; tokenName = escrows[_pledgeId].tokenName; } // ----------------------------------------- // TokenPool internal interface (extensible) // ----------------------------------------- /** * @dev _preValidateAddRecord, Validation of an incoming AddRecord. Use require statemens to revert state when conditions are not met. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function _preValidateAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) view internal { require(_pledgeSum > 0 && _pledgeId > 0 && _payerAddress != address(0) && bytes(_tokenName).length > 0 && address(msg.sender).isContract() && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processAddRecord, Executed when a AddRecord has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _payerAddress Address performing the pleadge. * @param _pledgeSum the value to pleadge. * @param _pledgeId pledge contract index number. * @param _tokenName pledge token name. */ function _processAddRecord(address _payerAddress, uint256 _pledgeSum, uint256 _pledgeId, string _tokenName) internal { Escrow memory escrow = Escrow(_pledgeSum, _payerAddress, _tokenName); escrows[_pledgeId] = escrow; } /** * @dev _preValidateRefund, Validation of an incoming refund. Use require statemens to revert state when conditions are not met. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function _preValidateRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) view internal { require(_returnSum > 0 && _pledgeId > 0 && _targetAddress != address(0) && address(msg.sender).isContract() && _returnSum <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processRefund, Executed when a Refund has been validated and is ready to be executed. Not necessarily emits/sends tokens. * @param _pledgeId pledge contract index number. * @param _targetAddress transfer target address. * @param _returnSum return token sum. */ function _processRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_returnSum); } /** * @dev _preValidateWithdraw, Withdraw initiated parameter validation. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function _preValidateWithdraw(address _maker, uint256 _num, uint256 _pledgeId) view internal { require(_num > 0 && _pledgeId > 0 && _maker != address(0) && address(msg.sender).isContract() && _num <= escrows[_pledgeId].pledgeSum && PledgeContract(msg.sender).getPledgeId()==_pledgeId ); } /** * @dev _processWithdraw, Withdraw data update. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */ function _processWithdraw(address _maker, uint256 _num, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_num); } }
/** * @title pledge pool base * @dev a base tokenPool, any tokenPool for a specific token should inherit from this tokenPool. */
NatSpecMultiLine
_processWithdraw
function _processWithdraw(address _maker, uint256 _num, uint256 _pledgeId) internal { escrows[_pledgeId].pledgeSum = escrows[_pledgeId].pledgeSum.sub(_num); }
/** * @dev _processWithdraw, Withdraw data update. * @param _pledgeId pledge contract index number. * @param _maker borrower address. * @param _num withdraw token sum. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 5830, 5999 ] }
3,795
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
EthPledgePool
contract EthPledgePool is PledgePoolBase { using SafeMath for uint256; using AddressUtils for address; // ----------------------------------------- // TokenPool external interface // ----------------------------------------- /** * @dev fallback function */ function() external payable {} /** * @dev recycle, Executed in some extreme unforsee cases, to avoid eth locked. * @param _amount Number of eth to withdraw * @param _contract Multi-signature contracts, for the fair and just treatment of funds. */ function recycle(uint256 _amount,address _contract) public onlyOwner returns(bool) { require(_amount <= address(this).balance && _contract.isContract()); _contract.transfer(_amount); return true; } /** * @dev kill, kills the contract and send everything to `_address`.. */ function kills() public onlyOwner { selfdestruct(owner); } // ----------------------------------------- // token pool internal interface (extensible) // ----------------------------------------- /** * @dev Executed when a Refund has been validated and is ready to be executed. * Not necessarily emits/sends tokens. */ function _processRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) internal { super._processRefund(_returnSum, _targetAddress, _pledgeId); require(address(this).balance >= _returnSum); _targetAddress.transfer(_returnSum); } /** * @dev Withdraw pledge token. */ function _processWithdraw(address _maker, uint256 _num, uint256 _pledgeId) internal { super._processWithdraw(_maker, _num, _pledgeId); require(address(this).balance >= _num); _maker.transfer(_num); } }
/** * @title eth pledge pool. * @dev the tokenPool for ETH. */
NatSpecMultiLine
function() external payable {}
/** * @dev fallback function */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 286, 319 ] }
3,796
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
EthPledgePool
contract EthPledgePool is PledgePoolBase { using SafeMath for uint256; using AddressUtils for address; // ----------------------------------------- // TokenPool external interface // ----------------------------------------- /** * @dev fallback function */ function() external payable {} /** * @dev recycle, Executed in some extreme unforsee cases, to avoid eth locked. * @param _amount Number of eth to withdraw * @param _contract Multi-signature contracts, for the fair and just treatment of funds. */ function recycle(uint256 _amount,address _contract) public onlyOwner returns(bool) { require(_amount <= address(this).balance && _contract.isContract()); _contract.transfer(_amount); return true; } /** * @dev kill, kills the contract and send everything to `_address`.. */ function kills() public onlyOwner { selfdestruct(owner); } // ----------------------------------------- // token pool internal interface (extensible) // ----------------------------------------- /** * @dev Executed when a Refund has been validated and is ready to be executed. * Not necessarily emits/sends tokens. */ function _processRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) internal { super._processRefund(_returnSum, _targetAddress, _pledgeId); require(address(this).balance >= _returnSum); _targetAddress.transfer(_returnSum); } /** * @dev Withdraw pledge token. */ function _processWithdraw(address _maker, uint256 _num, uint256 _pledgeId) internal { super._processWithdraw(_maker, _num, _pledgeId); require(address(this).balance >= _num); _maker.transfer(_num); } }
/** * @title eth pledge pool. * @dev the tokenPool for ETH. */
NatSpecMultiLine
recycle
function recycle(uint256 _amount,address _contract) public onlyOwner returns(bool) { require(_amount <= address(this).balance && _contract.isContract()); _contract.transfer(_amount); return true; }
/** * @dev recycle, Executed in some extreme unforsee cases, to avoid eth locked. * @param _amount Number of eth to withdraw * @param _contract Multi-signature contracts, for the fair and just treatment of funds. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 559, 777 ] }
3,797
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
EthPledgePool
contract EthPledgePool is PledgePoolBase { using SafeMath for uint256; using AddressUtils for address; // ----------------------------------------- // TokenPool external interface // ----------------------------------------- /** * @dev fallback function */ function() external payable {} /** * @dev recycle, Executed in some extreme unforsee cases, to avoid eth locked. * @param _amount Number of eth to withdraw * @param _contract Multi-signature contracts, for the fair and just treatment of funds. */ function recycle(uint256 _amount,address _contract) public onlyOwner returns(bool) { require(_amount <= address(this).balance && _contract.isContract()); _contract.transfer(_amount); return true; } /** * @dev kill, kills the contract and send everything to `_address`.. */ function kills() public onlyOwner { selfdestruct(owner); } // ----------------------------------------- // token pool internal interface (extensible) // ----------------------------------------- /** * @dev Executed when a Refund has been validated and is ready to be executed. * Not necessarily emits/sends tokens. */ function _processRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) internal { super._processRefund(_returnSum, _targetAddress, _pledgeId); require(address(this).balance >= _returnSum); _targetAddress.transfer(_returnSum); } /** * @dev Withdraw pledge token. */ function _processWithdraw(address _maker, uint256 _num, uint256 _pledgeId) internal { super._processWithdraw(_maker, _num, _pledgeId); require(address(this).balance >= _num); _maker.transfer(_num); } }
/** * @title eth pledge pool. * @dev the tokenPool for ETH. */
NatSpecMultiLine
kills
function kills() public onlyOwner { selfdestruct(owner); }
/** * @dev kill, kills the contract and send everything to `_address`.. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 868, 937 ] }
3,798
EthPledgePool
EthPledgePool.sol
0xda4d3539c4fa5b76c242f42a8a751cfa8d104b73
Solidity
EthPledgePool
contract EthPledgePool is PledgePoolBase { using SafeMath for uint256; using AddressUtils for address; // ----------------------------------------- // TokenPool external interface // ----------------------------------------- /** * @dev fallback function */ function() external payable {} /** * @dev recycle, Executed in some extreme unforsee cases, to avoid eth locked. * @param _amount Number of eth to withdraw * @param _contract Multi-signature contracts, for the fair and just treatment of funds. */ function recycle(uint256 _amount,address _contract) public onlyOwner returns(bool) { require(_amount <= address(this).balance && _contract.isContract()); _contract.transfer(_amount); return true; } /** * @dev kill, kills the contract and send everything to `_address`.. */ function kills() public onlyOwner { selfdestruct(owner); } // ----------------------------------------- // token pool internal interface (extensible) // ----------------------------------------- /** * @dev Executed when a Refund has been validated and is ready to be executed. * Not necessarily emits/sends tokens. */ function _processRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) internal { super._processRefund(_returnSum, _targetAddress, _pledgeId); require(address(this).balance >= _returnSum); _targetAddress.transfer(_returnSum); } /** * @dev Withdraw pledge token. */ function _processWithdraw(address _maker, uint256 _num, uint256 _pledgeId) internal { super._processWithdraw(_maker, _num, _pledgeId); require(address(this).balance >= _num); _maker.transfer(_num); } }
/** * @title eth pledge pool. * @dev the tokenPool for ETH. */
NatSpecMultiLine
_processRefund
function _processRefund(uint256 _returnSum, address _targetAddress, uint256 _pledgeId) internal { super._processRefund(_returnSum, _targetAddress, _pledgeId); require(address(this).balance >= _returnSum); _targetAddress.transfer(_returnSum); }
/** * @dev Executed when a Refund has been validated and is ready to be executed. * Not necessarily emits/sends tokens. */
NatSpecMultiLine
v0.4.25+commit.59dbf8f1
bzzr://283d2ad813330ec0fe8e481dcbecbf64dce32d626fc76fd7d4771b47dc32a30c
{ "func_code_index": [ 1230, 1494 ] }
3,799