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
23
// Load the E column into Q
for (uint j=0; j<a.length; j++) { q[j][i] = e_column[j]; }
for (uint j=0; j<a.length; j++) { q[j][i] = e_column[j]; }
31,038
2
// lets the owner change the current alchemize ImplementationalchemizeImplementation_ the address of the new implementation/
function newAlchemizeImplementation(address alchemizeImplementation_) external { require(msg.sender == factoryOwner, "Only factory owner"); require(alchemizeImplementation_ != address(0), "No zero address for alchemizeImplementation_"); alchemizeImplementation = alchemizeImplementation_; emit NewAlchemizeImplementation(alchemizeImplementation); }
function newAlchemizeImplementation(address alchemizeImplementation_) external { require(msg.sender == factoryOwner, "Only factory owner"); require(alchemizeImplementation_ != address(0), "No zero address for alchemizeImplementation_"); alchemizeImplementation = alchemizeImplementation_; emit NewAlchemizeImplementation(alchemizeImplementation); }
73,367
48
// Deposit INCH from user into vault
inchWormContract.transferFrom(msg.sender, address(this), _inchToSell);
inchWormContract.transferFrom(msg.sender, address(this), _inchToSell);
33,334
37
// Approves another address to transfer the given token ID The zero address indicates there is no approved address. There can only be one approved address per token at a given time. Can only be called by the token owner or an approved operator.to address to be approved for the given token IDtokenId uint256 ID of the token to be approved/
function approve(address to, uint256 tokenId) public { address owner = ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); }
function approve(address to, uint256 tokenId) public { address owner = ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); }
5,305
21
// Revokes token . Requirements:- the caller must have roleMINT_ROLE
* Emits {RevokeNTT} event. */ function revoke(uint256 tokenId, string memory uri) public override isExistNTT(tokenId) onlyRole(MINT_ROLE) { _nttMetadata[tokenId].isActive = false; _nttMetadata[tokenId].ipfsUri = uri; emit RevokeNTT(msg.sender, tokenId, _nttMetadata[tokenId]); }
* Emits {RevokeNTT} event. */ function revoke(uint256 tokenId, string memory uri) public override isExistNTT(tokenId) onlyRole(MINT_ROLE) { _nttMetadata[tokenId].isActive = false; _nttMetadata[tokenId].ipfsUri = uri; emit RevokeNTT(msg.sender, tokenId, _nttMetadata[tokenId]); }
869
11
// Description: Open buying on exchanges /
function openBuys() public isOwner { _buyIsOpen = true; }
function openBuys() public isOwner { _buyIsOpen = true; }
50,587
175
// solium-disable /
library strings { struct slice { uint _len; uint _ptr; } function memcpy(uint dest, uint src, uint len) private pure { // Copy word-length chunks while possible for(; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } // Copy remaining bytes uint mask = 256 ** (32 - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } /* * @dev Returns a slice containing the entire string. * @param self The string to make a slice from. * @return A newly allocated slice containing the entire string. */ function toSlice(string memory self) internal pure returns (slice memory) { uint ptr; assembly { ptr := add(self, 0x20) } return slice(bytes(self).length, ptr); } /* * @dev Returns the length of a null-terminated bytes32 string. * @param self The value to find the length of. * @return The length of the string, from 0 to 32. */ function len(bytes32 self) internal pure returns (uint) { uint ret; if (self == 0) return 0; if (uint256(self) & 0xffffffffffffffffffffffffffffffff == 0) { ret += 16; self = bytes32(uint(self) / 0x100000000000000000000000000000000); } if (uint256(self) & 0xffffffffffffffff == 0) { ret += 8; self = bytes32(uint(self) / 0x10000000000000000); } if (uint256(self) & 0xffffffff == 0) { ret += 4; self = bytes32(uint(self) / 0x100000000); } if (uint256(self) & 0xffff == 0) { ret += 2; self = bytes32(uint(self) / 0x10000); } if (uint256(self) & 0xff == 0) { ret += 1; } return 32 - ret; } /* * @dev Returns a slice containing the entire bytes32, interpreted as a * null-terminated utf-8 string. * @param self The bytes32 value to convert to a slice. * @return A new slice containing the value of the input argument up to the * first null. */ function toSliceB32(bytes32 self) internal pure returns (slice memory ret) { // Allocate space for `self` in memory, copy it there, and point ret at it assembly { let ptr := mload(0x40) mstore(0x40, add(ptr, 0x20)) mstore(ptr, self) mstore(add(ret, 0x20), ptr) } ret._len = len(self); } /* * @dev Returns a new slice containing the same data as the current slice. * @param self The slice to copy. * @return A new slice containing the same data as `self`. */ function copy(slice memory self) internal pure returns (slice memory) { return slice(self._len, self._ptr); } /* * @dev Copies a slice to a new string. * @param self The slice to copy. * @return A newly allocated string containing the slice's text. */ function toString(slice memory self) internal pure returns (string memory) { string memory ret = new string(self._len); uint retptr; assembly { retptr := add(ret, 32) } memcpy(retptr, self._ptr, self._len); return ret; } /* * @dev Returns the length in runes of the slice. Note that this operation * takes time proportional to the length of the slice; avoid using it * in loops, and call `slice.empty()` if you only need to kblock.timestamp whether * the slice is empty or not. * @param self The slice to operate on. * @return The length of the slice in runes. */ function len(slice memory self) internal pure returns (uint l) { // Starting at ptr-31 means the LSB will be the byte we care about uint ptr = self._ptr - 31; uint end = ptr + self._len; for (l = 0; ptr < end; l++) { uint8 b; assembly { b := and(mload(ptr), 0xFF) } if (b < 0x80) { ptr += 1; } else if(b < 0xE0) { ptr += 2; } else if(b < 0xF0) { ptr += 3; } else if(b < 0xF8) { ptr += 4; } else if(b < 0xFC) { ptr += 5; } else { ptr += 6; } } } /* * @dev Returns true if the slice is empty (has a length of 0). * @param self The slice to operate on. * @return True if the slice is empty, False otherwise. */ function empty(slice memory self) internal pure returns (bool) { return self._len == 0; } /* * @dev Returns a positive number if `other` comes lexicographically after * `self`, a negative number if it comes before, or zero if the * contents of the two slices are equal. Comparison is done per-rune, * on unicode codepoints. * @param self The first slice to compare. * @param other The second slice to compare. * @return The result of the comparison. */ function compare(slice memory self, slice memory other) internal pure returns (int) { uint shortest = self._len; if (other._len < self._len) shortest = other._len; uint selfptr = self._ptr; uint otherptr = other._ptr; for (uint idx = 0; idx < shortest; idx += 32) { uint a; uint b; assembly { a := mload(selfptr) b := mload(otherptr) } if (a != b) { // Mask out irrelevant bytes and check again uint256 mask = uint256(-1); // 0xffff... if(shortest < 32) { mask = ~(2 ** (8 * (32 - shortest + idx)) - 1); } uint256 diff = (a & mask) - (b & mask); if (diff != 0) return int(diff); } selfptr += 32; otherptr += 32; } return int(self._len) - int(other._len); } /* * @dev Returns true if the two slices contain the same text. * @param self The first slice to compare. * @param self The second slice to compare. * @return True if the slices are equal, false otherwise. */ function equals(slice memory self, slice memory other) internal pure returns (bool) { return compare(self, other) == 0; } /* * @dev Extracts the first rune in the slice into `rune`, advancing the * slice to point to the next rune and returning `self`. * @param self The slice to operate on. * @param rune The slice that will contain the first rune. * @return `rune`. */ function nextRune(slice memory self, slice memory rune) internal pure returns (slice memory) { rune._ptr = self._ptr; if (self._len == 0) { rune._len = 0; return rune; } uint l; uint b; // Load the first byte of the rune into the LSBs of b assembly { b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF) } if (b < 0x80) { l = 1; } else if(b < 0xE0) { l = 2; } else if(b < 0xF0) { l = 3; } else { l = 4; } // Check for truncated codepoints if (l > self._len) { rune._len = self._len; self._ptr += self._len; self._len = 0; return rune; } self._ptr += l; self._len -= l; rune._len = l; return rune; } /* * @dev Returns the first rune in the slice, advancing the slice to point * to the next rune. * @param self The slice to operate on. * @return A slice containing only the first rune from `self`. */ function nextRune(slice memory self) internal pure returns (slice memory ret) { nextRune(self, ret); } /* * @dev Returns the number of the first codepoint in the slice. * @param self The slice to operate on. * @return The number of the first codepoint in the slice. */ function ord(slice memory self) internal pure returns (uint ret) { if (self._len == 0) { return 0; } uint word; uint length; uint divisor = 2 ** 248; // Load the rune into the MSBs of b assembly { word:= mload(mload(add(self, 32))) } uint b = word / divisor; if (b < 0x80) { ret = b; length = 1; } else if(b < 0xE0) { ret = b & 0x1F; length = 2; } else if(b < 0xF0) { ret = b & 0x0F; length = 3; } else { ret = b & 0x07; length = 4; } // Check for truncated codepoints if (length > self._len) { return 0; } for (uint i = 1; i < length; i++) { divisor = divisor / 256; b = (word / divisor) & 0xFF; if (b & 0xC0 != 0x80) { // Invalid UTF-8 sequence return 0; } ret = (ret * 64) | (b & 0x3F); } return ret; } /* * @dev Returns the keccak-256 hash of the slice. * @param self The slice to hash. * @return The hash of the slice. */ function keccak(slice memory self) internal pure returns (bytes32 ret) { assembly { ret := keccak256(mload(add(self, 32)), mload(self)) } } /* * @dev Returns true if `self` starts with `needle`. * @param self The slice to operate on. * @param needle The slice to search for. * @return True if the slice starts with the provided text, false otherwise. */ function startsWith(slice memory self, slice memory needle) internal pure returns (bool) { if (self._len < needle._len) { return false; } if (self._ptr == needle._ptr) { return true; } bool equal; assembly { let length := mload(needle) let selfptr := mload(add(self, 0x20)) let needleptr := mload(add(needle, 0x20)) equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) } return equal; } /* * @dev If `self` starts with `needle`, `needle` is removed from the * beginning of `self`. Otherwise, `self` is unmodified. * @param self The slice to operate on. * @param needle The slice to search for. * @return `self` */ function beyond(slice memory self, slice memory needle) internal pure returns (slice memory) { if (self._len < needle._len) { return self; } bool equal = true; if (self._ptr != needle._ptr) { assembly { let length := mload(needle) let selfptr := mload(add(self, 0x20)) let needleptr := mload(add(needle, 0x20)) equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) } } if (equal) { self._len -= needle._len; self._ptr += needle._len; } return self; } /* * @dev Returns true if the slice ends with `needle`. * @param self The slice to operate on. * @param needle The slice to search for. * @return True if the slice starts with the provided text, false otherwise. */ function endsWith(slice memory self, slice memory needle) internal pure returns (bool) { if (self._len < needle._len) { return false; } uint selfptr = self._ptr + self._len - needle._len; if (selfptr == needle._ptr) { return true; } bool equal; assembly { let length := mload(needle) let needleptr := mload(add(needle, 0x20)) equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) } return equal; } /* * @dev If `self` ends with `needle`, `needle` is removed from the * end of `self`. Otherwise, `self` is unmodified. * @param self The slice to operate on. * @param needle The slice to search for. * @return `self` */ function until(slice memory self, slice memory needle) internal pure returns (slice memory) { if (self._len < needle._len) { return self; } uint selfptr = self._ptr + self._len - needle._len; bool equal = true; if (selfptr != needle._ptr) { assembly { let length := mload(needle) let needleptr := mload(add(needle, 0x20)) equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) } } if (equal) { self._len -= needle._len; } return self; } // Returns the memory address of the first byte of the first occurrence of // `needle` in `self`, or the first byte after `self` if not found. function findPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) { uint ptr = selfptr; uint idx; if (needlelen <= selflen) { if (needlelen <= 32) { bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1)); bytes32 needledata; assembly { needledata := and(mload(needleptr), mask) } uint end = selfptr + selflen - needlelen; bytes32 ptrdata; assembly { ptrdata := and(mload(ptr), mask) } while (ptrdata != needledata) { if (ptr >= end) return selfptr + selflen; ptr++; assembly { ptrdata := and(mload(ptr), mask) } } return ptr; } else { // For long needles, use hashing bytes32 hash; assembly { hash := keccak256(needleptr, needlelen) } for (idx = 0; idx <= selflen - needlelen; idx++) { bytes32 testHash; assembly { testHash := keccak256(ptr, needlelen) } if (hash == testHash) return ptr; ptr += 1; } } } return selfptr + selflen; } // Returns the memory address of the first byte after the last occurrence of // `needle` in `self`, or the address of `self` if not found. function rfindPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) { uint ptr; if (needlelen <= selflen) { if (needlelen <= 32) { bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1)); bytes32 needledata; assembly { needledata := and(mload(needleptr), mask) } ptr = selfptr + selflen - needlelen; bytes32 ptrdata; assembly { ptrdata := and(mload(ptr), mask) } while (ptrdata != needledata) { if (ptr <= selfptr) return selfptr; ptr--; assembly { ptrdata := and(mload(ptr), mask) } } return ptr + needlelen; } else { // For long needles, use hashing bytes32 hash; assembly { hash := keccak256(needleptr, needlelen) } ptr = selfptr + (selflen - needlelen); while (ptr >= selfptr) { bytes32 testHash; assembly { testHash := keccak256(ptr, needlelen) } if (hash == testHash) return ptr + needlelen; ptr -= 1; } } } return selfptr; } /* * @dev Modifies `self` to contain everything from the first occurrence of * `needle` to the end of the slice. `self` is set to the empty slice * if `needle` is not found. * @param self The slice to search and modify. * @param needle The text to search for. * @return `self`. */ function find(slice memory self, slice memory needle) internal pure returns (slice memory) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); self._len -= ptr - self._ptr; self._ptr = ptr; return self; } /* * @dev Modifies `self` to contain the part of the string from the start of * `self` to the end of the first occurrence of `needle`. If `needle` * is not found, `self` is set to the empty slice. * @param self The slice to search and modify. * @param needle The text to search for. * @return `self`. */ function rfind(slice memory self, slice memory needle) internal pure returns (slice memory) { uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); self._len = ptr - self._ptr; return self; } /* * @dev Splits the slice, setting `self` to everything after the first * occurrence of `needle`, and `token` to everything before it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and `token` is set to the entirety of `self`. * @param self The slice to split. * @param needle The text to search for in `self`. * @param token An output parameter to which the first token is written. * @return `token`. */ function split(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); token._ptr = self._ptr; token._len = ptr - self._ptr; if (ptr == self._ptr + self._len) { // Not found self._len = 0; } else { self._len -= token._len + needle._len; self._ptr = ptr + needle._len; } return token; } /* * @dev Splits the slice, setting `self` to everything after the first * occurrence of `needle`, and returning everything before it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and the entirety of `self` is returned. * @param self The slice to split. * @param needle The text to search for in `self`. * @return The part of `self` up to the first occurrence of `delim`. */ function split(slice memory self, slice memory needle) internal pure returns (slice memory token) { split(self, needle, token); } /* * @dev Splits the slice, setting `self` to everything before the last * occurrence of `needle`, and `token` to everything after it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and `token` is set to the entirety of `self`. * @param self The slice to split. * @param needle The text to search for in `self`. * @param token An output parameter to which the first token is written. * @return `token`. */ function rsplit(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) { uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); token._ptr = ptr; token._len = self._len - (ptr - self._ptr); if (ptr == self._ptr) { // Not found self._len = 0; } else { self._len -= token._len + needle._len; } return token; } /* * @dev Splits the slice, setting `self` to everything before the last * occurrence of `needle`, and returning everything after it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and the entirety of `self` is returned. * @param self The slice to split. * @param needle The text to search for in `self`. * @return The part of `self` after the last occurrence of `delim`. */ function rsplit(slice memory self, slice memory needle) internal pure returns (slice memory token) { rsplit(self, needle, token); } /* * @dev Counts the number of nonoverlapping occurrences of `needle` in `self`. * @param self The slice to search. * @param needle The text to search for in `self`. * @return The number of occurrences of `needle` found in `self`. */ function count(slice memory self, slice memory needle) internal pure returns (uint cnt) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len; while (ptr <= self._ptr + self._len) { cnt++; ptr = findPtr(self._len - (ptr - self._ptr), ptr, needle._len, needle._ptr) + needle._len; } } /* * @dev Returns True if `self` contains `needle`. * @param self The slice to search. * @param needle The text to search for in `self`. * @return True if `needle` is found in `self`, false otherwise. */ function contains(slice memory self, slice memory needle) internal pure returns (bool) { return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr; } /* * @dev Returns a newly allocated string containing the concatenation of * `self` and `other`. * @param self The first slice to concatenate. * @param other The second slice to concatenate. * @return The concatenation of the two strings. */ function concat(slice memory self, slice memory other) internal pure returns (string memory) { string memory ret = new string(self._len + other._len); uint retptr; assembly { retptr := add(ret, 32) } memcpy(retptr, self._ptr, self._len); memcpy(retptr + self._len, other._ptr, other._len); return ret; } /* * @dev Joins an array of slices, using `self` as a delimiter, returning a * newly allocated string. * @param self The delimiter to use. * @param parts A list of slices to join. * @return A newly allocated string containing all the slices in `parts`, * joined with `self`. */ function join(slice memory self, slice[] memory parts) internal pure returns (string memory) { if (parts.length == 0) return ""; uint length = self._len * (parts.length - 1); for(uint i = 0; i < parts.length; i++) length += parts[i]._len; string memory ret = new string(length); uint retptr; assembly { retptr := add(ret, 32) } for(uint i = 0; i < parts.length; i++) { memcpy(retptr, parts[i]._ptr, parts[i]._len); retptr += parts[i]._len; if (i < parts.length - 1) { memcpy(retptr, self._ptr, self._len); retptr += self._len; } } return ret; } }
library strings { struct slice { uint _len; uint _ptr; } function memcpy(uint dest, uint src, uint len) private pure { // Copy word-length chunks while possible for(; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) } dest += 32; src += 32; } // Copy remaining bytes uint mask = 256 ** (32 - len) - 1; assembly { let srcpart := and(mload(src), not(mask)) let destpart := and(mload(dest), mask) mstore(dest, or(destpart, srcpart)) } } /* * @dev Returns a slice containing the entire string. * @param self The string to make a slice from. * @return A newly allocated slice containing the entire string. */ function toSlice(string memory self) internal pure returns (slice memory) { uint ptr; assembly { ptr := add(self, 0x20) } return slice(bytes(self).length, ptr); } /* * @dev Returns the length of a null-terminated bytes32 string. * @param self The value to find the length of. * @return The length of the string, from 0 to 32. */ function len(bytes32 self) internal pure returns (uint) { uint ret; if (self == 0) return 0; if (uint256(self) & 0xffffffffffffffffffffffffffffffff == 0) { ret += 16; self = bytes32(uint(self) / 0x100000000000000000000000000000000); } if (uint256(self) & 0xffffffffffffffff == 0) { ret += 8; self = bytes32(uint(self) / 0x10000000000000000); } if (uint256(self) & 0xffffffff == 0) { ret += 4; self = bytes32(uint(self) / 0x100000000); } if (uint256(self) & 0xffff == 0) { ret += 2; self = bytes32(uint(self) / 0x10000); } if (uint256(self) & 0xff == 0) { ret += 1; } return 32 - ret; } /* * @dev Returns a slice containing the entire bytes32, interpreted as a * null-terminated utf-8 string. * @param self The bytes32 value to convert to a slice. * @return A new slice containing the value of the input argument up to the * first null. */ function toSliceB32(bytes32 self) internal pure returns (slice memory ret) { // Allocate space for `self` in memory, copy it there, and point ret at it assembly { let ptr := mload(0x40) mstore(0x40, add(ptr, 0x20)) mstore(ptr, self) mstore(add(ret, 0x20), ptr) } ret._len = len(self); } /* * @dev Returns a new slice containing the same data as the current slice. * @param self The slice to copy. * @return A new slice containing the same data as `self`. */ function copy(slice memory self) internal pure returns (slice memory) { return slice(self._len, self._ptr); } /* * @dev Copies a slice to a new string. * @param self The slice to copy. * @return A newly allocated string containing the slice's text. */ function toString(slice memory self) internal pure returns (string memory) { string memory ret = new string(self._len); uint retptr; assembly { retptr := add(ret, 32) } memcpy(retptr, self._ptr, self._len); return ret; } /* * @dev Returns the length in runes of the slice. Note that this operation * takes time proportional to the length of the slice; avoid using it * in loops, and call `slice.empty()` if you only need to kblock.timestamp whether * the slice is empty or not. * @param self The slice to operate on. * @return The length of the slice in runes. */ function len(slice memory self) internal pure returns (uint l) { // Starting at ptr-31 means the LSB will be the byte we care about uint ptr = self._ptr - 31; uint end = ptr + self._len; for (l = 0; ptr < end; l++) { uint8 b; assembly { b := and(mload(ptr), 0xFF) } if (b < 0x80) { ptr += 1; } else if(b < 0xE0) { ptr += 2; } else if(b < 0xF0) { ptr += 3; } else if(b < 0xF8) { ptr += 4; } else if(b < 0xFC) { ptr += 5; } else { ptr += 6; } } } /* * @dev Returns true if the slice is empty (has a length of 0). * @param self The slice to operate on. * @return True if the slice is empty, False otherwise. */ function empty(slice memory self) internal pure returns (bool) { return self._len == 0; } /* * @dev Returns a positive number if `other` comes lexicographically after * `self`, a negative number if it comes before, or zero if the * contents of the two slices are equal. Comparison is done per-rune, * on unicode codepoints. * @param self The first slice to compare. * @param other The second slice to compare. * @return The result of the comparison. */ function compare(slice memory self, slice memory other) internal pure returns (int) { uint shortest = self._len; if (other._len < self._len) shortest = other._len; uint selfptr = self._ptr; uint otherptr = other._ptr; for (uint idx = 0; idx < shortest; idx += 32) { uint a; uint b; assembly { a := mload(selfptr) b := mload(otherptr) } if (a != b) { // Mask out irrelevant bytes and check again uint256 mask = uint256(-1); // 0xffff... if(shortest < 32) { mask = ~(2 ** (8 * (32 - shortest + idx)) - 1); } uint256 diff = (a & mask) - (b & mask); if (diff != 0) return int(diff); } selfptr += 32; otherptr += 32; } return int(self._len) - int(other._len); } /* * @dev Returns true if the two slices contain the same text. * @param self The first slice to compare. * @param self The second slice to compare. * @return True if the slices are equal, false otherwise. */ function equals(slice memory self, slice memory other) internal pure returns (bool) { return compare(self, other) == 0; } /* * @dev Extracts the first rune in the slice into `rune`, advancing the * slice to point to the next rune and returning `self`. * @param self The slice to operate on. * @param rune The slice that will contain the first rune. * @return `rune`. */ function nextRune(slice memory self, slice memory rune) internal pure returns (slice memory) { rune._ptr = self._ptr; if (self._len == 0) { rune._len = 0; return rune; } uint l; uint b; // Load the first byte of the rune into the LSBs of b assembly { b := and(mload(sub(mload(add(self, 32)), 31)), 0xFF) } if (b < 0x80) { l = 1; } else if(b < 0xE0) { l = 2; } else if(b < 0xF0) { l = 3; } else { l = 4; } // Check for truncated codepoints if (l > self._len) { rune._len = self._len; self._ptr += self._len; self._len = 0; return rune; } self._ptr += l; self._len -= l; rune._len = l; return rune; } /* * @dev Returns the first rune in the slice, advancing the slice to point * to the next rune. * @param self The slice to operate on. * @return A slice containing only the first rune from `self`. */ function nextRune(slice memory self) internal pure returns (slice memory ret) { nextRune(self, ret); } /* * @dev Returns the number of the first codepoint in the slice. * @param self The slice to operate on. * @return The number of the first codepoint in the slice. */ function ord(slice memory self) internal pure returns (uint ret) { if (self._len == 0) { return 0; } uint word; uint length; uint divisor = 2 ** 248; // Load the rune into the MSBs of b assembly { word:= mload(mload(add(self, 32))) } uint b = word / divisor; if (b < 0x80) { ret = b; length = 1; } else if(b < 0xE0) { ret = b & 0x1F; length = 2; } else if(b < 0xF0) { ret = b & 0x0F; length = 3; } else { ret = b & 0x07; length = 4; } // Check for truncated codepoints if (length > self._len) { return 0; } for (uint i = 1; i < length; i++) { divisor = divisor / 256; b = (word / divisor) & 0xFF; if (b & 0xC0 != 0x80) { // Invalid UTF-8 sequence return 0; } ret = (ret * 64) | (b & 0x3F); } return ret; } /* * @dev Returns the keccak-256 hash of the slice. * @param self The slice to hash. * @return The hash of the slice. */ function keccak(slice memory self) internal pure returns (bytes32 ret) { assembly { ret := keccak256(mload(add(self, 32)), mload(self)) } } /* * @dev Returns true if `self` starts with `needle`. * @param self The slice to operate on. * @param needle The slice to search for. * @return True if the slice starts with the provided text, false otherwise. */ function startsWith(slice memory self, slice memory needle) internal pure returns (bool) { if (self._len < needle._len) { return false; } if (self._ptr == needle._ptr) { return true; } bool equal; assembly { let length := mload(needle) let selfptr := mload(add(self, 0x20)) let needleptr := mload(add(needle, 0x20)) equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) } return equal; } /* * @dev If `self` starts with `needle`, `needle` is removed from the * beginning of `self`. Otherwise, `self` is unmodified. * @param self The slice to operate on. * @param needle The slice to search for. * @return `self` */ function beyond(slice memory self, slice memory needle) internal pure returns (slice memory) { if (self._len < needle._len) { return self; } bool equal = true; if (self._ptr != needle._ptr) { assembly { let length := mload(needle) let selfptr := mload(add(self, 0x20)) let needleptr := mload(add(needle, 0x20)) equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) } } if (equal) { self._len -= needle._len; self._ptr += needle._len; } return self; } /* * @dev Returns true if the slice ends with `needle`. * @param self The slice to operate on. * @param needle The slice to search for. * @return True if the slice starts with the provided text, false otherwise. */ function endsWith(slice memory self, slice memory needle) internal pure returns (bool) { if (self._len < needle._len) { return false; } uint selfptr = self._ptr + self._len - needle._len; if (selfptr == needle._ptr) { return true; } bool equal; assembly { let length := mload(needle) let needleptr := mload(add(needle, 0x20)) equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) } return equal; } /* * @dev If `self` ends with `needle`, `needle` is removed from the * end of `self`. Otherwise, `self` is unmodified. * @param self The slice to operate on. * @param needle The slice to search for. * @return `self` */ function until(slice memory self, slice memory needle) internal pure returns (slice memory) { if (self._len < needle._len) { return self; } uint selfptr = self._ptr + self._len - needle._len; bool equal = true; if (selfptr != needle._ptr) { assembly { let length := mload(needle) let needleptr := mload(add(needle, 0x20)) equal := eq(keccak256(selfptr, length), keccak256(needleptr, length)) } } if (equal) { self._len -= needle._len; } return self; } // Returns the memory address of the first byte of the first occurrence of // `needle` in `self`, or the first byte after `self` if not found. function findPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) { uint ptr = selfptr; uint idx; if (needlelen <= selflen) { if (needlelen <= 32) { bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1)); bytes32 needledata; assembly { needledata := and(mload(needleptr), mask) } uint end = selfptr + selflen - needlelen; bytes32 ptrdata; assembly { ptrdata := and(mload(ptr), mask) } while (ptrdata != needledata) { if (ptr >= end) return selfptr + selflen; ptr++; assembly { ptrdata := and(mload(ptr), mask) } } return ptr; } else { // For long needles, use hashing bytes32 hash; assembly { hash := keccak256(needleptr, needlelen) } for (idx = 0; idx <= selflen - needlelen; idx++) { bytes32 testHash; assembly { testHash := keccak256(ptr, needlelen) } if (hash == testHash) return ptr; ptr += 1; } } } return selfptr + selflen; } // Returns the memory address of the first byte after the last occurrence of // `needle` in `self`, or the address of `self` if not found. function rfindPtr(uint selflen, uint selfptr, uint needlelen, uint needleptr) private pure returns (uint) { uint ptr; if (needlelen <= selflen) { if (needlelen <= 32) { bytes32 mask = bytes32(~(2 ** (8 * (32 - needlelen)) - 1)); bytes32 needledata; assembly { needledata := and(mload(needleptr), mask) } ptr = selfptr + selflen - needlelen; bytes32 ptrdata; assembly { ptrdata := and(mload(ptr), mask) } while (ptrdata != needledata) { if (ptr <= selfptr) return selfptr; ptr--; assembly { ptrdata := and(mload(ptr), mask) } } return ptr + needlelen; } else { // For long needles, use hashing bytes32 hash; assembly { hash := keccak256(needleptr, needlelen) } ptr = selfptr + (selflen - needlelen); while (ptr >= selfptr) { bytes32 testHash; assembly { testHash := keccak256(ptr, needlelen) } if (hash == testHash) return ptr + needlelen; ptr -= 1; } } } return selfptr; } /* * @dev Modifies `self` to contain everything from the first occurrence of * `needle` to the end of the slice. `self` is set to the empty slice * if `needle` is not found. * @param self The slice to search and modify. * @param needle The text to search for. * @return `self`. */ function find(slice memory self, slice memory needle) internal pure returns (slice memory) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); self._len -= ptr - self._ptr; self._ptr = ptr; return self; } /* * @dev Modifies `self` to contain the part of the string from the start of * `self` to the end of the first occurrence of `needle`. If `needle` * is not found, `self` is set to the empty slice. * @param self The slice to search and modify. * @param needle The text to search for. * @return `self`. */ function rfind(slice memory self, slice memory needle) internal pure returns (slice memory) { uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); self._len = ptr - self._ptr; return self; } /* * @dev Splits the slice, setting `self` to everything after the first * occurrence of `needle`, and `token` to everything before it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and `token` is set to the entirety of `self`. * @param self The slice to split. * @param needle The text to search for in `self`. * @param token An output parameter to which the first token is written. * @return `token`. */ function split(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr); token._ptr = self._ptr; token._len = ptr - self._ptr; if (ptr == self._ptr + self._len) { // Not found self._len = 0; } else { self._len -= token._len + needle._len; self._ptr = ptr + needle._len; } return token; } /* * @dev Splits the slice, setting `self` to everything after the first * occurrence of `needle`, and returning everything before it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and the entirety of `self` is returned. * @param self The slice to split. * @param needle The text to search for in `self`. * @return The part of `self` up to the first occurrence of `delim`. */ function split(slice memory self, slice memory needle) internal pure returns (slice memory token) { split(self, needle, token); } /* * @dev Splits the slice, setting `self` to everything before the last * occurrence of `needle`, and `token` to everything after it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and `token` is set to the entirety of `self`. * @param self The slice to split. * @param needle The text to search for in `self`. * @param token An output parameter to which the first token is written. * @return `token`. */ function rsplit(slice memory self, slice memory needle, slice memory token) internal pure returns (slice memory) { uint ptr = rfindPtr(self._len, self._ptr, needle._len, needle._ptr); token._ptr = ptr; token._len = self._len - (ptr - self._ptr); if (ptr == self._ptr) { // Not found self._len = 0; } else { self._len -= token._len + needle._len; } return token; } /* * @dev Splits the slice, setting `self` to everything before the last * occurrence of `needle`, and returning everything after it. If * `needle` does not occur in `self`, `self` is set to the empty slice, * and the entirety of `self` is returned. * @param self The slice to split. * @param needle The text to search for in `self`. * @return The part of `self` after the last occurrence of `delim`. */ function rsplit(slice memory self, slice memory needle) internal pure returns (slice memory token) { rsplit(self, needle, token); } /* * @dev Counts the number of nonoverlapping occurrences of `needle` in `self`. * @param self The slice to search. * @param needle The text to search for in `self`. * @return The number of occurrences of `needle` found in `self`. */ function count(slice memory self, slice memory needle) internal pure returns (uint cnt) { uint ptr = findPtr(self._len, self._ptr, needle._len, needle._ptr) + needle._len; while (ptr <= self._ptr + self._len) { cnt++; ptr = findPtr(self._len - (ptr - self._ptr), ptr, needle._len, needle._ptr) + needle._len; } } /* * @dev Returns True if `self` contains `needle`. * @param self The slice to search. * @param needle The text to search for in `self`. * @return True if `needle` is found in `self`, false otherwise. */ function contains(slice memory self, slice memory needle) internal pure returns (bool) { return rfindPtr(self._len, self._ptr, needle._len, needle._ptr) != self._ptr; } /* * @dev Returns a newly allocated string containing the concatenation of * `self` and `other`. * @param self The first slice to concatenate. * @param other The second slice to concatenate. * @return The concatenation of the two strings. */ function concat(slice memory self, slice memory other) internal pure returns (string memory) { string memory ret = new string(self._len + other._len); uint retptr; assembly { retptr := add(ret, 32) } memcpy(retptr, self._ptr, self._len); memcpy(retptr + self._len, other._ptr, other._len); return ret; } /* * @dev Joins an array of slices, using `self` as a delimiter, returning a * newly allocated string. * @param self The delimiter to use. * @param parts A list of slices to join. * @return A newly allocated string containing all the slices in `parts`, * joined with `self`. */ function join(slice memory self, slice[] memory parts) internal pure returns (string memory) { if (parts.length == 0) return ""; uint length = self._len * (parts.length - 1); for(uint i = 0; i < parts.length; i++) length += parts[i]._len; string memory ret = new string(length); uint retptr; assembly { retptr := add(ret, 32) } for(uint i = 0; i < parts.length; i++) { memcpy(retptr, parts[i]._ptr, parts[i]._len); retptr += parts[i]._len; if (i < parts.length - 1) { memcpy(retptr, self._ptr, self._len); retptr += self._len; } } return ret; } }
16,012
19
// Will revert if any independent claim reverts.
_claimRewards(msg.sender, periodID);
_claimRewards(msg.sender, periodID);
20,770
7
// NonReceivableInitializedProxy Anna Carroll /
contract NonReceivableInitializedProxy { // address of logic contract address public immutable logic; // ======== Constructor ========= constructor(address _logic, bytes memory _initializationCalldata) { logic = _logic; // Delegatecall into the logic contract, supplying initialization calldata (bool _ok, bytes memory returnData) = _logic.delegatecall( _initializationCalldata ); // Revert if delegatecall to implementation reverts require(_ok, string(returnData)); } // ======== Fallback ========= fallback() external payable { address _impl = logic; assembly { let ptr := mload(0x40) calldatacopy(ptr, 0, calldatasize()) let result := delegatecall(gas(), _impl, ptr, calldatasize(), 0, 0) let size := returndatasize() returndatacopy(ptr, 0, size) switch result case 0 { revert(ptr, size) } default { return(ptr, size) } } } }
contract NonReceivableInitializedProxy { // address of logic contract address public immutable logic; // ======== Constructor ========= constructor(address _logic, bytes memory _initializationCalldata) { logic = _logic; // Delegatecall into the logic contract, supplying initialization calldata (bool _ok, bytes memory returnData) = _logic.delegatecall( _initializationCalldata ); // Revert if delegatecall to implementation reverts require(_ok, string(returnData)); } // ======== Fallback ========= fallback() external payable { address _impl = logic; assembly { let ptr := mload(0x40) calldatacopy(ptr, 0, calldatasize()) let result := delegatecall(gas(), _impl, ptr, calldatasize(), 0, 0) let size := returndatasize() returndatacopy(ptr, 0, size) switch result case 0 { revert(ptr, size) } default { return(ptr, size) } } } }
20,206
7
// Divides two numbers and returns a uint32 a A number b A numberreturn a / b as a uint32 /
function div32(uint256 a, uint256 b) internal pure returns (uint32) { uint256 c = a / b; require(c < 2**32); /* solcov ignore next */ return uint32(c); }
function div32(uint256 a, uint256 b) internal pure returns (uint32) { uint256 c = a / b; require(c < 2**32); /* solcov ignore next */ return uint32(c); }
29,518
131
// TokenRecover Allows owner to recover any ERC20 sent into the contract /
contract TokenRecover is Ownable { /** * @dev Remember that only owner can call so be careful when use on contracts generated from other contracts. * @param tokenAddress The token contract address * @param tokenAmount Number of tokens to be sent */ function recoverERC20(address tokenAddress, uint256 tokenAmount) public virtual onlyOwner { IERC20(tokenAddress).transfer(owner(), tokenAmount); } }
contract TokenRecover is Ownable { /** * @dev Remember that only owner can call so be careful when use on contracts generated from other contracts. * @param tokenAddress The token contract address * @param tokenAmount Number of tokens to be sent */ function recoverERC20(address tokenAddress, uint256 tokenAmount) public virtual onlyOwner { IERC20(tokenAddress).transfer(owner(), tokenAmount); } }
2,171
17
// Returns node info of nodes in a monitoring list.Node info includes IPs, nodeIndex, and time to send verdict. /
function getCheckedArray(bytes32 monitorIndex) external view returns (CheckedNodeWithIp[] memory checkedNodesWithIp)
function getCheckedArray(bytes32 monitorIndex) external view returns (CheckedNodeWithIp[] memory checkedNodesWithIp)
28,593
34
// get isActive -- when account used token since last claim --
function isActive(uint _accountId) public view returns(bool) { return _accounts[_accountId].isActive; }
function isActive(uint _accountId) public view returns(bool) { return _accounts[_accountId].isActive; }
16,848
176
// Return failure if no input tokens.
return BRIDGE_FAILED;
return BRIDGE_FAILED;
33,113
12
// Require a valid commitment
require(commitments[commitment] + minCommitmentAge <= block.timestamp);
require(commitments[commitment] + minCommitmentAge <= block.timestamp);
6,126
7
// Vesting - simple contract with hardset unlocks and shares.
contract Vesting is Ownable, IVesting { uint256 public constant override MAX_LOCK_LENGTH = 100; uint256 public override claimed; uint256 public immutable override totalShares; IERC20 public immutable override token; uint256 public immutable override startAt; uint256[] private _shares; uint256[] private _unlocks; constructor( IERC20 _token, uint256 _startAt, uint256[] memory shares_, uint256[] memory _unlocksAt ) { require(_startAt > block.timestamp, "Vesting: unlock time in the past"); token = _token; startAt = _startAt; require( shares_.length == _unlocksAt.length, "Unlocks and shares_ length not equal" ); require(shares_.length != 0, "Empty vesting program"); require(shares_.length <= MAX_LOCK_LENGTH, "Max lock length overflow"); uint256 _totalShares; for (uint256 i; i < shares_.length; i++) { require(shares_[i] != 0, "Zero share set"); if (i == 0) { require( _unlocksAt[i] >= _startAt, "Previous timestamp higher then current" ); } else { require( _unlocksAt[i] > _unlocksAt[i - 1], "Previous timestamp higher then current" ); } _totalShares += shares_[i]; } _shares = shares_; _unlocks = _unlocksAt; totalShares = _totalShares; } function claim() external override onlyAfter(startAt) { uint256 amount = IERC20(token).balanceOf(address(this)); uint256 len = _unlocks.length; uint256 unlockedShares; for (uint256 i; i < len; i++) { if (_unlocks[i] <= block.timestamp) { if (i < _shares.length) { unlockedShares += _shares[i]; } } else { i = len; // end loop } } uint256 reward = (unlockedShares * amount) / totalShares; if (reward != 0) { reward -= claimed; } require(reward != 0, "No reward"); claimed += reward; IERC20(token).transfer(owner(), reward); } function nextClaim() external view override returns (uint256 reward, uint256 unlockedShares, uint256 timestamp) { uint256 amount = IERC20(token).balanceOf(address(this)); uint256 len = _unlocks.length; for (uint256 i; i < len; i++) { if (_unlocks[i] <= block.timestamp) { unlockedShares += _shares[i]; timestamp = block.timestamp; } else { timestamp = _unlocks[i]; i = len; // end loop } } if (unlockedShares == 0) { unlockedShares += _shares[0]; timestamp = _unlocks[0]; } if (unlockedShares == totalShares) { timestamp = 0; } reward = (unlockedShares * amount) / totalShares; if (reward != 0) { reward -= claimed; } } // @dev Returns how much _unlocks available. function countUnlocks() external view returns (uint256 result) { result = _unlocks.length; } function shares(uint256 _index) external view override returns (uint256) { require(_index < _shares.length, "Key not exist"); return _shares[_index]; } function unlocks(uint256 _index) external view override returns (uint256) { require(_index < _unlocks.length, "Key not exist"); return _unlocks[_index]; } modifier onlyAfter(uint256 _timestamp) { require(_timestamp < block.timestamp, "Its not a time"); _; } }
contract Vesting is Ownable, IVesting { uint256 public constant override MAX_LOCK_LENGTH = 100; uint256 public override claimed; uint256 public immutable override totalShares; IERC20 public immutable override token; uint256 public immutable override startAt; uint256[] private _shares; uint256[] private _unlocks; constructor( IERC20 _token, uint256 _startAt, uint256[] memory shares_, uint256[] memory _unlocksAt ) { require(_startAt > block.timestamp, "Vesting: unlock time in the past"); token = _token; startAt = _startAt; require( shares_.length == _unlocksAt.length, "Unlocks and shares_ length not equal" ); require(shares_.length != 0, "Empty vesting program"); require(shares_.length <= MAX_LOCK_LENGTH, "Max lock length overflow"); uint256 _totalShares; for (uint256 i; i < shares_.length; i++) { require(shares_[i] != 0, "Zero share set"); if (i == 0) { require( _unlocksAt[i] >= _startAt, "Previous timestamp higher then current" ); } else { require( _unlocksAt[i] > _unlocksAt[i - 1], "Previous timestamp higher then current" ); } _totalShares += shares_[i]; } _shares = shares_; _unlocks = _unlocksAt; totalShares = _totalShares; } function claim() external override onlyAfter(startAt) { uint256 amount = IERC20(token).balanceOf(address(this)); uint256 len = _unlocks.length; uint256 unlockedShares; for (uint256 i; i < len; i++) { if (_unlocks[i] <= block.timestamp) { if (i < _shares.length) { unlockedShares += _shares[i]; } } else { i = len; // end loop } } uint256 reward = (unlockedShares * amount) / totalShares; if (reward != 0) { reward -= claimed; } require(reward != 0, "No reward"); claimed += reward; IERC20(token).transfer(owner(), reward); } function nextClaim() external view override returns (uint256 reward, uint256 unlockedShares, uint256 timestamp) { uint256 amount = IERC20(token).balanceOf(address(this)); uint256 len = _unlocks.length; for (uint256 i; i < len; i++) { if (_unlocks[i] <= block.timestamp) { unlockedShares += _shares[i]; timestamp = block.timestamp; } else { timestamp = _unlocks[i]; i = len; // end loop } } if (unlockedShares == 0) { unlockedShares += _shares[0]; timestamp = _unlocks[0]; } if (unlockedShares == totalShares) { timestamp = 0; } reward = (unlockedShares * amount) / totalShares; if (reward != 0) { reward -= claimed; } } // @dev Returns how much _unlocks available. function countUnlocks() external view returns (uint256 result) { result = _unlocks.length; } function shares(uint256 _index) external view override returns (uint256) { require(_index < _shares.length, "Key not exist"); return _shares[_index]; } function unlocks(uint256 _index) external view override returns (uint256) { require(_index < _unlocks.length, "Key not exist"); return _unlocks[_index]; } modifier onlyAfter(uint256 _timestamp) { require(_timestamp < block.timestamp, "Its not a time"); _; } }
19,665
64
// xref:ROOT:erc1155.adocbatch-operations[Batched] version of {safeTransferFrom}. Emits a {TransferBatch} event. Requirements: - `ids` and `amounts` must have the same length.- If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return theacceptance magic value. /
function safeBatchTransferFrom(
function safeBatchTransferFrom(
715
70
// small shortcut We can check state >= because we know that Enum state is sequential. If some new State is added / removed check if condition is still valid
if ( state == IGovernanceCore.State.Null || state >= IGovernanceCore.State.Executed ) { return state; }
if ( state == IGovernanceCore.State.Null || state >= IGovernanceCore.State.Executed ) { return state; }
9,252
21
// Returns a list of all unconfirmed NFTs waiting for approval
function tokenizationRequests() external view returns(NFTData[] memory ownerTokens)
function tokenizationRequests() external view returns(NFTData[] memory ownerTokens)
40,455
19
// Internal function calculating new SRC20 values based on minted ones. On everynew minting of supply new SWM and SRC20 values are saved for further calculations.src20 SRC20 token address. swmValue SWM stake value.return Amount of SRC20 tokens. /
function _calcTokens(address src20, uint256 swmValue) internal view returns (uint256) { require(src20 != address(0), "Token address is zero"); require(swmValue != 0, "SWM value is zero"); require(_registry[src20].owner != address(0), "SRC20 token contract not registered"); uint256 totalSupply = ISRC20(src20).totalSupply(); return swmValue.mul(totalSupply).div(_registry[src20].stake); }
function _calcTokens(address src20, uint256 swmValue) internal view returns (uint256) { require(src20 != address(0), "Token address is zero"); require(swmValue != 0, "SWM value is zero"); require(_registry[src20].owner != address(0), "SRC20 token contract not registered"); uint256 totalSupply = ISRC20(src20).totalSupply(); return swmValue.mul(totalSupply).div(_registry[src20].stake); }
44,196
141
// Mapping token to allow to transfer to contract
mapping(uint256 => bool) public _transferToContract; ///////////////////////////////////////////////////////////////////////////////////// new 1 mapping(address => bool) public _addressTransferToContract; ///////////////////////////////////////////////////////////////////////////////////// new 1
mapping(uint256 => bool) public _transferToContract; ///////////////////////////////////////////////////////////////////////////////////// new 1 mapping(address => bool) public _addressTransferToContract; ///////////////////////////////////////////////////////////////////////////////////// new 1
6,098
25
// Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],but performing a delegate call. _Available since v3.3._ /
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract");
function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { require(isContract(target), "Address: delegate call to non-contract");
1,540
4
// First fibonacci number before the function (n-1)
uint num1;
uint num1;
1,222
215
// mStable mUSD basket manager contract. /
IBasketManager constant private _basketManager = IBasketManager(0x66126B4aA2a1C07536Ef8E5e8bD4EfDA1FdEA96D);
IBasketManager constant private _basketManager = IBasketManager(0x66126B4aA2a1C07536Ef8E5e8bD4EfDA1FdEA96D);
2,259
174
// check if his stored msg.data hash equals to the one of the other admin
if ((multiSigHashes[admin1]) == (multiSigHashes[admin2])) {
if ((multiSigHashes[admin1]) == (multiSigHashes[admin2])) {
4,281
103
// _to recipient, one of {ISSUER, HOLDER, POOL} _amount amount that was released in the transaction /
function setDepositsReleased(
function setDepositsReleased(
30,551
107
// For legit out of gas issue, the call may still fail if more gas is provied and this is okay, because there can be incentive to jail the app by providing more gas.
revert("SF: need more gas");
revert("SF: need more gas");
17,900
20
// ADMIN
function setStartTime(uint256 time) public onlyOwner() { startTime = time; }
function setStartTime(uint256 time) public onlyOwner() { startTime = time; }
27,820
13
// extracts the raw LE bytes of the output value/_outputthe output/ return the raw LE bytes of the output value
function valueBytes(bytes29 _output) internal pure typeAssert(_output, BTCTypes.TxOut) returns (bytes8) { return bytes8(_output.index(0, 8)); }
function valueBytes(bytes29 _output) internal pure typeAssert(_output, BTCTypes.TxOut) returns (bytes8) { return bytes8(_output.index(0, 8)); }
35,313
218
// Reads the decimals property of the provided token. Either decimals() or DECIMALS() method is used._token address of the token contract. return token decimals or 0 if none of the methods succeeded./
function readDecimals(address _token) internal view returns (uint256) { uint256 decimals; assembly { let ptr := mload(0x40) mstore(0x40, add(ptr, 32)) mstore(ptr, 0x313ce56700000000000000000000000000000000000000000000000000000000) // decimals() if iszero(staticcall(gas, _token, ptr, 4, ptr, 32)) { mstore(ptr, 0x2e0f262500000000000000000000000000000000000000000000000000000000) // DECIMALS() if iszero(staticcall(gas, _token, ptr, 4, ptr, 32)) { mstore(ptr, 0) } }
function readDecimals(address _token) internal view returns (uint256) { uint256 decimals; assembly { let ptr := mload(0x40) mstore(0x40, add(ptr, 32)) mstore(ptr, 0x313ce56700000000000000000000000000000000000000000000000000000000) // decimals() if iszero(staticcall(gas, _token, ptr, 4, ptr, 32)) { mstore(ptr, 0x2e0f262500000000000000000000000000000000000000000000000000000000) // DECIMALS() if iszero(staticcall(gas, _token, ptr, 4, ptr, 32)) { mstore(ptr, 0) } }
2,371
29
// If broadcastSignal is permissioned, check if msg.sender is the contract owner /
modifier onlyOwnerIfPermissioned() { require(!isBroadcastPermissioned || msg.sender == owner, "MACI: broadcast permission denied"); _; }
modifier onlyOwnerIfPermissioned() { require(!isBroadcastPermissioned || msg.sender == owner, "MACI: broadcast permission denied"); _; }
20,566
109
// Function to simply retrieve block number This exists mainly for inheriting test contracts to stub this result. /
function getBlockNumber() internal view returns (uint) { return block.number; }
function getBlockNumber() internal view returns (uint) { return block.number; }
4,781
150
// Initialize the passed address as AddressConfig address and Devminter. /
constructor(address _config, address _devMinter) public UsingConfig(_config)
constructor(address _config, address _devMinter) public UsingConfig(_config)
10,353
389
// Borrow cap of 0 corresponds to unlimited borrowing
if (borrowCap != 0) { uint totalBorrows = PToken(pToken).totalBorrows(); (MathError mathErr, uint nextTotalBorrows) = addUInt(totalBorrows, borrowAmount); require(mathErr == MathError.NO_ERROR, "total borrows overflow"); require(nextTotalBorrows < borrowCap, "market borrow cap reached"); }
if (borrowCap != 0) { uint totalBorrows = PToken(pToken).totalBorrows(); (MathError mathErr, uint nextTotalBorrows) = addUInt(totalBorrows, borrowAmount); require(mathErr == MathError.NO_ERROR, "total borrows overflow"); require(nextTotalBorrows < borrowCap, "market borrow cap reached"); }
15,576
133
// Includes an account from receiving reward.
* Emits a {IncludeAccountInReward} event. * * Requirements: * * - `account` is excluded in receiving reward. */ function includeAccountInReward(address account) public onlyOwner { require(_isExcludedFromReward[account], "Account is already included."); for (uint256 i = 0; i < _excludedFromReward.length; i++) { if (_excludedFromReward[i] == account) { _excludedFromReward[i] = _excludedFromReward[_excludedFromReward.length - 1]; _tokenBalances[account] = 0; _isExcludedFromReward[account] = false; _excludedFromReward.pop(); break; } } emit IncludeAccountInReward(account); }
* Emits a {IncludeAccountInReward} event. * * Requirements: * * - `account` is excluded in receiving reward. */ function includeAccountInReward(address account) public onlyOwner { require(_isExcludedFromReward[account], "Account is already included."); for (uint256 i = 0; i < _excludedFromReward.length; i++) { if (_excludedFromReward[i] == account) { _excludedFromReward[i] = _excludedFromReward[_excludedFromReward.length - 1]; _tokenBalances[account] = 0; _isExcludedFromReward[account] = false; _excludedFromReward.pop(); break; } } emit IncludeAccountInReward(account); }
42,757
11
// copy function selector and any arguments
calldatacopy(0, 0, calldatasize())
calldatacopy(0, 0, calldatasize())
34,278
37
// Call this contract function from the external remote job to perform the liquidation. /loan information
address flashToken, uint256 flashAmount,
address flashToken, uint256 flashAmount,
69,531
20
// Modern and gas-optimized ERC-1155 implementation./Modified from Helios (https:github.com/z0r0z/Helios/blob/main/contracts/ERC1155.sol)
contract ERC1155 { /*/////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 amount); event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] amounts); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /*/////////////////////////////////////////////////////////////// ERC1155 STORAGE //////////////////////////////////////////////////////////////*/ string public baseURI; string public name = "Santa Swap Participation Token"; mapping(address => mapping(uint256 => uint256)) public balanceOf; mapping(address => mapping(address => bool)) internal operators; /*/////////////////////////////////////////////////////////////// ERRORS //////////////////////////////////////////////////////////////*/ error ArrayParity(); error InvalidOperator(); error NullAddress(); error InvalidReceiver(); /*/////////////////////////////////////////////////////////////// ERC1155 LOGIC //////////////////////////////////////////////////////////////*/ /* GETTERS */ function balanceOfBatch(address[] calldata owners, uint256[] calldata ids) external view returns (uint256[] memory batchBalances) { if (owners.length != ids.length) revert ArrayParity(); batchBalances = new uint256[](owners.length); for (uint256 i = 0; i < owners.length; i++) { batchBalances[i] = balanceOf[owners[i]][ids[i]]; } } function supportsInterface(bytes4 interfaceId) external pure returns (bool supported) { supported = interfaceId == 0xd9b67a26 || interfaceId == 0x0e89341c; } function uri(uint256) external view returns (string memory meta) { meta = baseURI; } /* APPROVALS */ function isApprovedForAll(address owner, address operator) public view returns (bool isOperator) { isOperator = operators[owner][operator]; } function setApprovalForAll(address operator, bool approved) external { operators[msg.sender][operator] = approved; emit ApprovalForAll(msg.sender, operator, approved); } /* TRANSFERS */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) external { if (msg.sender != from || !isApprovedForAll(from, msg.sender)) revert InvalidOperator(); if (to == address(0)) revert NullAddress(); balanceOf[from][id] -= amount; balanceOf[to][id] += amount; _callonERC1155Received(from, to, id, amount, gasleft(), data); emit TransferSingle(msg.sender, from, to, id, amount); } function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) external { if (msg.sender != from || !isApprovedForAll(from, msg.sender)) revert InvalidOperator(); if (to == address(0)) revert NullAddress(); if (ids.length != amounts.length) revert ArrayParity(); for (uint256 i = 0; i < ids.length; i++) { balanceOf[from][ids[i]] -= amounts[i]; balanceOf[to][ids[i]] += amounts[i]; } _callonERC1155BatchReceived(from, to, ids, amounts, gasleft(), data); emit TransferBatch(msg.sender, from, to, ids, amounts); } function _callonERC1155Received( address from, address to, uint256 id, uint256 amount, uint256 gasLimit, bytes memory data ) internal view { if (to.code.length != 0) { // selector = `bytes4(keccak256('onERC1155Received(address,address,uint256,uint256,bytes)'))` (, bytes memory returned) = to.staticcall{gas: gasLimit}(abi.encodeWithSelector(0xf23a6e61, msg.sender, from, id, amount, data)); bytes4 selector = abi.decode(returned, (bytes4)); if (selector != 0xf23a6e61) revert InvalidReceiver(); } } function _callonERC1155BatchReceived( address from, address to, uint256[] memory ids, uint256[] memory amounts, uint256 gasLimit, bytes memory data ) internal view { if (to.code.length != 0) { // selector = `bytes4(keccak256('onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)'))` (, bytes memory returned) = to.staticcall{gas: gasLimit}(abi.encodeWithSelector(0xbc197c81, msg.sender, from, ids, amounts, data)); bytes4 selector = abi.decode(returned, (bytes4)); if (selector != 0xbc197c81) revert InvalidReceiver(); } } /*/////////////////////////////////////////////////////////////// MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint( address to, uint256 id, uint256 amount, bytes memory data ) internal { balanceOf[to][id] += amount; if (to.code.length != 0) _callonERC1155Received(address(0), to, id, amount, gasleft(), data); emit TransferSingle(msg.sender, address(0), to, id, amount); } function _batchMint( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal { if (ids.length != amounts.length) revert ArrayParity(); for (uint256 i = 0; i < ids.length; i++) { balanceOf[to][ids[i]] += amounts[i]; } if (to.code.length != 0) _callonERC1155BatchReceived(address(0x0), to, ids, amounts, gasleft(), data); emit TransferBatch(msg.sender, address(0), to, ids, amounts); } /*/////////////////////////////////////////////////////////////// URI LOGIC //////////////////////////////////////////////////////////////*/ function _updateURI(string memory newURI) internal { baseURI = newURI; } }
contract ERC1155 { /*/////////////////////////////////////////////////////////////// EVENTS //////////////////////////////////////////////////////////////*/ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 amount); event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] amounts); event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /*/////////////////////////////////////////////////////////////// ERC1155 STORAGE //////////////////////////////////////////////////////////////*/ string public baseURI; string public name = "Santa Swap Participation Token"; mapping(address => mapping(uint256 => uint256)) public balanceOf; mapping(address => mapping(address => bool)) internal operators; /*/////////////////////////////////////////////////////////////// ERRORS //////////////////////////////////////////////////////////////*/ error ArrayParity(); error InvalidOperator(); error NullAddress(); error InvalidReceiver(); /*/////////////////////////////////////////////////////////////// ERC1155 LOGIC //////////////////////////////////////////////////////////////*/ /* GETTERS */ function balanceOfBatch(address[] calldata owners, uint256[] calldata ids) external view returns (uint256[] memory batchBalances) { if (owners.length != ids.length) revert ArrayParity(); batchBalances = new uint256[](owners.length); for (uint256 i = 0; i < owners.length; i++) { batchBalances[i] = balanceOf[owners[i]][ids[i]]; } } function supportsInterface(bytes4 interfaceId) external pure returns (bool supported) { supported = interfaceId == 0xd9b67a26 || interfaceId == 0x0e89341c; } function uri(uint256) external view returns (string memory meta) { meta = baseURI; } /* APPROVALS */ function isApprovedForAll(address owner, address operator) public view returns (bool isOperator) { isOperator = operators[owner][operator]; } function setApprovalForAll(address operator, bool approved) external { operators[msg.sender][operator] = approved; emit ApprovalForAll(msg.sender, operator, approved); } /* TRANSFERS */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) external { if (msg.sender != from || !isApprovedForAll(from, msg.sender)) revert InvalidOperator(); if (to == address(0)) revert NullAddress(); balanceOf[from][id] -= amount; balanceOf[to][id] += amount; _callonERC1155Received(from, to, id, amount, gasleft(), data); emit TransferSingle(msg.sender, from, to, id, amount); } function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) external { if (msg.sender != from || !isApprovedForAll(from, msg.sender)) revert InvalidOperator(); if (to == address(0)) revert NullAddress(); if (ids.length != amounts.length) revert ArrayParity(); for (uint256 i = 0; i < ids.length; i++) { balanceOf[from][ids[i]] -= amounts[i]; balanceOf[to][ids[i]] += amounts[i]; } _callonERC1155BatchReceived(from, to, ids, amounts, gasleft(), data); emit TransferBatch(msg.sender, from, to, ids, amounts); } function _callonERC1155Received( address from, address to, uint256 id, uint256 amount, uint256 gasLimit, bytes memory data ) internal view { if (to.code.length != 0) { // selector = `bytes4(keccak256('onERC1155Received(address,address,uint256,uint256,bytes)'))` (, bytes memory returned) = to.staticcall{gas: gasLimit}(abi.encodeWithSelector(0xf23a6e61, msg.sender, from, id, amount, data)); bytes4 selector = abi.decode(returned, (bytes4)); if (selector != 0xf23a6e61) revert InvalidReceiver(); } } function _callonERC1155BatchReceived( address from, address to, uint256[] memory ids, uint256[] memory amounts, uint256 gasLimit, bytes memory data ) internal view { if (to.code.length != 0) { // selector = `bytes4(keccak256('onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)'))` (, bytes memory returned) = to.staticcall{gas: gasLimit}(abi.encodeWithSelector(0xbc197c81, msg.sender, from, ids, amounts, data)); bytes4 selector = abi.decode(returned, (bytes4)); if (selector != 0xbc197c81) revert InvalidReceiver(); } } /*/////////////////////////////////////////////////////////////// MINT/BURN LOGIC //////////////////////////////////////////////////////////////*/ function _mint( address to, uint256 id, uint256 amount, bytes memory data ) internal { balanceOf[to][id] += amount; if (to.code.length != 0) _callonERC1155Received(address(0), to, id, amount, gasleft(), data); emit TransferSingle(msg.sender, address(0), to, id, amount); } function _batchMint( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal { if (ids.length != amounts.length) revert ArrayParity(); for (uint256 i = 0; i < ids.length; i++) { balanceOf[to][ids[i]] += amounts[i]; } if (to.code.length != 0) _callonERC1155BatchReceived(address(0x0), to, ids, amounts, gasleft(), data); emit TransferBatch(msg.sender, address(0), to, ids, amounts); } /*/////////////////////////////////////////////////////////////// URI LOGIC //////////////////////////////////////////////////////////////*/ function _updateURI(string memory newURI) internal { baseURI = newURI; } }
20,155
1
// ========== CONSTRUCTOR ========== /
constructor(address _poolManager, address _rewardsToken, address _poolAddress, address _xTGEN) { rewardsToken = IERC20(_rewardsToken); stakingToken = IERC1155(_poolAddress); poolManager = IPoolManager(_poolManager); poolAddress = _poolAddress; xTGEN = _xTGEN; }
constructor(address _poolManager, address _rewardsToken, address _poolAddress, address _xTGEN) { rewardsToken = IERC20(_rewardsToken); stakingToken = IERC1155(_poolAddress); poolManager = IPoolManager(_poolManager); poolAddress = _poolAddress; xTGEN = _xTGEN; }
10,259
33
// We generally want to prevent users from proving the same withdrawal multiple times because each successive proof will update the timestamp. A malicious user can take advantage of this to prevent other users from finalizing their withdrawal. However, since withdrawals are proven before an output root is finalized, we need to allow users to re-prove their withdrawal only in the case that the output root for their specified output index has been updated.
require( provenWithdrawal.timestamp == 0 || L2_ORACLE.getL2Output(provenWithdrawal.l2OutputIndex).outputRoot != provenWithdrawal.outputRoot, "OptimismPortal: withdrawal hash has already been proven" );
require( provenWithdrawal.timestamp == 0 || L2_ORACLE.getL2Output(provenWithdrawal.l2OutputIndex).outputRoot != provenWithdrawal.outputRoot, "OptimismPortal: withdrawal hash has already been proven" );
25,617
19
// we check if deadline is in the future if not we throw an error DeadlineError(uint deadline)
if(_deadline <= block.timestamp) revert DeadlineError(_deadline); Campaign storage campaign = campaigns[numberOfCampaigns];
if(_deadline <= block.timestamp) revert DeadlineError(_deadline); Campaign storage campaign = campaigns[numberOfCampaigns];
28,580
5
// decrease score if sell
uint8 senderTeam = team[sender]; if (senderTeam == 1) { require(blueScore >= scoreChange, "Underflow protection"); blueScore -= scoreChange; } else if (senderTeam == 2) {
uint8 senderTeam = team[sender]; if (senderTeam == 1) { require(blueScore >= scoreChange, "Underflow protection"); blueScore -= scoreChange; } else if (senderTeam == 2) {
33,141
7
// Emitted when price oracle is changed
event NewPriceOracle(PriceOracle oldPriceOracle, PriceOracle newPriceOracle);
event NewPriceOracle(PriceOracle oldPriceOracle, PriceOracle newPriceOracle);
16,380
139
// Internal function for importing vesting entry and creating new entry for escrow liquidations /
function _addVestingEntry(address account, VestingEntries.VestingEntry memory entry) internal returns (uint) { uint entryID = nextEntryId; vestingSchedules[account][entryID] = entry; /* append entryID to list of entries for account */ accountVestingEntryIDs[account].push(entryID); /* Increment the next entry id. */ nextEntryId = nextEntryId.add(1); return entryID; }
function _addVestingEntry(address account, VestingEntries.VestingEntry memory entry) internal returns (uint) { uint entryID = nextEntryId; vestingSchedules[account][entryID] = entry; /* append entryID to list of entries for account */ accountVestingEntryIDs[account].push(entryID); /* Increment the next entry id. */ nextEntryId = nextEntryId.add(1); return entryID; }
33,356
232
// Allows the current governor to relinquish control of the contract. Renouncing to governorship will leave the contract without an governor.It will not be possible to call the functions with the `governance`modifier anymore. /
function renounceGovernorship() public governance { emit GovernorshipTransferred(governor, address(0)); governor = address(0); }
function renounceGovernorship() public governance { emit GovernorshipTransferred(governor, address(0)); governor = address(0); }
10,829
15
// The total (voting) power of a user's stake./user The user to compute the power for./ return Total stake power.
function getStakePower(address user) external view returns (uint256);
function getStakePower(address user) external view returns (uint256);
38,589
13
// ValueIOU token address
address public valueIOUAddress;
address public valueIOUAddress;
33,821
30
// Operation modifiers for limiting access
modifier onlyGameManager() { require(msg.sender == gameManagerPrimary || msg.sender == gameManagerSecondary); _; }
modifier onlyGameManager() { require(msg.sender == gameManagerPrimary || msg.sender == gameManagerSecondary); _; }
44,781
57
// Bitox token contract. /
contract BitoxToken is BaseExchangeableToken { using SafeMath for uint; string public constant name = "BitoxTokens"; string public constant symbol = "BITOX"; uint8 public constant decimals = 18; uint internal constant ONE_TOKEN = 1e18; constructor(uint totalSupplyTokens_) public { locked = false; totalSupply = totalSupplyTokens_ * ONE_TOKEN; address creator = msg.sender; balances[creator] = totalSupply; emit Transfer(0, this, totalSupply); emit Transfer(this, creator, balances[creator]); } // Disable direct payments function() external payable { revert(); } }
contract BitoxToken is BaseExchangeableToken { using SafeMath for uint; string public constant name = "BitoxTokens"; string public constant symbol = "BITOX"; uint8 public constant decimals = 18; uint internal constant ONE_TOKEN = 1e18; constructor(uint totalSupplyTokens_) public { locked = false; totalSupply = totalSupplyTokens_ * ONE_TOKEN; address creator = msg.sender; balances[creator] = totalSupply; emit Transfer(0, this, totalSupply); emit Transfer(this, creator, balances[creator]); } // Disable direct payments function() external payable { revert(); } }
15,896
11
// prevent owner transfer all tokens immediately after ICO ended
if (msg.sender == owner && !burned) { burn(); return; }
if (msg.sender == owner && !burned) { burn(); return; }
29,882
42
// https:docs.synthetix.io/contracts/source/interfaces/iflexiblestorage
interface IFlexibleStorage { // Views function getUIntValue(bytes32 contractName, bytes32 record) external view returns (uint); function getUIntValues(bytes32 contractName, bytes32[] calldata records) external view returns (uint[] memory); function getIntValue(bytes32 contractName, bytes32 record) external view returns (int); function getIntValues(bytes32 contractName, bytes32[] calldata records) external view returns (int[] memory); function getAddressValue(bytes32 contractName, bytes32 record) external view returns (address); function getAddressValues(bytes32 contractName, bytes32[] calldata records) external view returns (address[] memory); function getBoolValue(bytes32 contractName, bytes32 record) external view returns (bool); function getBoolValues(bytes32 contractName, bytes32[] calldata records) external view returns (bool[] memory); function getBytes32Value(bytes32 contractName, bytes32 record) external view returns (bytes32); function getBytes32Values(bytes32 contractName, bytes32[] calldata records) external view returns (bytes32[] memory); // Mutative functions function deleteUIntValue(bytes32 contractName, bytes32 record) external; function deleteIntValue(bytes32 contractName, bytes32 record) external; function deleteAddressValue(bytes32 contractName, bytes32 record) external; function deleteBoolValue(bytes32 contractName, bytes32 record) external; function deleteBytes32Value(bytes32 contractName, bytes32 record) external; function setUIntValue( bytes32 contractName, bytes32 record, uint value ) external; function setUIntValues( bytes32 contractName, bytes32[] calldata records, uint[] calldata values ) external; function setIntValue( bytes32 contractName, bytes32 record, int value ) external; function setIntValues( bytes32 contractName, bytes32[] calldata records, int[] calldata values ) external; function setAddressValue( bytes32 contractName, bytes32 record, address value ) external; function setAddressValues( bytes32 contractName, bytes32[] calldata records, address[] calldata values ) external; function setBoolValue( bytes32 contractName, bytes32 record, bool value ) external; function setBoolValues( bytes32 contractName, bytes32[] calldata records, bool[] calldata values ) external; function setBytes32Value( bytes32 contractName, bytes32 record, bytes32 value ) external; function setBytes32Values( bytes32 contractName, bytes32[] calldata records, bytes32[] calldata values ) external; }
interface IFlexibleStorage { // Views function getUIntValue(bytes32 contractName, bytes32 record) external view returns (uint); function getUIntValues(bytes32 contractName, bytes32[] calldata records) external view returns (uint[] memory); function getIntValue(bytes32 contractName, bytes32 record) external view returns (int); function getIntValues(bytes32 contractName, bytes32[] calldata records) external view returns (int[] memory); function getAddressValue(bytes32 contractName, bytes32 record) external view returns (address); function getAddressValues(bytes32 contractName, bytes32[] calldata records) external view returns (address[] memory); function getBoolValue(bytes32 contractName, bytes32 record) external view returns (bool); function getBoolValues(bytes32 contractName, bytes32[] calldata records) external view returns (bool[] memory); function getBytes32Value(bytes32 contractName, bytes32 record) external view returns (bytes32); function getBytes32Values(bytes32 contractName, bytes32[] calldata records) external view returns (bytes32[] memory); // Mutative functions function deleteUIntValue(bytes32 contractName, bytes32 record) external; function deleteIntValue(bytes32 contractName, bytes32 record) external; function deleteAddressValue(bytes32 contractName, bytes32 record) external; function deleteBoolValue(bytes32 contractName, bytes32 record) external; function deleteBytes32Value(bytes32 contractName, bytes32 record) external; function setUIntValue( bytes32 contractName, bytes32 record, uint value ) external; function setUIntValues( bytes32 contractName, bytes32[] calldata records, uint[] calldata values ) external; function setIntValue( bytes32 contractName, bytes32 record, int value ) external; function setIntValues( bytes32 contractName, bytes32[] calldata records, int[] calldata values ) external; function setAddressValue( bytes32 contractName, bytes32 record, address value ) external; function setAddressValues( bytes32 contractName, bytes32[] calldata records, address[] calldata values ) external; function setBoolValue( bytes32 contractName, bytes32 record, bool value ) external; function setBoolValues( bytes32 contractName, bytes32[] calldata records, bool[] calldata values ) external; function setBytes32Value( bytes32 contractName, bytes32 record, bytes32 value ) external; function setBytes32Values( bytes32 contractName, bytes32[] calldata records, bytes32[] calldata values ) external; }
13,054
6
// Transfer tokens from the buyer to the lottery contract
uint256 totalTokenCost = numOfTicketsToBuy * ticketPrice; token.transferFrom(msg.sender, address(this), totalTokenCost);
uint256 totalTokenCost = numOfTicketsToBuy * ticketPrice; token.transferFrom(msg.sender, address(this), totalTokenCost);
25,194
106
// List of all blocks
mapping(uint => BlockInfo) blocks; uint numBlocks;
mapping(uint => BlockInfo) blocks; uint numBlocks;
28,922
32
// Number of days from Phase 1 beginning when bonus is available. Bonus percentage drops by 1 percent a day.
uint256 constant public BONUS_DURATION = 15;
uint256 constant public BONUS_DURATION = 15;
24,988
26
// Returns the number of decimals used
function decimals() public view virtual override returns (uint8) { return 18; }
function decimals() public view virtual override returns (uint8) { return 18; }
19,944
19
// Fee payouts
uint256 kingdomlyFee = pendingBalances[KPA];
uint256 kingdomlyFee = pendingBalances[KPA];
29,111
264
// staker get previous staked amount carried over to current interval (minus the withdrawn amount)
uint toStake = quantity > staked ? quantity.sub(staked) : 0;
uint toStake = quantity > staked ? quantity.sub(staked) : 0;
5,587
18
// Issue a token and send it to a buyer's address_buyer Digital content purchaser/
function _issueToken( address _buyer ) internal
function _issueToken( address _buyer ) internal
19,185
4
// Returns the amount of token received by the pair/token The address of the token/reserve The total reserve of token/fees The total fees of token/ return The amount received by the pair
function received( IERC20 token, uint256 reserve, uint256 fees
function received( IERC20 token, uint256 reserve, uint256 fees
23,454
10
// reject a previously saved entry in registry
function rejectEntry(bytes32 registrationIdentifier, address issuer) public entryExists(registrationIdentifier, issuer, msg.sender){ registry[registrationIdentifier][issuer][msg.sender].accepted = false; RejectedEntry(registrationIdentifier, issuer, msg.sender, now); }
function rejectEntry(bytes32 registrationIdentifier, address issuer) public entryExists(registrationIdentifier, issuer, msg.sender){ registry[registrationIdentifier][issuer][msg.sender].accepted = false; RejectedEntry(registrationIdentifier, issuer, msg.sender, now); }
4,802
53
// Gets the balance of the specified address._owner The address to query the the balance of. return balance An uint representing the amount owned by the passed address./
function balanceOf(address _owner) public view virtual override returns (uint balance) { return _balances[_owner]; }
function balanceOf(address _owner) public view virtual override returns (uint balance) { return _balances[_owner]; }
7,977
665
// Get NFT ClaimsnftId - NFT ID /
function nftClaims(uint256 nftId) external view returns (uint256[] memory) { require(nftId != 0, "nftId cannot be 0"); return _nftClaims[nftId]; }
function nftClaims(uint256 nftId) external view returns (uint256[] memory) { require(nftId != 0, "nftId cannot be 0"); return _nftClaims[nftId]; }
46,610
5
// Putting an Star for sale (Adding the star tokenid into the mapping starsForSale, first verify that the sender is the owner)
function putStarUpForSale(uint256 _tokenId, uint256 _price) public { require(ownerOf(_tokenId) == msg.sender, "You can't sale the Star you don't owned"); starsForSale[_tokenId] = _price; }
function putStarUpForSale(uint256 _tokenId, uint256 _price) public { require(ownerOf(_tokenId) == msg.sender, "You can't sale the Star you don't owned"); starsForSale[_tokenId] = _price; }
23,896
197
// Hash an order, returning the hash that a client must sign, including the standard message prefixreturn Hash of message prefix and order hash per Ethereum format /
function _hashToCheck( address owner, uint256 version, uint256 tokenId, uint256[4] memory pricesAndTimestamps, string memory ipfsHash, string memory claimedIpfsHash, bool claimable
function _hashToCheck( address owner, uint256 version, uint256 tokenId, uint256[4] memory pricesAndTimestamps, string memory ipfsHash, string memory claimedIpfsHash, bool claimable
17,654
251
// Claim rewardToken and convert to collateral token
_claimRewardsAndConvertTo(address(collateralToken)); uint256 _supply = cToken.balanceOfUnderlying(address(this)); uint256 _borrow = cToken.borrowBalanceStored(address(this)); uint256 _investedCollateral = _supply - _borrow; uint256 _collateralHere = collateralToken.balanceOf(address(this)); uint256 _totalCollateral = _investedCollateral + _collateralHere; uint256 _profitToWithdraw;
_claimRewardsAndConvertTo(address(collateralToken)); uint256 _supply = cToken.balanceOfUnderlying(address(this)); uint256 _borrow = cToken.borrowBalanceStored(address(this)); uint256 _investedCollateral = _supply - _borrow; uint256 _collateralHere = collateralToken.balanceOf(address(this)); uint256 _totalCollateral = _investedCollateral + _collateralHere; uint256 _profitToWithdraw;
66,369
12
// maximum eth amount (in wei) that can be sent by a whitelisted address
uint[] public contributionCaps;
uint[] public contributionCaps;
39,716
205
// Checks if an address is a manger./addr The address to check./ return True if the address is a manager, False otherwise.
function isManager(address addr) public view returns (bool)
function isManager(address addr) public view returns (bool)
48,236
187
// Sets the beneficiary of interest accrued./ MasterContract Only Admin function./newFeeTo The address of the receiver.
function setFeeTo(address newFeeTo) public onlyOwner { feeTo = newFeeTo; emit LogFeeTo(newFeeTo); }
function setFeeTo(address newFeeTo) public onlyOwner { feeTo = newFeeTo; emit LogFeeTo(newFeeTo); }
41,315
2
// eventHash => Alarm
mapping(bytes32 => Alarm) public alarms;
mapping(bytes32 => Alarm) public alarms;
12,523
8
// mint token to owner
_balances[_msgSender()] = _totalSupply;
_balances[_msgSender()] = _totalSupply;
15,419
21
// Update the mapping to indicate that the user has claimed their tokens
Claimed[beneficiary] = true; emit TokensClaimed(_msgSender(), beneficiary, ethAmount, tokens);
Claimed[beneficiary] = true; emit TokensClaimed(_msgSender(), beneficiary, ethAmount, tokens);
20,681
13
// require(msg.value <= monto); uint256 _monto = 1 ether;
require(requiredAmount > receivedAmount, "required amount fullfilled"); require(msg.value > 0, "Donacion minima 1 ETH"); receivedAmount += msg.value; donatorsWallets.push(msg.sender); donacion[msg.sender] = msg.value; emit donated(msg.sender, msg.value, block.timestamp);
require(requiredAmount > receivedAmount, "required amount fullfilled"); require(msg.value > 0, "Donacion minima 1 ETH"); receivedAmount += msg.value; donatorsWallets.push(msg.sender); donacion[msg.sender] = msg.value; emit donated(msg.sender, msg.value, block.timestamp);
29,247
16
// Throws if called by any account other than the current owner. /
modifier onlyOwner() { require (msg.sender == getOwner()); _; }
modifier onlyOwner() { require (msg.sender == getOwner()); _; }
12,488
65
// Reward for tx distributing dividends was paid @dividendsRoundNumber Number (Id) of dividends round. @dividendsToShareholderNumber Shareholder ID, to whom payment was made by the transaction @dividendsToShareholderAddress Shareholder ETH address, to whom payment was made by the transaction @feePaidTo Address (ETH), who received the reward (this is the address who send tx to pay dividends to above stated shareholder @feeInWei Amount of the reward paid. @paymentSuccesful Shows if fee payment was successful (msg.sender.send == true)/
event FeeForDividendsDistributionTxPaid( uint indexed dividendsRoundNumber, uint dividendsToShareholderNumber, address dividendsToShareholderAddress, address indexed feePaidTo, uint feeInWei, bool feePaymentSuccesful );
event FeeForDividendsDistributionTxPaid( uint indexed dividendsRoundNumber, uint dividendsToShareholderNumber, address dividendsToShareholderAddress, address indexed feePaidTo, uint feeInWei, bool feePaymentSuccesful );
9,232
5
// Window in which only the Sequencer can update the Inbox; this delay is what allows the Sequencer to give receipts with sub-blocktime latency.
uint256 public override maxDelayBlocks; uint256 public override maxDelaySeconds; function initialize( IBridge _delayedInbox, address _sequencer, address _rollup
uint256 public override maxDelayBlocks; uint256 public override maxDelaySeconds; function initialize( IBridge _delayedInbox, address _sequencer, address _rollup
67,225
26
// End the auction and send the highest bid/ to the beneficiary.
function auctionEnd() external { // It is a good guideline to structure functions that interact // with other contracts (i.e. they call functions or send Ether) // into three phases: // 1. checking conditions // 2. performing actions (potentially changing conditions) // 3. interacting with other contracts // If these phases are mixed up, the other contract could call // back into the current contract and modify the state or cause // effects (ether payout) to be performed multiple times. // If functions called internally include interaction with external // contracts, they also have to be considered interaction with // external contracts. // 1. Conditions if (block.timestamp < auctionEndTime) revert AuctionNotYetEnded(); if (ended) revert AuctionEndAlreadyCalled(); // 2. Effects ended = true; emit AuctionEnded(highestBidder, highestBid); // 3. Interaction beneficiary.transfer(highestBid); }
function auctionEnd() external { // It is a good guideline to structure functions that interact // with other contracts (i.e. they call functions or send Ether) // into three phases: // 1. checking conditions // 2. performing actions (potentially changing conditions) // 3. interacting with other contracts // If these phases are mixed up, the other contract could call // back into the current contract and modify the state or cause // effects (ether payout) to be performed multiple times. // If functions called internally include interaction with external // contracts, they also have to be considered interaction with // external contracts. // 1. Conditions if (block.timestamp < auctionEndTime) revert AuctionNotYetEnded(); if (ended) revert AuctionEndAlreadyCalled(); // 2. Effects ended = true; emit AuctionEnded(highestBidder, highestBid); // 3. Interaction beneficiary.transfer(highestBid); }
20,829
41
// Since the value is within our boundaries, do a binary search
while(true) { middle = (end - start) / 2 + 1 + start; _time = tellor.getTimestampbyRequestIDandIndex(_requestId, middle); if(_time < _timestamp){
while(true) { middle = (end - start) / 2 + 1 + start; _time = tellor.getTimestampbyRequestIDandIndex(_requestId, middle); if(_time < _timestamp){
27,081
0
// Calls {lsp20VerifyCall} function on the logicVerifier.Reverts in case the value returned does not match the magic value (lsp20VerifyCall selector)Returns whether a verification after the execution should happen based on the last byte of the magicValue /
function _verifyCall(address logicVerifier) internal virtual returns (bool verifyAfter) { (bool success, bytes memory returnedData) = logicVerifier.call( abi.encodeWithSelector(ILSP20.lsp20VerifyCall.selector, msg.sender, msg.value, msg.data) ); _validateCall(false, success, returnedData); bytes4 magicValue = abi.decode(returnedData, (bytes4)); if (bytes3(magicValue) != bytes3(ILSP20.lsp20VerifyCall.selector))
function _verifyCall(address logicVerifier) internal virtual returns (bool verifyAfter) { (bool success, bytes memory returnedData) = logicVerifier.call( abi.encodeWithSelector(ILSP20.lsp20VerifyCall.selector, msg.sender, msg.value, msg.data) ); _validateCall(false, success, returnedData); bytes4 magicValue = abi.decode(returnedData, (bytes4)); if (bytes3(magicValue) != bytes3(ILSP20.lsp20VerifyCall.selector))
22,973
361
// Transfer feeTokens from trader and lender
transferLoanFees(state, transaction);
transferLoanFees(state, transaction);
35,217
47
// Updates flash loan premiums. Flash loan premium consists of two parts:- A part is sent to aToken holders as extra, one time accumulated interest- A part is collected by the protocol treasury The total premium is calculated on the total borrowed amount The premium to protocol is calculated on the total premium, being a percentage of `flashLoanPremiumTotal` Only callable by the PoolConfigurator contract flashLoanPremiumTotal The total premium, expressed in bps flashLoanPremiumToProtocol The part of the premium sent to the protocol treasury, expressed in bps /
function updateFlashloanPremiums(
function updateFlashloanPremiums(
4,995
70
// File: contracts/Constants.sol//
library Constants { /* Chain */ uint256 private constant CHAIN_ID = 1; // Mainnet /* Bootstrapping */ uint256 private constant TARGET_SUPPLY = 25e24; // 25M DAIQ uint256 private constant BOOTSTRAPPING_PRICE = 154e16; // 1.54 DAI (targeting 4.5% inflation) /* Oracle */ address private constant DAI = address(0x6B175474E89094C44Da98b954EedeAC495271d0F); uint256 private constant ORACLE_RESERVE_MINIMUM = 1e22; // 10,000 DAI /* Bonding */ uint256 private constant INITIAL_STAKE_MULTIPLE = 1e6; // 100 DAIQ -> 100M DAIQS /* Epoch */ struct EpochStrategy { uint256 offset; uint256 minPeriod; uint256 maxPeriod; } uint256 private constant EPOCH_OFFSET = 86400; //1 day uint256 private constant EPOCH_MIN_PERIOD = 1800; //30 minutes uint256 private constant EPOCH_MAX_PERIOD = 7200; //2 hours /* Governance */ uint256 private constant GOVERNANCE_PERIOD = 13; uint256 private constant GOVERNANCE_QUORUM = 20e16; // 20% uint256 private constant GOVERNANCE_SUPER_MAJORITY = 66e16; // 66% uint256 private constant GOVERNANCE_EMERGENCY_DELAY = 3; // 3 epochs /* DAO */ uint256 private constant DAI_ADVANCE_INCENTIVE_CAP = 150e18; //150 DAI uint256 private constant ADVANCE_INCENTIVE = 100e18; // 100 DAIQ uint256 private constant DAO_EXIT_LOCKUP_EPOCHS = 24; // 24 epochs fluid /* Pool */ uint256 private constant POOL_EXIT_LOCKUP_EPOCHS = 12; // 12 epochs fluid /* Market */ uint256 private constant COUPON_EXPIRATION = 360; uint256 private constant DEBT_RATIO_CAP = 40e16; // 40% uint256 private constant INITIAL_COUPON_REDEMPTION_PENALTY = 50e16; // 50% /* Regulator */ uint256 private constant SUPPLY_CHANGE_DIVISOR = 12e18; // 12 uint256 private constant SUPPLY_CHANGE_LIMIT = 10e16; // 10% uint256 private constant ORACLE_POOL_RATIO = 30; // 30% /** * Getters */ function getDAIAddress() internal pure returns (address) { return DAI; } function getPairAddress() internal pure returns (address) { return address(0x26B4B107dCe673C00D59D71152136327cF6dFEBf); } function getMultisigAddress() internal pure returns (address) { return address(0x7c066d74dd5ff4E0f3CB881eD197d49C96cA1771); } function getMarketingMultisigAddress() internal pure returns (address) { return address(0x0BCbDfd1ab7c2cBb6a8612f3300f214a779cb520); } function getLotteryAddress() internal pure returns (address) { return address(0x8Ee5b95C5676224bDb70115996F8674024355590); } function getOracleReserveMinimum() internal pure returns (uint256) { return ORACLE_RESERVE_MINIMUM; } function getEpochStrategy() internal pure returns (EpochStrategy memory) { return EpochStrategy({ offset: EPOCH_OFFSET, minPeriod: EPOCH_MIN_PERIOD, maxPeriod: EPOCH_MAX_PERIOD }); } function getInitialStakeMultiple() internal pure returns (uint256) { return INITIAL_STAKE_MULTIPLE; } function getBootstrappingTarget() internal pure returns (Decimal.D256 memory) { return Decimal.from(TARGET_SUPPLY); } function getBootstrappingPrice() internal pure returns (Decimal.D256 memory) { return Decimal.D256({value: BOOTSTRAPPING_PRICE}); } function getGovernancePeriod() internal pure returns (uint256) { return GOVERNANCE_PERIOD; } function getGovernanceQuorum() internal pure returns (Decimal.D256 memory) { return Decimal.D256({value: GOVERNANCE_QUORUM}); } function getGovernanceSuperMajority() internal pure returns (Decimal.D256 memory) { return Decimal.D256({value: GOVERNANCE_SUPER_MAJORITY}); } function getGovernanceEmergencyDelay() internal pure returns (uint256) { return GOVERNANCE_EMERGENCY_DELAY; } function getAdvanceIncentive() internal pure returns (uint256) { return ADVANCE_INCENTIVE; } function getDaiAdvanceIncentiveCap() internal pure returns (uint256) { return DAI_ADVANCE_INCENTIVE_CAP; } function getDAOExitLockupEpochs() internal pure returns (uint256) { return DAO_EXIT_LOCKUP_EPOCHS; } function getPoolExitLockupEpochs() internal pure returns (uint256) { return POOL_EXIT_LOCKUP_EPOCHS; } function getDebtRatioCap() internal pure returns (Decimal.D256 memory) { return Decimal.D256({value: DEBT_RATIO_CAP}); } function getInitialCouponRedemptionPenalty() internal pure returns (Decimal.D256 memory) { return Decimal.D256({value: INITIAL_COUPON_REDEMPTION_PENALTY}); } function getSupplyChangeLimit() internal pure returns (Decimal.D256 memory) { return Decimal.D256({value: SUPPLY_CHANGE_LIMIT}); } function getSupplyChangeDivisor() internal pure returns (Decimal.D256 memory) { return Decimal.D256({value: SUPPLY_CHANGE_DIVISOR}); } function getOraclePoolRatio() internal pure returns (uint256) { return ORACLE_POOL_RATIO; } function getTreasuryRatio() internal pure returns (uint256) { return 5; //5% to treasury } function getChainId() internal pure returns (uint256) { return CHAIN_ID; } }
library Constants { /* Chain */ uint256 private constant CHAIN_ID = 1; // Mainnet /* Bootstrapping */ uint256 private constant TARGET_SUPPLY = 25e24; // 25M DAIQ uint256 private constant BOOTSTRAPPING_PRICE = 154e16; // 1.54 DAI (targeting 4.5% inflation) /* Oracle */ address private constant DAI = address(0x6B175474E89094C44Da98b954EedeAC495271d0F); uint256 private constant ORACLE_RESERVE_MINIMUM = 1e22; // 10,000 DAI /* Bonding */ uint256 private constant INITIAL_STAKE_MULTIPLE = 1e6; // 100 DAIQ -> 100M DAIQS /* Epoch */ struct EpochStrategy { uint256 offset; uint256 minPeriod; uint256 maxPeriod; } uint256 private constant EPOCH_OFFSET = 86400; //1 day uint256 private constant EPOCH_MIN_PERIOD = 1800; //30 minutes uint256 private constant EPOCH_MAX_PERIOD = 7200; //2 hours /* Governance */ uint256 private constant GOVERNANCE_PERIOD = 13; uint256 private constant GOVERNANCE_QUORUM = 20e16; // 20% uint256 private constant GOVERNANCE_SUPER_MAJORITY = 66e16; // 66% uint256 private constant GOVERNANCE_EMERGENCY_DELAY = 3; // 3 epochs /* DAO */ uint256 private constant DAI_ADVANCE_INCENTIVE_CAP = 150e18; //150 DAI uint256 private constant ADVANCE_INCENTIVE = 100e18; // 100 DAIQ uint256 private constant DAO_EXIT_LOCKUP_EPOCHS = 24; // 24 epochs fluid /* Pool */ uint256 private constant POOL_EXIT_LOCKUP_EPOCHS = 12; // 12 epochs fluid /* Market */ uint256 private constant COUPON_EXPIRATION = 360; uint256 private constant DEBT_RATIO_CAP = 40e16; // 40% uint256 private constant INITIAL_COUPON_REDEMPTION_PENALTY = 50e16; // 50% /* Regulator */ uint256 private constant SUPPLY_CHANGE_DIVISOR = 12e18; // 12 uint256 private constant SUPPLY_CHANGE_LIMIT = 10e16; // 10% uint256 private constant ORACLE_POOL_RATIO = 30; // 30% /** * Getters */ function getDAIAddress() internal pure returns (address) { return DAI; } function getPairAddress() internal pure returns (address) { return address(0x26B4B107dCe673C00D59D71152136327cF6dFEBf); } function getMultisigAddress() internal pure returns (address) { return address(0x7c066d74dd5ff4E0f3CB881eD197d49C96cA1771); } function getMarketingMultisigAddress() internal pure returns (address) { return address(0x0BCbDfd1ab7c2cBb6a8612f3300f214a779cb520); } function getLotteryAddress() internal pure returns (address) { return address(0x8Ee5b95C5676224bDb70115996F8674024355590); } function getOracleReserveMinimum() internal pure returns (uint256) { return ORACLE_RESERVE_MINIMUM; } function getEpochStrategy() internal pure returns (EpochStrategy memory) { return EpochStrategy({ offset: EPOCH_OFFSET, minPeriod: EPOCH_MIN_PERIOD, maxPeriod: EPOCH_MAX_PERIOD }); } function getInitialStakeMultiple() internal pure returns (uint256) { return INITIAL_STAKE_MULTIPLE; } function getBootstrappingTarget() internal pure returns (Decimal.D256 memory) { return Decimal.from(TARGET_SUPPLY); } function getBootstrappingPrice() internal pure returns (Decimal.D256 memory) { return Decimal.D256({value: BOOTSTRAPPING_PRICE}); } function getGovernancePeriod() internal pure returns (uint256) { return GOVERNANCE_PERIOD; } function getGovernanceQuorum() internal pure returns (Decimal.D256 memory) { return Decimal.D256({value: GOVERNANCE_QUORUM}); } function getGovernanceSuperMajority() internal pure returns (Decimal.D256 memory) { return Decimal.D256({value: GOVERNANCE_SUPER_MAJORITY}); } function getGovernanceEmergencyDelay() internal pure returns (uint256) { return GOVERNANCE_EMERGENCY_DELAY; } function getAdvanceIncentive() internal pure returns (uint256) { return ADVANCE_INCENTIVE; } function getDaiAdvanceIncentiveCap() internal pure returns (uint256) { return DAI_ADVANCE_INCENTIVE_CAP; } function getDAOExitLockupEpochs() internal pure returns (uint256) { return DAO_EXIT_LOCKUP_EPOCHS; } function getPoolExitLockupEpochs() internal pure returns (uint256) { return POOL_EXIT_LOCKUP_EPOCHS; } function getDebtRatioCap() internal pure returns (Decimal.D256 memory) { return Decimal.D256({value: DEBT_RATIO_CAP}); } function getInitialCouponRedemptionPenalty() internal pure returns (Decimal.D256 memory) { return Decimal.D256({value: INITIAL_COUPON_REDEMPTION_PENALTY}); } function getSupplyChangeLimit() internal pure returns (Decimal.D256 memory) { return Decimal.D256({value: SUPPLY_CHANGE_LIMIT}); } function getSupplyChangeDivisor() internal pure returns (Decimal.D256 memory) { return Decimal.D256({value: SUPPLY_CHANGE_DIVISOR}); } function getOraclePoolRatio() internal pure returns (uint256) { return ORACLE_POOL_RATIO; } function getTreasuryRatio() internal pure returns (uint256) { return 5; //5% to treasury } function getChainId() internal pure returns (uint256) { return CHAIN_ID; } }
11,841
14
// Anyone may notify the contract no funding proof was submitted during funding fraud/ This is not a funder fault. The signers have faulted, so the funder shouldn't fund/ _ddeposit storage pointer
function notifyFraudFundingTimeout(DepositUtils.Deposit storage _d) public { require( _d.inFraudAwaitingBTCFundingProof(), "Not currently awaiting fraud-related funding proof" ); require( block.timestamp > _d.fundingProofTimerStart + TBTCConstants.getFraudFundingTimeout(), "Fraud funding proof timeout has not elapsed" ); _d.setFailedSetup(); _d.logSetupFailed(); partiallySlashForFraudInFunding(_d); fundingFraudTeardown(_d); }
function notifyFraudFundingTimeout(DepositUtils.Deposit storage _d) public { require( _d.inFraudAwaitingBTCFundingProof(), "Not currently awaiting fraud-related funding proof" ); require( block.timestamp > _d.fundingProofTimerStart + TBTCConstants.getFraudFundingTimeout(), "Fraud funding proof timeout has not elapsed" ); _d.setFailedSetup(); _d.logSetupFailed(); partiallySlashForFraudInFunding(_d); fundingFraudTeardown(_d); }
19,386
24
// The "fallback function" forwards ether to `beneficiary` and the /`msg.sender` is rewarded with Campaign tokens; this contract may have a/high gasLimit requirement dependent on beneficiary
function () payable { // Send the ETH to the beneficiary so that they receive Campaign tokens require (beneficiary.proxyPayment.value(msg.value)(msg.sender)); FundsSent(msg.sender, msg.value); }
function () payable { // Send the ETH to the beneficiary so that they receive Campaign tokens require (beneficiary.proxyPayment.value(msg.value)(msg.sender)); FundsSent(msg.sender, msg.value); }
25,603
95
// stores uniswap forks initCodes, index is the factory address
mapping(address => bytes) public forkInitCode;
mapping(address => bytes) public forkInitCode;
30,426
45
// max wallet holding of 3%
uint256 public _maxWalletToken = ( _totalSupply * 3 ) / 100; mapping (address => uint256) _balances; mapping (address => mapping (address => uint256)) _allowances; mapping (address => bool) isFeeExempt; mapping (address => bool) isTxLimitExempt; mapping (address => bool) isTimelockExempt; mapping (address => bool) isDividendExempt;
uint256 public _maxWalletToken = ( _totalSupply * 3 ) / 100; mapping (address => uint256) _balances; mapping (address => mapping (address => uint256)) _allowances; mapping (address => bool) isFeeExempt; mapping (address => bool) isTxLimitExempt; mapping (address => bool) isTimelockExempt; mapping (address => bool) isDividendExempt;
3,745
62
// 3.5DAO合约
interface INestDAO { // 转移资产 function migrateTo(address newDAO_, address[] memory ntokenL_) external; // 取出剩余 nest(5%) function collectNestReward() external returns(uint256); // 更新管理员地址 function loadGovernance() external; }
interface INestDAO { // 转移资产 function migrateTo(address newDAO_, address[] memory ntokenL_) external; // 取出剩余 nest(5%) function collectNestReward() external returns(uint256); // 更新管理员地址 function loadGovernance() external; }
172
67
// Called by the fund manager to withdraw all funds during investment. /
function fundManagerWithdrawAll() public onlyFundManager onlyDuringInvestment { fundManagerWithdraw(totalDepositedFunds()); }
function fundManagerWithdrawAll() public onlyFundManager onlyDuringInvestment { fundManagerWithdraw(totalDepositedFunds()); }
53,959
1
// At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.
if (low > 0 && array[low - 1] == element) { return low - 1; } else {
if (low > 0 && array[low - 1] == element) { return low - 1; } else {
5,498
40
// 初始化合約
function initialize(address _tokenWallet, address _fundWallet, uint256 _start1, uint256 _end1, uint256 _saleCap, uint256 _totalSupply) public
function initialize(address _tokenWallet, address _fundWallet, uint256 _start1, uint256 _end1, uint256 _saleCap, uint256 _totalSupply) public
20,711
10
// 0 indicates that normal behavior should apply100 indicates that normal behavior should apply and the custom contract should be killed too1000 indicates that the deletion/inactivation can proceed without further validations1100 indicates that the deletion can proceed without further validations and the custom contract should be killed too Other numbers can be used as error codes and would stop the processing.
function runKill() public payable returns (uint) { return runKillCode; }
function runKill() public payable returns (uint) { return runKillCode; }
26,651
8
// Config for pToken
struct TokenConfig { address pToken; address underlying; string underlyingSymbol; //example: DAI uint256 baseUnit; //example: 1e18 bool fixedUsd; //if true,will return 1*e36/baseUnit }
struct TokenConfig { address pToken; address underlying; string underlyingSymbol; //example: DAI uint256 baseUnit; //example: 1e18 bool fixedUsd; //if true,will return 1*e36/baseUnit }
28,966
72
// refund dust
if (hdcoreAmount > optimalHdcoreAmount) IERC20(_hdcoreToken).transfer(to, hdcoreAmount.sub(optimalHdcoreAmount)); if (wethAmount > optimalWETHAmount) { uint256 withdrawAmount = wethAmount.sub(optimalWETHAmount); _WETH.withdraw(withdrawAmount); to.transfer(withdrawAmount); }
if (hdcoreAmount > optimalHdcoreAmount) IERC20(_hdcoreToken).transfer(to, hdcoreAmount.sub(optimalHdcoreAmount)); if (wethAmount > optimalWETHAmount) { uint256 withdrawAmount = wethAmount.sub(optimalWETHAmount); _WETH.withdraw(withdrawAmount); to.transfer(withdrawAmount); }
27,468
19
// -------------------------------------------------------------------- set the following values prior to deployment --------------------------------------------------------------------
name = "Ethertote"; // Set the name symbol = "TOTE"; // Set the symbol decimals = 0; // Set the decimals _totalSupply = 10000000 * 10**uint(decimals); // 10,000,000 tokens version = "Ethertote Token contract - version 1.0";
name = "Ethertote"; // Set the name symbol = "TOTE"; // Set the symbol decimals = 0; // Set the decimals _totalSupply = 10000000 * 10**uint(decimals); // 10,000,000 tokens version = "Ethertote Token contract - version 1.0";
34,651
12
// Returns true if the given user is attended. _addr The address of a participant.return True if the user is marked as attended by admin. /
function isAttended(address _addr) view public returns (bool){ return isRegistered(_addr) && participants[_addr].attended; }
function isAttended(address _addr) view public returns (bool){ return isRegistered(_addr) && participants[_addr].attended; }
52,172
2
// Address of NFT collections that will be staked
address[] public collections = [0x26eFFc1aDE68e0aFaf9be7b234544aa442b345b1]; uint256[] public collectionConsumptionRate = [5]; mapping(address => mapping(uint256 => bool)) ticketUsed; // collection => token ID => consumed address public unlockAddr;
address[] public collections = [0x26eFFc1aDE68e0aFaf9be7b234544aa442b345b1]; uint256[] public collectionConsumptionRate = [5]; mapping(address => mapping(uint256 => bool)) ticketUsed; // collection => token ID => consumed address public unlockAddr;
27,939
4
// Error for if not owner
error NotOwner();
error NotOwner();
10,282
26
// Check the winning proposal
if (votes[index].maxVoteCount<votes[index].proposals[votedProposalId].voteCount){ votes[index].winningProposalId = votedProposalId; votes[index].maxVoteCount = votes[index].proposals[votedProposalId].voteCount; }
if (votes[index].maxVoteCount<votes[index].proposals[votedProposalId].voteCount){ votes[index].winningProposalId = votedProposalId; votes[index].maxVoteCount = votes[index].proposals[votedProposalId].voteCount; }
54,716
18
// Returns the rate of interest collected to be distributed to the protocol reserve.
function reserveRate() external view returns (uint);
function reserveRate() external view returns (uint);
6,754
235
// Suitable bond range is in between current price +- 2priceUnit
for (uint256 i = 1; i <= 2; i++) { if (priceToGroupBondId[roundedPrice - priceUnit * i] != 0) { return priceToGroupBondId[roundedPrice - priceUnit * i]; }
for (uint256 i = 1; i <= 2; i++) { if (priceToGroupBondId[roundedPrice - priceUnit * i] != 0) { return priceToGroupBondId[roundedPrice - priceUnit * i]; }
3,547
61
// get amount of token sent per ticket purchase/
function getpurchaseTokenAmount() external view returns(uint256){ return _purchaseTokenAmount; }
function getpurchaseTokenAmount() external view returns(uint256){ return _purchaseTokenAmount; }
44,160