Unnamed: 0
int64 0
7.36k
| comments
stringlengths 3
35.2k
| code_string
stringlengths 1
527k
| code
stringlengths 1
527k
| __index_level_0__
int64 0
88.6k
|
---|---|---|---|---|
158 | // can later be changed with {transferOwnership}./ Initializes the contract setting the deployer as the initial owner. / | constructor() {
_setOwner(_msgSender());
}
| constructor() {
_setOwner(_msgSender());
}
| 143 |
65 | // Set a wallet address so that it has to pay transaction fees | function includeInFee(address account) public onlyOwner {
_isExcludedFromFee[account] = false;
}
| function includeInFee(address account) public onlyOwner {
_isExcludedFromFee[account] = false;
}
| 595 |
281 | // Admin Functions Put an evil address into blacklist | function blacklistAddress(address addr) public {
require(hasRole(MANAGER_ROLE, msg.sender), "Caller is not a manager");
_state.accounts[addr].isBlacklisted = true;
}
| function blacklistAddress(address addr) public {
require(hasRole(MANAGER_ROLE, msg.sender), "Caller is not a manager");
_state.accounts[addr].isBlacklisted = true;
}
| 75,368 |
10 | // Claim phygital NFT phygitalClaimRequest The phygital claim request signature The signature / | function claimPhygital(
PhygitalClaimRequest calldata phygitalClaimRequest,
bytes calldata signature
| function claimPhygital(
PhygitalClaimRequest calldata phygitalClaimRequest,
bytes calldata signature
| 9,882 |
73 | // If no default or external position remaining then remove component from components array | if (_setToken.getExternalPositionRealUnit(_component, _module) != 0) {
address[] memory positionModules = _setToken.getExternalPositionModules(_component);
if (_setToken.getDefaultPositionRealUnit(_component) == 0 && positionModules.length == 1) {
require(positionModules[0] == _module, "External positions must be 0 to remove component");
_setToken.removeComponent(_component);
}
| if (_setToken.getExternalPositionRealUnit(_component, _module) != 0) {
address[] memory positionModules = _setToken.getExternalPositionModules(_component);
if (_setToken.getDefaultPositionRealUnit(_component) == 0 && positionModules.length == 1) {
require(positionModules[0] == _module, "External positions must be 0 to remove component");
_setToken.removeComponent(_component);
}
| 29,702 |
155 | // Constructor for an oracle using only Chainlink with multiple pools to read from/_circuitChainlink Chainlink pool addresses (in order)/_circuitChainIsMultiplied Whether we should multiply or divide by this rate when computing Chainlink price | constructor(address[] memory _circuitChainlink, uint8[] memory _circuitChainIsMultiplied) {
uint256 circuitLength = _circuitChainlink.length;
require(circuitLength > 0, "106");
require(circuitLength == _circuitChainIsMultiplied.length, "104");
for (uint256 i = 0; i < circuitLength; i++) {
AggregatorV3Interface _pool = AggregatorV3Interface(_circuitChainlink[i]);
circuitChainlink.push(_pool);
chainlinkDecimals.push(_pool.decimals());
}
circuitChainIsMultiplied = _circuitChainIsMultiplied;
}
| constructor(address[] memory _circuitChainlink, uint8[] memory _circuitChainIsMultiplied) {
uint256 circuitLength = _circuitChainlink.length;
require(circuitLength > 0, "106");
require(circuitLength == _circuitChainIsMultiplied.length, "104");
for (uint256 i = 0; i < circuitLength; i++) {
AggregatorV3Interface _pool = AggregatorV3Interface(_circuitChainlink[i]);
circuitChainlink.push(_pool);
chainlinkDecimals.push(_pool.decimals());
}
circuitChainIsMultiplied = _circuitChainIsMultiplied;
}
| 77,772 |
47 | // Make it impossible for the sender to re-claim the same deposit. | bidToCheck.blindedBid = bytes32(0);
| bidToCheck.blindedBid = bytes32(0);
| 40,948 |
79 | // Opens a new channel between `participant1` and `participant2`/ and deposits for `participant1`. Can be called by anyone/participant1 Ethereum address of a channel participant/participant2 Ethereum address of the other channel participant/settle_timeout Number of blocks that need to be mined between a/ call to closeChannel and settleChannel/participant1_total_deposit The total amount of tokens that/ `participant1` will have as deposit | function openChannelWithDeposit(
address participant1,
address participant2,
uint256 settle_timeout,
uint256 participant1_total_deposit
)
public
isSafe
settleTimeoutValid(settle_timeout)
returns (uint256)
| function openChannelWithDeposit(
address participant1,
address participant2,
uint256 settle_timeout,
uint256 participant1_total_deposit
)
public
isSafe
settleTimeoutValid(settle_timeout)
returns (uint256)
| 58,212 |
85 | // This is an admin mint function to mint a quantity to a specific address/to address to mint to/quantity quantity to mint/ return the id of the first minted NFT | function adminMint(address to, uint256 quantity) external returns (uint256);
| function adminMint(address to, uint256 quantity) external returns (uint256);
| 3,373 |
68 | // `msg.sender` approves `spender` to spend `value` tokensspender The address of the account able to transfer the tokensvalue The amount of wei to be approved for transfer return Whether the approval was successful or not | function approve(address _spender, uint _value) public returns (bool ok) {
//validate _spender address
require(_spender != 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
| function approve(address _spender, uint _value) public returns (bool ok) {
//validate _spender address
require(_spender != 0);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
| 81,622 |
275 | // Gets the amount1 delta between two prices/Calculates liquidity(sqrt(upper) - sqrt(lower))/sqrtRatioAX96 A sqrt price/sqrtRatioBX96 Another sqrt price/liquidity The amount of usable liquidity/roundUp Whether to round the amount up, or down/ return amount1 Amount of token1 required to cover a position of size liquidity between the two passed prices | function getAmount1Delta(
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
uint128 liquidity,
bool roundUp
| function getAmount1Delta(
uint160 sqrtRatioAX96,
uint160 sqrtRatioBX96,
uint128 liquidity,
bool roundUp
| 2,545 |
32 | // Deposit `_value` tokens for `msg.sender` and lock for `_duration` _value Amount to deposit _duration Epoch time until tokens unlock from now / | function createLock(uint256 _value, uint256 _duration) external nonReentrant {
uint256 unlock_time = ((block.timestamp + _duration) / interval) * interval; // Locktime is rounded down to a multiple of interval
LockedBalance memory _locked = locked[msg.sender];
require(_value > 0, "VE: INVALID_VALUE");
require(_locked.amount == 0, "VE: EXISTING_LOCK_FOUND");
require(unlock_time > block.timestamp, "VE: UNLOCK_TIME_TOO_EARLY");
require(unlock_time <= block.timestamp + maxDuration, "VE: UNLOCK_TIME_TOO_LATE");
_depositFor(msg.sender, _value, 0, unlock_time, _locked, CRETE_LOCK_TYPE);
}
| function createLock(uint256 _value, uint256 _duration) external nonReentrant {
uint256 unlock_time = ((block.timestamp + _duration) / interval) * interval; // Locktime is rounded down to a multiple of interval
LockedBalance memory _locked = locked[msg.sender];
require(_value > 0, "VE: INVALID_VALUE");
require(_locked.amount == 0, "VE: EXISTING_LOCK_FOUND");
require(unlock_time > block.timestamp, "VE: UNLOCK_TIME_TOO_EARLY");
require(unlock_time <= block.timestamp + maxDuration, "VE: UNLOCK_TIME_TOO_LATE");
_depositFor(msg.sender, _value, 0, unlock_time, _locked, CRETE_LOCK_TYPE);
}
| 42,511 |
62 | // uint256 from = player.last_payout > dep.time ? player.last_payout : dep.time;uint256 to = block.timestamp > dep.expire ? dep.expire : uint256(block.timestamp); |
if(dep.status == 0) {
uint256 _day_payout = _getInvestDayPayoutOf(dep.amount, dep.period);
value += _day_payout;
}
|
if(dep.status == 0) {
uint256 _day_payout = _getInvestDayPayoutOf(dep.amount, dep.period);
value += _day_payout;
}
| 13,154 |
11 | // Updates the borrow allowance of a user on the specific debt token. delegator The address delegating the borrowing power delegatee The address receiving the delegated borrowing power amount The allowance amount being delegated. / | function _approveDelegation(address delegator, address delegatee, uint256 amount) internal {
_borrowAllowances[delegator][delegatee] = amount;
emit BorrowAllowanceDelegated(delegator, delegatee, _underlyingAsset, amount);
}
| function _approveDelegation(address delegator, address delegatee, uint256 amount) internal {
_borrowAllowances[delegator][delegatee] = amount;
emit BorrowAllowanceDelegated(delegator, delegatee, _underlyingAsset, amount);
}
| 18,848 |
34 | // fees need to be deducted from the pool since fees are deducted from position.collateral and collateral is treated as part of the pool | _decreasePoolAmount(_collateralToken, usdToTokenMin(_collateralToken, fee));
| _decreasePoolAmount(_collateralToken, usdToTokenMin(_collateralToken, fee));
| 13,643 |
100 | // Hooks // Check for 'ERC1400TokensSender' user extension in ERC1820 registry and call it. partition Name of the partition (bytes32 to be left empty for transfers where partition is not specified). operator Address which triggered the balance decrease (through transfer or redemption). from Token holder. to Token recipient for a transfer and 0x for a redemption. value Number of tokens the token holder balance is decreased by. data Extra information. operatorData Extra information, attached by the operator (if any). / | function _callSenderExtension(
bytes32 partition,
address operator,
address from,
address to,
uint256 value,
bytes memory data,
bytes memory operatorData
)
internal
| function _callSenderExtension(
bytes32 partition,
address operator,
address from,
address to,
uint256 value,
bytes memory data,
bytes memory operatorData
)
internal
| 12,262 |
43 | // If not in list or in list but inactive | if (!status[epoch][validator].isIn) {
| if (!status[epoch][validator].isIn) {
| 24,252 |
102 | // check output via tokenA -> weth -> tokenB | address[] memory pathB = new address[](3);
pathB[0] = _FromTokenContractAddress;
pathB[1] = wethTokenAddress;
pathB[2] = _ToTokenContractAddress;
uint256 amtB = uniswapRouter.getAmountsOut(
tokens2Trade,
pathB
)[2];
| address[] memory pathB = new address[](3);
pathB[0] = _FromTokenContractAddress;
pathB[1] = wethTokenAddress;
pathB[2] = _ToTokenContractAddress;
uint256 amtB = uniswapRouter.getAmountsOut(
tokens2Trade,
pathB
)[2];
| 34,849 |
49 | // | * @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
unchecked {
_approve(sender, _msgSender(), currentAllowance - amount);
}
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `sender` to `recipient`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[sender] = senderBalance - amount;
}
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
_afterTokenTransfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
| * @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* TIP: For a detailed writeup see our guide
* https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/
contract ERC20 is Context, IERC20, IERC20Metadata {
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* The default value of {decimals} is 18. To select a different value for
* {decimals} you should overload it.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the value {ERC20} uses, unless this function is
* overridden;
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual override returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual override returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `recipient` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/
function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(_msgSender(), recipient, amount);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual override returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 amount) public virtual override returns (bool) {
_approve(_msgSender(), spender, amount);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* Requirements:
*
* - `sender` and `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
* - the caller must have allowance for ``sender``'s tokens of at least
* `amount`.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
uint256 currentAllowance = _allowances[sender][_msgSender()];
require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
unchecked {
_approve(sender, _msgSender(), currentAllowance - amount);
}
return true;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
return true;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(_msgSender(), spender, currentAllowance - subtractedValue);
}
return true;
}
/**
* @dev Moves `amount` of tokens from `sender` to `recipient`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* Requirements:
*
* - `sender` cannot be the zero address.
* - `recipient` cannot be the zero address.
* - `sender` must have a balance of at least `amount`.
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual {
require(sender != address(0), "ERC20: transfer from the zero address");
require(recipient != address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(sender, recipient, amount);
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[sender] = senderBalance - amount;
}
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
_afterTokenTransfer(sender, recipient, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/
function _mint(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
_balances[account] += amount;
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/
function _burn(address account, uint256 amount) internal virtual {
require(account != address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
}
_totalSupply -= amount;
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal virtual {
require(owner != address(0), "ERC20: approve from the zero address");
require(spender != address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 amount
) internal virtual {}
}
| 38 |
97 | // The amount to take as revenue, in basis points. | uint256 public immutable revenueBps;
| uint256 public immutable revenueBps;
| 22,145 |
10 | // Current price is smaller than target (>0.5%), swap token1 for token0 We divide the amount of reserve1 to send that would balance the price in two because an ammout of reserve0 is going to come out | address[] memory path = new address[](2);
path[0] = address(token0);
path[1] = address(token1);
| address[] memory path = new address[](2);
path[0] = address(token0);
path[1] = address(token1);
| 34,285 |
45 | // Fallback function for funding smart contract. / | function() external payable {
fund();
}
| function() external payable {
fund();
}
| 39,842 |
5 | // Ensure enough ETH is provided | _checkFunds(msg.value, quantity, publicMintStage.mintPrice);
| _checkFunds(msg.value, quantity, publicMintStage.mintPrice);
| 30,967 |
2 | // 'e' not encountered yet, minting integer part or decimals | if (decimals) {
| if (decimals) {
| 35,170 |
115 | // 检查挖矿权限/account 目标账号/ return flag 挖矿权限标记,只有1表示可以挖矿 | function checkMinter(address account) external view returns (uint) {
return _minters[account];
}
| function checkMinter(address account) external view returns (uint) {
return _minters[account];
}
| 14,169 |
173 | // Emitted when the collected protocol fees are withdrawn by the factory owner/sender The address that collects the protocol fees/recipient The address that receives the collected protocol fees/amount0 The amount of token0 protocol fees that is withdrawn/amount0 The amount of token1 protocol fees that is withdrawn | event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);
| event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);
| 41,019 |
1 | // The underlying asset contract | IERC721 immutable public tokenContract;
| IERC721 immutable public tokenContract;
| 13,804 |
71 | // Owner can move funds of successful fund to fundWallet | function finaliseICO() public returns (bool);
| function finaliseICO() public returns (bool);
| 39,020 |
16 | // payout must be greater than 0 | require(_payoutPercentage > 0);
| require(_payoutPercentage > 0);
| 110 |
77 | // Creates mapping between a Storage ID and Storage/Handover submitter address then save in storage. | storageAddressMap[_storageID] = msg.sender;
| storageAddressMap[_storageID] = msg.sender;
| 25,102 |
152 | // Mints quantity tokens and transfers them to to. Requirements: - there must be quantity tokens remaining unminted in the total collection.- to cannot be the zero address.- quantity cannot be larger than the max batch size. | * Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bool isAdminMint,
bytes memory _data
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), "ERC721A: mint to the zero address");
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), "ERC721A: token already minted");
// For admin mints we do not want to enforce the maxBatchSize limit
if (isAdminMint == false) {
require(quantity <= maxBatchSize, "ERC721A: quantity to mint too high");
}
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
AddressData memory addressData = _addressData[to];
_addressData[to] = AddressData(
addressData.balance + uint128(quantity),
addressData.numberMinted + (isAdminMint ? 0 : uint128(quantity))
);
_ownerships[startTokenId] = TokenOwnership(to, uint64(block.timestamp));
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
"ERC721A: transfer to non ERC721Receiver implementer"
);
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
| * Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bool isAdminMint,
bytes memory _data
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), "ERC721A: mint to the zero address");
// We know if the first token in the batch doesn't exist, the other ones don't as well, because of serial ordering.
require(!_exists(startTokenId), "ERC721A: token already minted");
// For admin mints we do not want to enforce the maxBatchSize limit
if (isAdminMint == false) {
require(quantity <= maxBatchSize, "ERC721A: quantity to mint too high");
}
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
AddressData memory addressData = _addressData[to];
_addressData[to] = AddressData(
addressData.balance + uint128(quantity),
addressData.numberMinted + (isAdminMint ? 0 : uint128(quantity))
);
_ownerships[startTokenId] = TokenOwnership(to, uint64(block.timestamp));
uint256 updatedIndex = startTokenId;
for (uint256 i = 0; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
"ERC721A: transfer to non ERC721Receiver implementer"
);
updatedIndex++;
}
currentIndex = updatedIndex;
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
| 6,380 |
72 | // decrease sender's token balance | walletTokenBalance[lockedToken[_id].tokenAddress][msg.sender] = walletTokenBalance[lockedToken[_id].tokenAddress][msg.sender].sub(lockedToken[_id].tokenAmount);
| walletTokenBalance[lockedToken[_id].tokenAddress][msg.sender] = walletTokenBalance[lockedToken[_id].tokenAddress][msg.sender].sub(lockedToken[_id].tokenAmount);
| 28,856 |
3 | // mapping from worker to its internal state | mapping(address => WorkerState) private stateOf;
function isAvailable(address workerAddress)
public
override
view
returns (bool)
{
return stateOf[workerAddress] == WorkerState.Available;
}
| mapping(address => WorkerState) private stateOf;
function isAvailable(address workerAddress)
public
override
view
returns (bool)
{
return stateOf[workerAddress] == WorkerState.Available;
}
| 55,959 |
21 | // Internal function that Withdraws a quantity of tokens from the vault. _token The address of the ERC20 token_quantityThe number of tokens to withdraw / | function withdrawInternal(
address _token,
uint256 _quantity
)
internal
| function withdrawInternal(
address _token,
uint256 _quantity
)
internal
| 555 |
7 | // Adds two numbers, throws on overflow. | function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
require(c >= a, "add fail");
return c;
}
| function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
require(c >= a, "add fail");
return c;
}
| 58,053 |
40 | // In case the ratio >= scale, the calculation anyway leads to zero. | if (ratio >= LOCKED_PROFIT_RELEASE_SCALE) {
return 0;
}
| if (ratio >= LOCKED_PROFIT_RELEASE_SCALE) {
return 0;
}
| 15,284 |
348 | // Give permissions to new lsp contract and then hand over ownership. | longToken.addMinter(lspAddress);
longToken.addBurner(lspAddress);
longToken.resetOwner(lspAddress);
shortToken.addMinter(lspAddress);
shortToken.addBurner(lspAddress);
shortToken.resetOwner(lspAddress);
emit CreatedLongShortPair(lspAddress, msg.sender, address(longToken), address(shortToken));
| longToken.addMinter(lspAddress);
longToken.addBurner(lspAddress);
longToken.resetOwner(lspAddress);
shortToken.addMinter(lspAddress);
shortToken.addBurner(lspAddress);
shortToken.resetOwner(lspAddress);
emit CreatedLongShortPair(lspAddress, msg.sender, address(longToken), address(shortToken));
| 74,501 |
12 | // Sets the address that will receive the swap fees. account The address that will receive the swap fees. / | function setFeeReceiver(address payable account) external onlyOwner {
_setFeeReceiver(account);
}
| function setFeeReceiver(address payable account) external onlyOwner {
_setFeeReceiver(account);
}
| 36,422 |
22 | // Map each investor to a series of checkpoints | mapping(address => Checkpoint[]) checkpointBalances;
| mapping(address => Checkpoint[]) checkpointBalances;
| 26,164 |
146 | // returnAmount = isETH(toToken) ? toToken.balanceOf(address(this)) : address(this).balance;returnAmount = toToken.universalBalanceOf(address(this)); |
require (returnAmount >= minAmount, 'XTrinity slippage is too high');
|
require (returnAmount >= minAmount, 'XTrinity slippage is too high');
| 11,715 |
19 | // DepositHandler / | contract DepositHandler is OracleManageable, ReentrancyGuard, IERC721Receiver {
using SafeMath for uint;
// Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`
bytes4 private constant ERC721_RECEIVED = 0x150b7a02;
// Equals to `bytes4(keccak256("onERC721Received(address,address,uint256)"))`
// This is old ERC721 spec. We added this for compatibility
bytes4 private constant ERC721_RECEIVED_OLD = 0xf0b9e5ba;
enum TokenType {
unknown,
eth,
erc20,
erc721
}
enum DepositStatus {
invalid,
deposited,
failed
}
struct Deposit {
uint id;
DepositStatus status;
TokenType tokenType;
address owner;
address token;
uint value;
}
Deposit[] public deposits;
event ERC20Deposited(uint indexed depositId, address indexed owner, address indexed token, uint amount);
event ERC721Deposited(uint indexed depositId, address indexed owner, address indexed token, uint tokenId);
event ETHDeposited(uint indexed depositId, address indexed owner, uint amount);
event ERC20DepositCancelled(uint indexed depositId, address indexed owner, address indexed token, uint amount);
event ERC721DepositCancelled(uint indexed depositId, address indexed owner, address indexed token, uint tokenId);
event ETHDepositCancelled(uint indexed depositId, address indexed owner, uint amount);
/**
* @notice deposit ERC20 token
* @param tokenAddress The address of ERC20 token contract
* @param amount The amount of tokens to be deposited
*/
function depositERC20(address tokenAddress, uint amount) external {
require(amount > 0, "invalid amount");
require(amount <= IERC20(tokenAddress).balanceOf(msg.sender), "not enough balance");
require(amount <= IERC20(tokenAddress).allowance(msg.sender, address(this)), "not enough allowed");
uint balanceBefore = IERC20(tokenAddress).balanceOf(address(this));
IERC20(tokenAddress).transferFrom(msg.sender, address(this), amount);
uint balanceAfter = IERC20(tokenAddress).balanceOf(address(this));
require(amount == balanceAfter.sub(balanceBefore));
uint depositId = deposits.length;
deposits.length += 1;
_recordDeposit(depositId, DepositStatus.deposited, TokenType.erc20, msg.sender, tokenAddress, amount);
emit ERC20Deposited(depositId, msg.sender, tokenAddress, amount);
}
/**
* @notice deposit ERC721 token
* @param tokenAddress The address of ERC721 token contract
* @param tokenId The ID of token to be deposited
*/
function depositERC721(address tokenAddress, uint tokenId) external {
_depositERC721(tokenAddress, msg.sender, tokenId);
}
/**
* @notice deposit Ethereum
*/
function depositETH() external payable {
require(msg.value > 0);
uint depositId = deposits.length;
deposits.length += 1;
_recordDeposit(depositId, DepositStatus.deposited, TokenType.eth, msg.sender, address(0), msg.value);
emit ETHDeposited(depositId, msg.sender, msg.value);
}
/**
* @notice cancel deposit when oracle fails relay deposit to side chain.
* Reverts when given deposit is invalid or setted already failed.
* @param depositId The ID of deposit
*/
function cancelFailedDeposit(uint depositId) external onlyOracle nonReentrant {
require(depositId < deposits.length, "Invalid deposit ID");
Deposit storage deposit = deposits[depositId];
require(deposit.status == DepositStatus.deposited, "Invalid Deposit");
deposit.status = DepositStatus.failed;
if (deposit.tokenType == TokenType.eth) {
address payable ethReceiver = address(uint160(deposit.owner)); /* solhint not recognize payable address */ // solhint-disable-line
ethReceiver.transfer(deposit.value);
emit ETHDepositCancelled(depositId, deposit.owner, deposit.value);
} else if (deposit.tokenType == TokenType.erc20) {
IERC20(deposit.token).transfer(deposit.owner, deposit.value);
emit ERC20DepositCancelled(depositId, deposit.owner, deposit.token, deposit.value);
} else if (deposit.tokenType == TokenType.erc721) {
IERC721(deposit.token).safeTransferFrom(address(this), deposit.owner, deposit.value);
emit ERC721DepositCancelled(depositId, deposit.owner, deposit.token, deposit.value);
} else {
assert(false);
}
}
function initialize(address owner, address oracle) public initializer {
OracleManageable.initialize(owner, oracle);
ReentrancyGuard.initialize();
}
/**
* @notice Handle the receipt of an NFT
* @param from The address which previously owned the token
* @param tokenId The NFT identifier which is being transferred
* @return bytes4 `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
*/
function onERC721Received(
address, /* operator */
address from,
uint256 tokenId,
bytes memory /* data */
) public returns (bytes4) {
_handleOnERC721Received(msg.sender, from, tokenId);
return ERC721_RECEIVED;
}
/**
* @notice Handle the receipt of an NFT
* @param from The address which previously owned the token
* @param tokenId The NFT identifier which is being transferred
* @return bytes4 `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`
*/
function onERC721Received(address from, uint256 tokenId, bytes memory /* data */)
public returns (bytes4) {
_handleOnERC721Received(msg.sender, from, tokenId);
return ERC721_RECEIVED_OLD;
}
/**
* @notice get Deposit info by deposit ID
* @param depositId The ID of deposit
* @return DepositStatus The status of deposit
* @return TokenType The type of deposited token
* @return address The address of sender
* @return address The address of deposited token
* @return uint The value of deposited token.
*/
function getDeposit(uint depositId) public view returns (DepositStatus, TokenType, address, address, uint) {
Deposit storage deposit = deposits[depositId];
return (
deposit.status,
deposit.tokenType,
deposit.owner,
deposit.token,
deposit.value
);
}
/**
* @notice handle onERC721Received
* @param tokenAddress The address of ERC721 token contract
* @param from The address of token holder
* @param tokenId The ID of token to be deposited
*/
function _handleOnERC721Received(address tokenAddress, address from, uint tokenId) private {
uint depositId = deposits.length;
deposits.length += 1;
_recordDeposit(depositId, DepositStatus.deposited, TokenType.erc721, from, tokenAddress, tokenId);
emit ERC721Deposited(depositId, from, tokenAddress, tokenId);
}
/**
* @notice deposit ERC721 token
* @param tokenAddress The address of ERC721 token contract
* @param from The address of token holder
* @param tokenId The ID of token to be deposited
*/
function _depositERC721(address tokenAddress, address from, uint tokenId) internal {
require(IERC721(tokenAddress).ownerOf(tokenId) == from, "not token owner");
require(address(this) == IERC721(tokenAddress).getApproved(tokenId), "not allowed token");
IERC721(tokenAddress).transferFrom(from, address(this), tokenId);
require(IERC721(tokenAddress).ownerOf(tokenId) == address(this));
uint depositId = deposits.length;
deposits.length += 1;
_recordDeposit(depositId, DepositStatus.deposited, TokenType.erc721, from, tokenAddress, tokenId);
emit ERC721Deposited(depositId, from, tokenAddress, tokenId);
}
/**
* @notice record deposit to `deposits` list
* @param depositId The ID of deposit
* @param depositStatus The status of deposit
* @param tokenType The type of deposited token
* @param from The address of sender
* @param tokenAddress The address of deposited token
* @param value The vlaue of token. It is Amount when ETH or ERC20, tokenID when ERC721.
*/
function _recordDeposit(
uint depositId,
DepositStatus depositStatus,
TokenType tokenType,
address from,
address tokenAddress,
uint value
) internal {
deposits[depositId].status = depositStatus;
deposits[depositId].tokenType = tokenType;
deposits[depositId].owner = from;
deposits[depositId].token = tokenAddress;
deposits[depositId].value = value;
}
// Reserved storage space to allow for layout changes in the future.
uint256[50] private ______gap;
}
| contract DepositHandler is OracleManageable, ReentrancyGuard, IERC721Receiver {
using SafeMath for uint;
// Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`
bytes4 private constant ERC721_RECEIVED = 0x150b7a02;
// Equals to `bytes4(keccak256("onERC721Received(address,address,uint256)"))`
// This is old ERC721 spec. We added this for compatibility
bytes4 private constant ERC721_RECEIVED_OLD = 0xf0b9e5ba;
enum TokenType {
unknown,
eth,
erc20,
erc721
}
enum DepositStatus {
invalid,
deposited,
failed
}
struct Deposit {
uint id;
DepositStatus status;
TokenType tokenType;
address owner;
address token;
uint value;
}
Deposit[] public deposits;
event ERC20Deposited(uint indexed depositId, address indexed owner, address indexed token, uint amount);
event ERC721Deposited(uint indexed depositId, address indexed owner, address indexed token, uint tokenId);
event ETHDeposited(uint indexed depositId, address indexed owner, uint amount);
event ERC20DepositCancelled(uint indexed depositId, address indexed owner, address indexed token, uint amount);
event ERC721DepositCancelled(uint indexed depositId, address indexed owner, address indexed token, uint tokenId);
event ETHDepositCancelled(uint indexed depositId, address indexed owner, uint amount);
/**
* @notice deposit ERC20 token
* @param tokenAddress The address of ERC20 token contract
* @param amount The amount of tokens to be deposited
*/
function depositERC20(address tokenAddress, uint amount) external {
require(amount > 0, "invalid amount");
require(amount <= IERC20(tokenAddress).balanceOf(msg.sender), "not enough balance");
require(amount <= IERC20(tokenAddress).allowance(msg.sender, address(this)), "not enough allowed");
uint balanceBefore = IERC20(tokenAddress).balanceOf(address(this));
IERC20(tokenAddress).transferFrom(msg.sender, address(this), amount);
uint balanceAfter = IERC20(tokenAddress).balanceOf(address(this));
require(amount == balanceAfter.sub(balanceBefore));
uint depositId = deposits.length;
deposits.length += 1;
_recordDeposit(depositId, DepositStatus.deposited, TokenType.erc20, msg.sender, tokenAddress, amount);
emit ERC20Deposited(depositId, msg.sender, tokenAddress, amount);
}
/**
* @notice deposit ERC721 token
* @param tokenAddress The address of ERC721 token contract
* @param tokenId The ID of token to be deposited
*/
function depositERC721(address tokenAddress, uint tokenId) external {
_depositERC721(tokenAddress, msg.sender, tokenId);
}
/**
* @notice deposit Ethereum
*/
function depositETH() external payable {
require(msg.value > 0);
uint depositId = deposits.length;
deposits.length += 1;
_recordDeposit(depositId, DepositStatus.deposited, TokenType.eth, msg.sender, address(0), msg.value);
emit ETHDeposited(depositId, msg.sender, msg.value);
}
/**
* @notice cancel deposit when oracle fails relay deposit to side chain.
* Reverts when given deposit is invalid or setted already failed.
* @param depositId The ID of deposit
*/
function cancelFailedDeposit(uint depositId) external onlyOracle nonReentrant {
require(depositId < deposits.length, "Invalid deposit ID");
Deposit storage deposit = deposits[depositId];
require(deposit.status == DepositStatus.deposited, "Invalid Deposit");
deposit.status = DepositStatus.failed;
if (deposit.tokenType == TokenType.eth) {
address payable ethReceiver = address(uint160(deposit.owner)); /* solhint not recognize payable address */ // solhint-disable-line
ethReceiver.transfer(deposit.value);
emit ETHDepositCancelled(depositId, deposit.owner, deposit.value);
} else if (deposit.tokenType == TokenType.erc20) {
IERC20(deposit.token).transfer(deposit.owner, deposit.value);
emit ERC20DepositCancelled(depositId, deposit.owner, deposit.token, deposit.value);
} else if (deposit.tokenType == TokenType.erc721) {
IERC721(deposit.token).safeTransferFrom(address(this), deposit.owner, deposit.value);
emit ERC721DepositCancelled(depositId, deposit.owner, deposit.token, deposit.value);
} else {
assert(false);
}
}
function initialize(address owner, address oracle) public initializer {
OracleManageable.initialize(owner, oracle);
ReentrancyGuard.initialize();
}
/**
* @notice Handle the receipt of an NFT
* @param from The address which previously owned the token
* @param tokenId The NFT identifier which is being transferred
* @return bytes4 `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
*/
function onERC721Received(
address, /* operator */
address from,
uint256 tokenId,
bytes memory /* data */
) public returns (bytes4) {
_handleOnERC721Received(msg.sender, from, tokenId);
return ERC721_RECEIVED;
}
/**
* @notice Handle the receipt of an NFT
* @param from The address which previously owned the token
* @param tokenId The NFT identifier which is being transferred
* @return bytes4 `bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`
*/
function onERC721Received(address from, uint256 tokenId, bytes memory /* data */)
public returns (bytes4) {
_handleOnERC721Received(msg.sender, from, tokenId);
return ERC721_RECEIVED_OLD;
}
/**
* @notice get Deposit info by deposit ID
* @param depositId The ID of deposit
* @return DepositStatus The status of deposit
* @return TokenType The type of deposited token
* @return address The address of sender
* @return address The address of deposited token
* @return uint The value of deposited token.
*/
function getDeposit(uint depositId) public view returns (DepositStatus, TokenType, address, address, uint) {
Deposit storage deposit = deposits[depositId];
return (
deposit.status,
deposit.tokenType,
deposit.owner,
deposit.token,
deposit.value
);
}
/**
* @notice handle onERC721Received
* @param tokenAddress The address of ERC721 token contract
* @param from The address of token holder
* @param tokenId The ID of token to be deposited
*/
function _handleOnERC721Received(address tokenAddress, address from, uint tokenId) private {
uint depositId = deposits.length;
deposits.length += 1;
_recordDeposit(depositId, DepositStatus.deposited, TokenType.erc721, from, tokenAddress, tokenId);
emit ERC721Deposited(depositId, from, tokenAddress, tokenId);
}
/**
* @notice deposit ERC721 token
* @param tokenAddress The address of ERC721 token contract
* @param from The address of token holder
* @param tokenId The ID of token to be deposited
*/
function _depositERC721(address tokenAddress, address from, uint tokenId) internal {
require(IERC721(tokenAddress).ownerOf(tokenId) == from, "not token owner");
require(address(this) == IERC721(tokenAddress).getApproved(tokenId), "not allowed token");
IERC721(tokenAddress).transferFrom(from, address(this), tokenId);
require(IERC721(tokenAddress).ownerOf(tokenId) == address(this));
uint depositId = deposits.length;
deposits.length += 1;
_recordDeposit(depositId, DepositStatus.deposited, TokenType.erc721, from, tokenAddress, tokenId);
emit ERC721Deposited(depositId, from, tokenAddress, tokenId);
}
/**
* @notice record deposit to `deposits` list
* @param depositId The ID of deposit
* @param depositStatus The status of deposit
* @param tokenType The type of deposited token
* @param from The address of sender
* @param tokenAddress The address of deposited token
* @param value The vlaue of token. It is Amount when ETH or ERC20, tokenID when ERC721.
*/
function _recordDeposit(
uint depositId,
DepositStatus depositStatus,
TokenType tokenType,
address from,
address tokenAddress,
uint value
) internal {
deposits[depositId].status = depositStatus;
deposits[depositId].tokenType = tokenType;
deposits[depositId].owner = from;
deposits[depositId].token = tokenAddress;
deposits[depositId].value = value;
}
// Reserved storage space to allow for layout changes in the future.
uint256[50] private ______gap;
}
| 32,170 |
38 | // RewardPerTokenStored at last time accrue rewards to this account | uint rewardPerTokenUpdated;
| uint rewardPerTokenUpdated;
| 47,646 |
76 | // Get the content (a product code) of the last item in the array productCodes using the lastIndex we obtained above | keyToMove = storefronts[storeId].productCodes[lastIndex];
| keyToMove = storefronts[storeId].productCodes[lastIndex];
| 51,749 |
1 | // Get the total token supply | function totalSupply() public constant returns (uint256 _totalSupply);
| function totalSupply() public constant returns (uint256 _totalSupply);
| 8,997 |
36 | // _assetCategory Category of the asset - see { MultiToken.sol } _duration Loan duration in seconds _assetId ID of an ERC721 or ERC1155 token || 0 in case the token doesn't have IDs _assetAmount Amount of an ERC20 or ERC1155 token || 0 in case of NFTs _owner Address initiating the new Deedreturn Deed ID of the newly minted Deed / | function create(
address _assetAddress,
MultiToken.Category _assetCategory,
uint32 _duration,
uint256 _assetId,
uint256 _assetAmount,
address _owner
) external onlyPWN returns (uint256) {
id++;
| function create(
address _assetAddress,
MultiToken.Category _assetCategory,
uint32 _duration,
uint256 _assetId,
uint256 _assetAmount,
address _owner
) external onlyPWN returns (uint256) {
id++;
| 41,617 |
94 | // caps have to be consistent with each other | require(_softCap <= _cap);
softCap = _softCap;
softCapTime = _softCapTime;
| require(_softCap <= _cap);
softCap = _softCap;
softCapTime = _softCapTime;
| 42,050 |
28 | // Next price will in 2 times more if it less then 1 ether. | if (sellingPrice >= 1 ether)
drinkIdToPrice[_tokenId] = uint256(SafeMath.div(SafeMath.mul(sellingPrice, 3), 2));
else
drinkIdToPrice[_tokenId] = uint256(SafeMath.mul(sellingPrice, 2));
_transfer(oldOwner, newOwner, _tokenId);
| if (sellingPrice >= 1 ether)
drinkIdToPrice[_tokenId] = uint256(SafeMath.div(SafeMath.mul(sellingPrice, 3), 2));
else
drinkIdToPrice[_tokenId] = uint256(SafeMath.mul(sellingPrice, 2));
_transfer(oldOwner, newOwner, _tokenId);
| 9,804 |
60 | // Array index check | require(id < _lockers.length, "Error: Unknown token definition");
| require(id < _lockers.length, "Error: Unknown token definition");
| 67,413 |
28 | // Swap for buyback | uint256 ethBought = 0;
contractTokenBalance = buyback;
contractTokenBalance = checkWithPool(contractTokenBalance);
ethBought = swapEthBasedFees(contractTokenBalance);
| uint256 ethBought = 0;
contractTokenBalance = buyback;
contractTokenBalance = checkWithPool(contractTokenBalance);
ethBought = swapEthBasedFees(contractTokenBalance);
| 45,989 |
85 | // Find amount of tokens ready to be withdrawn by a swap party. / | function _withdrawableAmount(SwapOffer _offer) internal view returns(uint256) {
return _unlockedAmount(_offer.tokensForSwap).sub(_offer.withdrawnTokensForSwap);
}
| function _withdrawableAmount(SwapOffer _offer) internal view returns(uint256) {
return _unlockedAmount(_offer.tokensForSwap).sub(_offer.withdrawnTokensForSwap);
}
| 65,197 |
30 | // BlokkoContracts takes Smartys token in escrow from client and supplier./Both can claim the tokens if they send a valid signed message. | contract BlokkoOrder is IERC777Recipient, IERC777Sender, ERC1820Implementer {
IERC1820Registry private _erc1820 = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);
bytes32 constant private TOKENS_RECIPIENT_INTERFACE_HASH = keccak256("ERC777TokensRecipient");
bytes32 constant public TOKENS_SENDER_INTERFACE_HASH = keccak256("ERC777TokensSender");
IERC777 public blokkoToken;
/// @dev Link contract to Smartys token.
/// @dev For a smart contract to receive ERC777 tokens, it needs to implement the tokensReceived hook and register with ERC1820 registry as an ERC777TokensRecipient
constructor (IERC777 tokenAddress) public {
blokkoToken = IERC777(tokenAddress);
_erc1820.setInterfaceImplementer(address(this), TOKENS_RECIPIENT_INTERFACE_HASH, address(this));
}
using SafeMath for uint256;
function bytesToUint(bytes memory userData) public pure returns (uint256 number) {
number=0;
for(uint i=0;i<userData.length;i++){
number *= 256;
number += uint(uint8(userData[i]));
}
}
function uintToBytes(uint256 x) public pure returns (bytes memory b) {
b = new bytes(32);
for (uint i = 0; i < 32; i++) {
b[i] = byte(uint8(x / (2**(8*(31 - i)))));
}
}
function senderFor(address account) public {
_registerInterfaceForAddress(TOKENS_SENDER_INTERFACE_HASH, account);
}
event DoneStuff(address operator, address from, address to, uint256 amount, bytes userData, bytes operatorData);
function tokensToSend(
address operator,
address from,
address to,
uint256 amount,
bytes memory userData,
bytes memory operatorData
) public {
emit DoneStuff(operator, from, to, amount, userData, operatorData);
}
/// @dev Define contract parameters.
/// @param orderID Contract nonce to prevent replay attack (make sure escrow can only be claimed successfully once).
uint256 orderID;
/// @dev Define order status parameters.
/// @param escrowPaid Set to true when client has paid escrow. By default initialized to `false`.
/// @param orderPaid Set to true after order is settled. By default initialized to `false`.
/// @param orderEnded Set to true after order is settled or cancelled, disallows any change. By default initialized to `false`.
/// @param status Sets status of the order. Possible values: `1-registered, 2-escrowPaid, 3-deliveredInTime, 4-deliveredLate, 5-cancelledInTime, 6-cancelledLate`.
/// @param deliveryEnd Timestamp of registry of transport delivery.
struct OrderStatus {
uint256 deliveryEnd;
uint256 finalCostPaid;
bool escrowPaid;
bool orderPaid;
bool orderEnded;
string status;
}
/// @param OrderData Array of dynamic size to capture the contract data for a specific order.
/// @param orderAmount Escrowed by client, can be claimed by supplier if client confirms delivery.
/// @param goodsReceived True when valid signed message by client is received.
/// @param deliveryStart Timestamp of registry of transport start.
/// @param deliveryTime Maximum agreed delivery timestamp.
struct OrderData {
string sessionUuid;
address supplier;
address client;
uint256 orderAmount;
uint256 transportAmount;
string ipfsOrderHash;
uint256 transportTime;
uint256 deliveryStart;
uint256 deliveryTime;
OrderStatus status;
}
mapping (uint256 => OrderData) public orders;
uint256[] public orderIDs;
/// @notice Register order parameters and store in struct
/// @param _transportTime Transport time in seconds.
/// @return orderID that is increased by 1 for every new order registered
event newOrder(uint256 orderID, string status);
function defineOrder(
string memory _sessionUuid,
address _supplier_address,
uint256 _orderAmount,
uint256 _transportAmount,
uint256 _transportTime,
string memory _ipfsOrderHash
) public returns(uint256) {
/// @dev set orderID.status
orderID++;
/// @dev set order parameters
orders[orderID].sessionUuid = _sessionUuid;
orders[orderID].supplier = _supplier_address;
orders[orderID].client = msg.sender;
orders[orderID].transportAmount = _transportAmount;
orders[orderID].orderAmount = _orderAmount;
orders[orderID].transportTime = _transportTime;
orders[orderID].ipfsOrderHash = _ipfsOrderHash;
orders[orderID].status.status = "1-registered";
/// @dev push the new orderId to the array of uints orderIDs
orderIDs.push(orderID);
emit newOrder(orderID, orders[orderID].status.status);
}
function getOrderIDs() view public returns(uint256[] memory){
return orderIDs;
}
function storeIPFSOrderHash(
uint256 _selectedOrderID,
string memory _ipfsOrderHash
) public {
// set parameters
orders[_selectedOrderID].ipfsOrderHash = _ipfsOrderHash;
}
/// @dev Code from https://forum.openzeppelin.com/t/simple-erc777-token-example/746
event receivedTokens(string text, address operator, address from, address to, uint256 amount, bytes userData, bytes operatorData);
event clientDeposited(string status, uint256 orderID, uint256 _deliveryStart, uint256 _deliveryTime);
function tokensReceived(
address operator,
address from,
address to,
uint256 amount,
bytes calldata userData, // asume only uint
bytes calldata operatorData
) external {
uint256 _selectedOrderID = bytesToUint(userData);
uint256 _escrowAmount = orders[_selectedOrderID].orderAmount.add(orders[_selectedOrderID].transportAmount);
/// @dev set order parameters
uint256 _deliveryStart = uint64(block.timestamp);
orders[_selectedOrderID].deliveryStart = _deliveryStart;
orders[_selectedOrderID].deliveryTime = _deliveryStart.add(orders[_selectedOrderID].transportTime);
// check conditions
require(msg.sender == address(blokkoToken), "Simple777Recipient: Invalid ERC777 token");
require(from == orders[_selectedOrderID].client, "Payment not made by client");
require(amount == _escrowAmount, "Escrow payment is not the same as the order amount");
require(orders[_selectedOrderID].status.escrowPaid == false, "Escrow is already deposited");
require(orders[_selectedOrderID].status.orderEnded == false, "Order is already ended");
emit receivedTokens("tokensReceived", operator, from, to, amount, userData, operatorData);
// register payment
orders[_selectedOrderID].status.escrowPaid = true;
orders[_selectedOrderID].status.status = "2-escrowPaid";
emit clientDeposited(orders[_selectedOrderID].status.status, _selectedOrderID, _deliveryStart, orders[_selectedOrderID].deliveryTime);
}
/// @notice Register delivery timestamp and settle payments
event transportReceived(string status, uint orderID, bool orderEnded, uint256 finalCostPaid);
function recieveTransport(bytes memory userData) public {
uint256 _selectedOrderID = bytesToUint(userData);
uint256 _deliveryEnd = uint64(block.timestamp);
uint256 _totalAmount = orders[_selectedOrderID].transportAmount.add(orders[_selectedOrderID].orderAmount);
require(msg.sender == orders[_selectedOrderID].client, "Only client can register transport receipt");
require(orders[_selectedOrderID].status.escrowPaid == true, "No escrow has been deposited");
require(orders[_selectedOrderID].status.orderEnded == false, "Transport already ended");
if (_deliveryEnd <= orders[_selectedOrderID].deliveryTime ) {
// Scenario green
blokkoToken.send(orders[_selectedOrderID].supplier, _totalAmount, userData);
orders[_selectedOrderID].status.finalCostPaid = _totalAmount;
orders[_selectedOrderID].status.status = "3-deliveredInTime";
} else {
// Scenario red
blokkoToken.send(orders[_selectedOrderID].supplier, orders[_selectedOrderID].orderAmount, userData);
blokkoToken.send(orders[_selectedOrderID].client, orders[_selectedOrderID].transportAmount, userData);
orders[_selectedOrderID].status.finalCostPaid = orders[_selectedOrderID].orderAmount;
orders[_selectedOrderID].status.status = "4-deliveredLate";
}
orders[_selectedOrderID].status.deliveryEnd = _deliveryEnd;
orders[_selectedOrderID].status.orderEnded = true;
emit transportReceived(orders[_selectedOrderID].status.status, _selectedOrderID, orders[_selectedOrderID].status.orderEnded, orders[_selectedOrderID].status.finalCostPaid);
}
/// @notice Register cancel order by client and settle payments
event orderCancelled(string status, uint orderID, bool _orderEnded);
function cancelOrder(bytes memory userData) public {
uint256 _selectedOrderID = bytesToUint(userData);
uint256 _deliveryEnd = uint64(block.timestamp);
uint256 _totalAmount = orders[_selectedOrderID].transportAmount.add(orders[_selectedOrderID].orderAmount);
require(msg.sender == orders[_selectedOrderID].client, "Only client can call this function.");
require(orders[_selectedOrderID].status.escrowPaid == true, "No escrow has been deposited.");
require(orders[_selectedOrderID].status.orderEnded == false, "Transport already ended.");
if (_deliveryEnd <= orders[_selectedOrderID].deliveryTime ) {
// Scenario green: cancelled within delivery time
blokkoToken.send(orders[_selectedOrderID].client, orders[_selectedOrderID].orderAmount, userData);
blokkoToken.send(orders[_selectedOrderID].supplier, orders[_selectedOrderID].transportAmount, userData);
orders[_selectedOrderID].status.status = "5-cancelledIntime";
} else {
// Scenario red: cancelled outside delivery time
blokkoToken.send(orders[_selectedOrderID].client, _totalAmount, userData);
orders[_selectedOrderID].status.status = "6-cancelledLate";
}
orders[_selectedOrderID].status.orderEnded = true;
emit orderCancelled(orders[_selectedOrderID].status.status, _selectedOrderID, orders[_selectedOrderID].status.orderEnded);
}
event depositedStatus(bool escrowPaid);
function depositStatus(uint256 _selectedOrderID) public /* onlyBy(client) */ {
bool _escrowPaid = orders[_selectedOrderID].status.escrowPaid;
emit depositedStatus(_escrowPaid);
}
} | contract BlokkoOrder is IERC777Recipient, IERC777Sender, ERC1820Implementer {
IERC1820Registry private _erc1820 = IERC1820Registry(0x1820a4B7618BdE71Dce8cdc73aAB6C95905faD24);
bytes32 constant private TOKENS_RECIPIENT_INTERFACE_HASH = keccak256("ERC777TokensRecipient");
bytes32 constant public TOKENS_SENDER_INTERFACE_HASH = keccak256("ERC777TokensSender");
IERC777 public blokkoToken;
/// @dev Link contract to Smartys token.
/// @dev For a smart contract to receive ERC777 tokens, it needs to implement the tokensReceived hook and register with ERC1820 registry as an ERC777TokensRecipient
constructor (IERC777 tokenAddress) public {
blokkoToken = IERC777(tokenAddress);
_erc1820.setInterfaceImplementer(address(this), TOKENS_RECIPIENT_INTERFACE_HASH, address(this));
}
using SafeMath for uint256;
function bytesToUint(bytes memory userData) public pure returns (uint256 number) {
number=0;
for(uint i=0;i<userData.length;i++){
number *= 256;
number += uint(uint8(userData[i]));
}
}
function uintToBytes(uint256 x) public pure returns (bytes memory b) {
b = new bytes(32);
for (uint i = 0; i < 32; i++) {
b[i] = byte(uint8(x / (2**(8*(31 - i)))));
}
}
function senderFor(address account) public {
_registerInterfaceForAddress(TOKENS_SENDER_INTERFACE_HASH, account);
}
event DoneStuff(address operator, address from, address to, uint256 amount, bytes userData, bytes operatorData);
function tokensToSend(
address operator,
address from,
address to,
uint256 amount,
bytes memory userData,
bytes memory operatorData
) public {
emit DoneStuff(operator, from, to, amount, userData, operatorData);
}
/// @dev Define contract parameters.
/// @param orderID Contract nonce to prevent replay attack (make sure escrow can only be claimed successfully once).
uint256 orderID;
/// @dev Define order status parameters.
/// @param escrowPaid Set to true when client has paid escrow. By default initialized to `false`.
/// @param orderPaid Set to true after order is settled. By default initialized to `false`.
/// @param orderEnded Set to true after order is settled or cancelled, disallows any change. By default initialized to `false`.
/// @param status Sets status of the order. Possible values: `1-registered, 2-escrowPaid, 3-deliveredInTime, 4-deliveredLate, 5-cancelledInTime, 6-cancelledLate`.
/// @param deliveryEnd Timestamp of registry of transport delivery.
struct OrderStatus {
uint256 deliveryEnd;
uint256 finalCostPaid;
bool escrowPaid;
bool orderPaid;
bool orderEnded;
string status;
}
/// @param OrderData Array of dynamic size to capture the contract data for a specific order.
/// @param orderAmount Escrowed by client, can be claimed by supplier if client confirms delivery.
/// @param goodsReceived True when valid signed message by client is received.
/// @param deliveryStart Timestamp of registry of transport start.
/// @param deliveryTime Maximum agreed delivery timestamp.
struct OrderData {
string sessionUuid;
address supplier;
address client;
uint256 orderAmount;
uint256 transportAmount;
string ipfsOrderHash;
uint256 transportTime;
uint256 deliveryStart;
uint256 deliveryTime;
OrderStatus status;
}
mapping (uint256 => OrderData) public orders;
uint256[] public orderIDs;
/// @notice Register order parameters and store in struct
/// @param _transportTime Transport time in seconds.
/// @return orderID that is increased by 1 for every new order registered
event newOrder(uint256 orderID, string status);
function defineOrder(
string memory _sessionUuid,
address _supplier_address,
uint256 _orderAmount,
uint256 _transportAmount,
uint256 _transportTime,
string memory _ipfsOrderHash
) public returns(uint256) {
/// @dev set orderID.status
orderID++;
/// @dev set order parameters
orders[orderID].sessionUuid = _sessionUuid;
orders[orderID].supplier = _supplier_address;
orders[orderID].client = msg.sender;
orders[orderID].transportAmount = _transportAmount;
orders[orderID].orderAmount = _orderAmount;
orders[orderID].transportTime = _transportTime;
orders[orderID].ipfsOrderHash = _ipfsOrderHash;
orders[orderID].status.status = "1-registered";
/// @dev push the new orderId to the array of uints orderIDs
orderIDs.push(orderID);
emit newOrder(orderID, orders[orderID].status.status);
}
function getOrderIDs() view public returns(uint256[] memory){
return orderIDs;
}
function storeIPFSOrderHash(
uint256 _selectedOrderID,
string memory _ipfsOrderHash
) public {
// set parameters
orders[_selectedOrderID].ipfsOrderHash = _ipfsOrderHash;
}
/// @dev Code from https://forum.openzeppelin.com/t/simple-erc777-token-example/746
event receivedTokens(string text, address operator, address from, address to, uint256 amount, bytes userData, bytes operatorData);
event clientDeposited(string status, uint256 orderID, uint256 _deliveryStart, uint256 _deliveryTime);
function tokensReceived(
address operator,
address from,
address to,
uint256 amount,
bytes calldata userData, // asume only uint
bytes calldata operatorData
) external {
uint256 _selectedOrderID = bytesToUint(userData);
uint256 _escrowAmount = orders[_selectedOrderID].orderAmount.add(orders[_selectedOrderID].transportAmount);
/// @dev set order parameters
uint256 _deliveryStart = uint64(block.timestamp);
orders[_selectedOrderID].deliveryStart = _deliveryStart;
orders[_selectedOrderID].deliveryTime = _deliveryStart.add(orders[_selectedOrderID].transportTime);
// check conditions
require(msg.sender == address(blokkoToken), "Simple777Recipient: Invalid ERC777 token");
require(from == orders[_selectedOrderID].client, "Payment not made by client");
require(amount == _escrowAmount, "Escrow payment is not the same as the order amount");
require(orders[_selectedOrderID].status.escrowPaid == false, "Escrow is already deposited");
require(orders[_selectedOrderID].status.orderEnded == false, "Order is already ended");
emit receivedTokens("tokensReceived", operator, from, to, amount, userData, operatorData);
// register payment
orders[_selectedOrderID].status.escrowPaid = true;
orders[_selectedOrderID].status.status = "2-escrowPaid";
emit clientDeposited(orders[_selectedOrderID].status.status, _selectedOrderID, _deliveryStart, orders[_selectedOrderID].deliveryTime);
}
/// @notice Register delivery timestamp and settle payments
event transportReceived(string status, uint orderID, bool orderEnded, uint256 finalCostPaid);
function recieveTransport(bytes memory userData) public {
uint256 _selectedOrderID = bytesToUint(userData);
uint256 _deliveryEnd = uint64(block.timestamp);
uint256 _totalAmount = orders[_selectedOrderID].transportAmount.add(orders[_selectedOrderID].orderAmount);
require(msg.sender == orders[_selectedOrderID].client, "Only client can register transport receipt");
require(orders[_selectedOrderID].status.escrowPaid == true, "No escrow has been deposited");
require(orders[_selectedOrderID].status.orderEnded == false, "Transport already ended");
if (_deliveryEnd <= orders[_selectedOrderID].deliveryTime ) {
// Scenario green
blokkoToken.send(orders[_selectedOrderID].supplier, _totalAmount, userData);
orders[_selectedOrderID].status.finalCostPaid = _totalAmount;
orders[_selectedOrderID].status.status = "3-deliveredInTime";
} else {
// Scenario red
blokkoToken.send(orders[_selectedOrderID].supplier, orders[_selectedOrderID].orderAmount, userData);
blokkoToken.send(orders[_selectedOrderID].client, orders[_selectedOrderID].transportAmount, userData);
orders[_selectedOrderID].status.finalCostPaid = orders[_selectedOrderID].orderAmount;
orders[_selectedOrderID].status.status = "4-deliveredLate";
}
orders[_selectedOrderID].status.deliveryEnd = _deliveryEnd;
orders[_selectedOrderID].status.orderEnded = true;
emit transportReceived(orders[_selectedOrderID].status.status, _selectedOrderID, orders[_selectedOrderID].status.orderEnded, orders[_selectedOrderID].status.finalCostPaid);
}
/// @notice Register cancel order by client and settle payments
event orderCancelled(string status, uint orderID, bool _orderEnded);
function cancelOrder(bytes memory userData) public {
uint256 _selectedOrderID = bytesToUint(userData);
uint256 _deliveryEnd = uint64(block.timestamp);
uint256 _totalAmount = orders[_selectedOrderID].transportAmount.add(orders[_selectedOrderID].orderAmount);
require(msg.sender == orders[_selectedOrderID].client, "Only client can call this function.");
require(orders[_selectedOrderID].status.escrowPaid == true, "No escrow has been deposited.");
require(orders[_selectedOrderID].status.orderEnded == false, "Transport already ended.");
if (_deliveryEnd <= orders[_selectedOrderID].deliveryTime ) {
// Scenario green: cancelled within delivery time
blokkoToken.send(orders[_selectedOrderID].client, orders[_selectedOrderID].orderAmount, userData);
blokkoToken.send(orders[_selectedOrderID].supplier, orders[_selectedOrderID].transportAmount, userData);
orders[_selectedOrderID].status.status = "5-cancelledIntime";
} else {
// Scenario red: cancelled outside delivery time
blokkoToken.send(orders[_selectedOrderID].client, _totalAmount, userData);
orders[_selectedOrderID].status.status = "6-cancelledLate";
}
orders[_selectedOrderID].status.orderEnded = true;
emit orderCancelled(orders[_selectedOrderID].status.status, _selectedOrderID, orders[_selectedOrderID].status.orderEnded);
}
event depositedStatus(bool escrowPaid);
function depositStatus(uint256 _selectedOrderID) public /* onlyBy(client) */ {
bool _escrowPaid = orders[_selectedOrderID].status.escrowPaid;
emit depositedStatus(_escrowPaid);
}
} | 3,620 |
534 | // --- Contract setters --- |
function setAddresses(
address _borrowerOperationsAddress,
address _troveManagerAddress,
address _activePoolAddress,
address _lusdTokenAddress,
address _sortedTrovesAddress,
address _priceFeedAddress,
address _communityIssuanceAddress
)
|
function setAddresses(
address _borrowerOperationsAddress,
address _troveManagerAddress,
address _activePoolAddress,
address _lusdTokenAddress,
address _sortedTrovesAddress,
address _priceFeedAddress,
address _communityIssuanceAddress
)
| 8,885 |
4 | // -Infinity. / | bytes16 private constant NEGATIVE_INFINITY = 0xFFFF0000000000000000000000000000;
| bytes16 private constant NEGATIVE_INFINITY = 0xFFFF0000000000000000000000000000;
| 11,503 |
1 | // positive case | function pulsone() public payable{
uint256 j = 0;
uint i = 100;
for (; i < i; i++) {
j++;
}
}
| function pulsone() public payable{
uint256 j = 0;
uint i = 100;
for (; i < i; i++) {
j++;
}
}
| 45,262 |
9 | // Calculate the amount of underlying token available to withdrawwhen withdrawing via only single token tokenAmount the amount of LP token to burn tokenIndex index of which token will be withdrawnreturn availableTokenAmount calculated amount of underlying tokenavailable to withdraw / | function calculateRemoveLiquidityOneToken(
uint256 tokenAmount,
uint8 tokenIndex
| function calculateRemoveLiquidityOneToken(
uint256 tokenAmount,
uint8 tokenIndex
| 25,971 |
19 | // creating the bin corresponding to this contributor | uint256 amt = crowdFund.contributionAtIdx(contributorIdx);
acc += amt;
| uint256 amt = crowdFund.contributionAtIdx(contributorIdx);
acc += amt;
| 8,905 |
200 | // helper for sell pool in Bancor network converter type v2/ | function sellPoolViaBancorV2(
IERC20 _poolToken,
uint256 _amount,
bytes calldata _additionalData
)
private
returns(address[] memory connectorsAddress)
| function sellPoolViaBancorV2(
IERC20 _poolToken,
uint256 _amount,
bytes calldata _additionalData
)
private
returns(address[] memory connectorsAddress)
| 33,195 |
10 | // This multiplication can't overflow, _secondsPassed will easily fit within 64-bits, and totalPriceChange will easily fit within 128-bits, their product will always fit within 256-bits. | int256 currentPriceChange = (totalPriceChange *
int256(secondsPassed)) / int256(duration);
| int256 currentPriceChange = (totalPriceChange *
int256(secondsPassed)) / int256(duration);
| 15,190 |
8 | // retrieve the size of the code, this needs assembly | let size := extcodesize(_addr)
| let size := extcodesize(_addr)
| 45,263 |
4 | // Struct & Mapping to store proposal details | uint256 constant PROJECT_OWNER_TRANSFER_DURATION = 3 days; // Sets the time from motion creation to possible amount transfer from the project owner's repository
mapping(uint256 => Proposal) public proposals;
| uint256 constant PROJECT_OWNER_TRANSFER_DURATION = 3 days; // Sets the time from motion creation to possible amount transfer from the project owner's repository
mapping(uint256 => Proposal) public proposals;
| 15,722 |
20 | // mouth | rarities[5] = [
80,
225,
227,
228,
112,
240,
64,
160,
167,
| rarities[5] = [
80,
225,
227,
228,
112,
240,
64,
160,
167,
| 10,745 |
136 | // Distributes ether to token holders as dividends./It reverts if the total supply of tokens is 0./ It emits the `DividendsDistributed` event if the amount of received ether is greater than 0./ About undistributed ether:/ In each distribution, there is a small amount of ether not distributed,/ the magnified amount of which is/ `(msg.valuemagnitude) % totalSupply()`./ With a well-chosen `magnitude`, the amount of undistributed ether/ (de-magnified) in a distribution can be less than 1 wei./ We can actually keep track of the undistributed ether in a distribution/ and try to distribute it in the next distribution,/ but keeping track of such | function distributeDividends() public override payable {
require(totalSupply() > 0);
if (msg.value > 0) {
magnifiedDividendPerShare = magnifiedDividendPerShare.add(
(msg.value).mul(magnitude) / totalSupply()
);
emit DividendsDistributed(msg.sender, msg.value);
totalDividendsDistributed = totalDividendsDistributed.add(msg.value);
}
}
| function distributeDividends() public override payable {
require(totalSupply() > 0);
if (msg.value > 0) {
magnifiedDividendPerShare = magnifiedDividendPerShare.add(
(msg.value).mul(magnitude) / totalSupply()
);
emit DividendsDistributed(msg.sender, msg.value);
totalDividendsDistributed = totalDividendsDistributed.add(msg.value);
}
}
| 32,184 |
59 | // Event triggered when a new reward tier is added_index of the tier added_rate of added tier_price of added tier_enabled status of added tier/ | event TierAdded(uint256 _index, uint256 _rate, uint256 _price, bool _enabled);
| event TierAdded(uint256 _index, uint256 _rate, uint256 _price, bool _enabled);
| 48,985 |
10 | // Eyebrow N°11 => Yokai Blood | function item_11() public pure returns (string memory) {
return base(yokai("B50D5E"), "Yokai Blood");
}
| function item_11() public pure returns (string memory) {
return base(yokai("B50D5E"), "Yokai Blood");
}
| 22,502 |
250 | // generate a random index | uint256 index = _random(supplyLeft);
uint256 tokenAtPlace = indices[index];
uint256 tokenId;
| uint256 index = _random(supplyLeft);
uint256 tokenAtPlace = indices[index];
uint256 tokenId;
| 8,607 |
27 | // we need to be net short the asset. | uint expectedShort = uint(-expectedHedge);
| uint expectedShort = uint(-expectedHedge);
| 35,734 |
0 | // Define a variable to store the access key smart contract | TokenERC1155 public accessKeysCollection;
constructor(
string memory _name,
string memory _symbol,
address _royaltyRecipient,
uint128 _royaltyBps,
| TokenERC1155 public accessKeysCollection;
constructor(
string memory _name,
string memory _symbol,
address _royaltyRecipient,
uint128 _royaltyBps,
| 12,074 |
47 | // This event MUST be emitted by `onRoyaltiesReceived()`. | event RoyaltiesReceived(
address indexed _royaltyRecipient,
address indexed _buyer,
uint256 indexed _tokenId,
address _tokenPaid,
uint256 _amount,
bytes32 _metadata
);
| event RoyaltiesReceived(
address indexed _royaltyRecipient,
address indexed _buyer,
uint256 indexed _tokenId,
address _tokenPaid,
uint256 _amount,
bytes32 _metadata
);
| 59,146 |
124 | // true up earned amount to vBZRX vesting schedule | lastSync = vestingLastSync[account];
multiplier = vestedBalanceForAmount(
1e36,
0,
lastSync
);
value = value
.mul(multiplier);
value /= 1e36;
bzrxRewardsEarned = bzrxRewardsEarned
| lastSync = vestingLastSync[account];
multiplier = vestedBalanceForAmount(
1e36,
0,
lastSync
);
value = value
.mul(multiplier);
value /= 1e36;
bzrxRewardsEarned = bzrxRewardsEarned
| 43,227 |
19 | // return Half ray, 1e27/2 / | function halfRay() internal pure returns (uint256) {
return halfRAY;
}
| function halfRay() internal pure returns (uint256) {
return halfRAY;
}
| 8,554 |
6 | // Initializes the contract by setting a `name` and a `symbol` to the token collection, and by setting supply caps, mint indexes, and reserves / | constructor()
ERC721("Edgerunners", "EDGE")
| constructor()
ERC721("Edgerunners", "EDGE")
| 25,611 |
13 | // abort deposit/withdraw requests/_uuid UUID used as an external identifier/ return Whether the transaction was successful or not (0: Successful) | function abortTransfer (
bytes16 _uuid
| function abortTransfer (
bytes16 _uuid
| 2,612 |
57 | // Requires that the token exists. | modifier tokenExists(uint256 tokenId) {
require(ERC721._exists(tokenId), "ERC721Common: Token doesn't exist");
_;
}
| modifier tokenExists(uint256 tokenId) {
require(ERC721._exists(tokenId), "ERC721Common: Token doesn't exist");
_;
}
| 49,522 |
8 | // Sets the configIds for an array of `assets` and `debts`assets erc-20 address array to set e-mode config debts erc-20 address array corresponding asset in mapping configIds from aaveV3 (refer to this contract title block) / | function setEModeConfig(
address[] calldata assets,
address[] calldata debts,
uint8[] calldata configIds
)
external
onlyTimelock
| function setEModeConfig(
address[] calldata assets,
address[] calldata debts,
uint8[] calldata configIds
)
external
onlyTimelock
| 20,011 |
118 | // Calculates the total underlying tokens It includes tokens held by the contract and held in MasterChef / | function balanceOf() public view returns (uint256) {
(uint256 amount, ) = IMasterChef(masterchef).userInfo(address(this));
return token.balanceOf(address(this)).add(amount);
}
| function balanceOf() public view returns (uint256) {
(uint256 amount, ) = IMasterChef(masterchef).userInfo(address(this));
return token.balanceOf(address(this)).add(amount);
}
| 33,792 |
136 | // View function to see pending Token/_nftId NFT for which pending tokens are to be viewed/ return pending reward for a given user. | function pendingToken(uint256 _nftId) external view returns (uint256) {
NFTInfo storage nft = nftInfo[_nftId];
if (!nft.isStaked) {
return 0;
}
(address baseToken, , uint256 amount) = lpToken.tokenMetadata(_nftId);
amount /= liquidityProviders.BASE_DIVISOR();
PoolInfo memory pool = poolInfo[baseToken];
uint256 accToken1PerShare = pool.accTokenPerShare;
if (block.timestamp > pool.lastRewardTime && totalSharesStaked[baseToken] != 0) {
accToken1PerShare = getUpdatedAccTokenPerShare(baseToken);
}
return ((amount * accToken1PerShare) / ACC_TOKEN_PRECISION) - nft.rewardDebt + nft.unpaidRewards;
}
| function pendingToken(uint256 _nftId) external view returns (uint256) {
NFTInfo storage nft = nftInfo[_nftId];
if (!nft.isStaked) {
return 0;
}
(address baseToken, , uint256 amount) = lpToken.tokenMetadata(_nftId);
amount /= liquidityProviders.BASE_DIVISOR();
PoolInfo memory pool = poolInfo[baseToken];
uint256 accToken1PerShare = pool.accTokenPerShare;
if (block.timestamp > pool.lastRewardTime && totalSharesStaked[baseToken] != 0) {
accToken1PerShare = getUpdatedAccTokenPerShare(baseToken);
}
return ((amount * accToken1PerShare) / ACC_TOKEN_PRECISION) - nft.rewardDebt + nft.unpaidRewards;
}
| 24,674 |
4 | // Fallback: reverts if Ether is sent to this smart contract by mistake | function() external {
revert();
}
| function() external {
revert();
}
| 31,432 |
405 | // Get information about a service provider given their address _serviceProvider - address of service provider / | function getServiceProviderDetails(address _serviceProvider)
external view returns (
uint256 deployerStake,
uint256 deployerCut,
bool validBounds,
uint256 numberOfEndpoints,
uint256 minAccountStake,
uint256 maxAccountStake)
| function getServiceProviderDetails(address _serviceProvider)
external view returns (
uint256 deployerStake,
uint256 deployerCut,
bool validBounds,
uint256 numberOfEndpoints,
uint256 minAccountStake,
uint256 maxAccountStake)
| 45,335 |
4 | // filter too small asset, saving gas | uint256 public minMintToken0;
uint256 public minMintToken1;
mapping(address => UserInfo) userInfo0;
mapping(address => UserInfo) userInfo1;
event Stake(bool _index0, address _user, uint256 _amount);
| uint256 public minMintToken0;
uint256 public minMintToken1;
mapping(address => UserInfo) userInfo0;
mapping(address => UserInfo) userInfo1;
event Stake(bool _index0, address _user, uint256 _amount);
| 36,797 |
113 | // KNEEL PEON! KNEEL BEFORE YOUR MASTER! / | function worship() public payable onlyAwake {
assembly {
if gt(sload(timestampUntilNextEpoch.slot), add(timestamp(), 1)) {
mstore(0x00, ERROR_SIG)
mstore(0x04, 0x20)
mstore(0x24, 8)
mstore(0x44, 'Too Soon')
revert(0x00, 0x64)
}
}
uint256 score = currentEpochTotalSacrificed + placationCount;
if (lastEpochTotalSacrificed >= score) {
assembly {
// emit Obliterate(_totalSupply)
mstore(0x00, sload(_totalSupply.slot))
log1(0x00, 0x20, OBLITERATE_SIG)
selfdestruct(0x00) // womp womp
}
}
assembly {
sstore(lastEpochTotalSacrificed.slot, sload(currentEpochTotalSacrificed.slot))
sstore(currentEpochTotalSacrificed.slot, 0)
sstore(timestampUntilNextEpoch.slot, add(timestamp(), SECONDS_PER_WEEK))
sstore(doomCounter.slot, add(sload(doomCounter.slot), 1))
sstore(placationCount.slot, 0)
}
if (doomCounter == (WEEKS_UNTIL_OBLIVION + 1)) {
obliterate();
}
// emit Countdown(doomCounter)
assembly {
mstore(0x00, sload(doomCounter.slot))
log1(0x00, 0x20, COUNTDOWN_SIG)
}
}
| function worship() public payable onlyAwake {
assembly {
if gt(sload(timestampUntilNextEpoch.slot), add(timestamp(), 1)) {
mstore(0x00, ERROR_SIG)
mstore(0x04, 0x20)
mstore(0x24, 8)
mstore(0x44, 'Too Soon')
revert(0x00, 0x64)
}
}
uint256 score = currentEpochTotalSacrificed + placationCount;
if (lastEpochTotalSacrificed >= score) {
assembly {
// emit Obliterate(_totalSupply)
mstore(0x00, sload(_totalSupply.slot))
log1(0x00, 0x20, OBLITERATE_SIG)
selfdestruct(0x00) // womp womp
}
}
assembly {
sstore(lastEpochTotalSacrificed.slot, sload(currentEpochTotalSacrificed.slot))
sstore(currentEpochTotalSacrificed.slot, 0)
sstore(timestampUntilNextEpoch.slot, add(timestamp(), SECONDS_PER_WEEK))
sstore(doomCounter.slot, add(sload(doomCounter.slot), 1))
sstore(placationCount.slot, 0)
}
if (doomCounter == (WEEKS_UNTIL_OBLIVION + 1)) {
obliterate();
}
// emit Countdown(doomCounter)
assembly {
mstore(0x00, sload(doomCounter.slot))
log1(0x00, 0x20, COUNTDOWN_SIG)
}
}
| 80,878 |
53 | // Official prices and timestamps by symbol hash | mapping(bytes32 => Price) public prices;
| mapping(bytes32 => Price) public prices;
| 21,943 |
43 | // Auto-LP varibales | bool private swapping;
bool public swapEnabled = true;
uint256 public addLiquityThresholdETH = 10**17; // 1 ETH = 10**18 | 0.1 ETH = 10**17
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 1_000_000_000_000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
address private feeaddress;
| bool private swapping;
bool public swapEnabled = true;
uint256 public addLiquityThresholdETH = 10**17; // 1 ETH = 10**18 | 0.1 ETH = 10**17
uint256 private constant MAX = ~uint256(0);
uint256 private _tTotal = 1_000_000_000_000 * 10**9;
uint256 private _rTotal = (MAX - (MAX % _tTotal));
uint256 private _tFeeTotal;
address private feeaddress;
| 57,978 |
78 | // create local variable for unlock total | uint tokensToUnlock;
| uint tokensToUnlock;
| 14,363 |
34 | // version cache buster | string public constant version = "v2";
| string public constant version = "v2";
| 53,652 |
2 | // Public Functions//Accesses the batch storage container.return Reference to the batch storage container. / | function batches()
public
view
returns (
iOVM_ChainStorageContainer
)
| function batches()
public
view
returns (
iOVM_ChainStorageContainer
)
| 15,223 |
62 | // split the contract balance into halves add the marketing wallet | uint256 half = contractTokenBalance.div(2);
uint256 otherHalf = contractTokenBalance.sub(half);
| uint256 half = contractTokenBalance.div(2);
uint256 otherHalf = contractTokenBalance.sub(half);
| 68 |
0 | // Address of securityToken this ConstraintModule is used by / | ISecurityToken private _securityToken;
| ISecurityToken private _securityToken;
| 21,143 |
38 | // Sell `amount` tokens to contract/ amount amount of tokens to be sold | function sell(uint256 amount) public {
//require(this.balance >= amount * sellPrice); // checks if the contract has enough ether to buy
require(balanceOf[msg.sender] >= amount * sellPrice); // checks if the contract has enough ether to buy
_transfer(msg.sender, this, amount); // makes the transfers
msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks
}
| function sell(uint256 amount) public {
//require(this.balance >= amount * sellPrice); // checks if the contract has enough ether to buy
require(balanceOf[msg.sender] >= amount * sellPrice); // checks if the contract has enough ether to buy
_transfer(msg.sender, this, amount); // makes the transfers
msg.sender.transfer(amount * sellPrice); // sends ether to the seller. It's important to do this last to avoid recursion attacks
}
| 20,936 |
186 | // Token URI | function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
| function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
| 1,447 |
24 | // Hook for future use | _beforeUpdate();
| _beforeUpdate();
| 19,911 |
9 | // set claimed to 1 to avoid initial claim requirement for vestees calling `claim` | userData[_receivers[i]] = UserWeight({tranche: 1, weight: _weights[i], claimed: 1});
| userData[_receivers[i]] = UserWeight({tranche: 1, weight: _weights[i], claimed: 1});
| 36,712 |
31 | // tokens[0] = tokenAddress; tokens[1] = wethAddress; | token = _token;
factory = _factory;
weth = _weth;
ANCHOR = duration(0,block.timestamp).mul(ONE_DAY);
DOMAIN_SEPARATOR = keccak256(abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
keccak256("MiningPool"),
keccak256(bytes(version)),
chainId_,
| token = _token;
factory = _factory;
weth = _weth;
ANCHOR = duration(0,block.timestamp).mul(ONE_DAY);
DOMAIN_SEPARATOR = keccak256(abi.encode(
keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
keccak256("MiningPool"),
keccak256(bytes(version)),
chainId_,
| 42,659 |
12 | // Utils/Helper Function to get Available Token by Token Id / | function getAvailableTokensByTokenId(uint256 id)
public
view
returns (int)
| function getAvailableTokensByTokenId(uint256 id)
public
view
returns (int)
| 80,553 |
28 | // Enum NOTE: You can add a new type at the end, but DO NOT CHANGE this order | enum DefiActions { YearnDeposit, YearnWithdraw }
constructor(address _tokensTypes) public {
tokensTypes = ITokensTypeStorage(_tokensTypes);
}
| enum DefiActions { YearnDeposit, YearnWithdraw }
constructor(address _tokensTypes) public {
tokensTypes = ITokensTypeStorage(_tokensTypes);
}
| 26,150 |
4 | // handle returndata | return handleReturnData();
| return handleReturnData();
| 38,291 |
0 | // Emitted when a token renounces its permission list/renouncedPermissionListAddress - The address of the renounced permission list | event PermissionListRenounced(address renouncedPermissionListAddress);
| event PermissionListRenounced(address renouncedPermissionListAddress);
| 27,566 |
17 | // all tokens are assumed to be in - since we want to import all of them | info.cUser = USER_INFO.getPerUserInfo(user, info.tokenInfo.ctoken, info.tokenInfo.ctoken, info.tokenInfo.underlying);
info.importInfo = USER_INFO.getImportInfo(user, info.tokenInfo.ctoken, registry, sugarDaddy);
info.scoreInfo = USER_INFO.getScoreInfo(user, jarConnector);
info.compTokenInfo = USER_INFO.getCompTokenInfo(user, comptroller, registry);
info.jarInfo = USER_INFO.getJarInfo(jar, info.tokenInfo.ctoken);
if(getTvl) info.tvlInfo = USER_INFO.getTvlInfo(info.tokenInfo.ctoken, registry);
| info.cUser = USER_INFO.getPerUserInfo(user, info.tokenInfo.ctoken, info.tokenInfo.ctoken, info.tokenInfo.underlying);
info.importInfo = USER_INFO.getImportInfo(user, info.tokenInfo.ctoken, registry, sugarDaddy);
info.scoreInfo = USER_INFO.getScoreInfo(user, jarConnector);
info.compTokenInfo = USER_INFO.getCompTokenInfo(user, comptroller, registry);
info.jarInfo = USER_INFO.getJarInfo(jar, info.tokenInfo.ctoken);
if(getTvl) info.tvlInfo = USER_INFO.getTvlInfo(info.tokenInfo.ctoken, registry);
| 60,700 |
99 | // calculate the number of tokens to take as a fee | uint256 liquidityFee =
calculateTokenFee(amount, _feeDecimals, _feePercentage);
| uint256 liquidityFee =
calculateTokenFee(amount, _feeDecimals, _feePercentage);
| 12,057 |
16 | // If the contract is initializing we ignore whether _initialized is set in order to support multiple inheritance patterns, but we only do this in the context of a constructor, and for the lowest level of initializers, because in other contexts the contract may have been reentered. | if (_initializing) {
require(
version == 1 && !AddressUpgradeable.isContract(address(this)),
"Initializable: contract is already initialized"
);
return false;
} else {
| if (_initializing) {
require(
version == 1 && !AddressUpgradeable.isContract(address(this)),
"Initializable: contract is already initialized"
);
return false;
} else {
| 22,450 |
46 | // elsethen check allowed token for board member | return currentTime() > time;
| return currentTime() > time;
| 49,892 |