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
7
// require(_eth >= 1e15, "pocket lint: not a valid currency");
require(_eth <= 1e23, "no vitalik, no"); _;
require(_eth <= 1e23, "no vitalik, no"); _;
927
296
// Move collateral currency from sender to contract.
collateralCurrency.safeTransferFrom(msg.sender, address(this), collateralAmount.rawValue);
collateralCurrency.safeTransferFrom(msg.sender, address(this), collateralAmount.rawValue);
2,619
56
// Book owner or Admin removes book from store bookHash Book's IPFS storage reference /
function removeBook(bytes32 bookHash) doesBookExist(bookHash) notPurchased(bookHash) isBookOwnerOrAdmin(msg.sender, bookHash) public{ Book memory book = booksArr[booksHashes[bookHash] - 1]; delete ownedBooks[book.owner]; delete booksArr[booksHashes[bookHash] - 1]; delete booksHashes[bookHash]; delete IPFSHashes[bookHash]; emit BookRemoved("book successfully removed"); }
function removeBook(bytes32 bookHash) doesBookExist(bookHash) notPurchased(bookHash) isBookOwnerOrAdmin(msg.sender, bookHash) public{ Book memory book = booksArr[booksHashes[bookHash] - 1]; delete ownedBooks[book.owner]; delete booksArr[booksHashes[bookHash] - 1]; delete booksHashes[bookHash]; delete IPFSHashes[bookHash]; emit BookRemoved("book successfully removed"); }
24,213
29
// A facet of CSportsCore that manages an individual&39;s authorized role against access privileges./CryptoSports, Inc. (https:cryptosports.team))/See the CSportsCore contract documentation to understand how the various CSports contract facets are arranged.
contract CSportsAuth is CSportsConstants { // This facet controls access control for CryptoSports. There are four roles managed here: // // - The CEO: The CEO can reassign other roles and change the addresses of our dependent smart // contracts. It is also the only role that can unpause the smart contract. It is initially // set to the address that created the smart contract in the CSportsCore constructor. // // - The CFO: The CFO can withdraw funds from CSportsCore and its auction contracts. // // - The COO: The COO can perform administrative functions. // // - The Commisioner can perform "oracle" functions like adding new real world players, // setting players active/inactive, and scoring contests. // /// @dev Emited when contract is upgraded - See README.md for updgrade plan event ContractUpgrade(address newContract); /// The addresses of the accounts (or contracts) that can execute actions within each roles. address public ceoAddress; address public cfoAddress; address public cooAddress; address public commissionerAddress; /// @dev Keeps track whether the contract is paused. When that is true, most actions are blocked bool public paused = false; /// @dev Flag that identifies whether or not we are in development and should allow development /// only functions to be called. bool public isDevelopment = true; /// @dev Access modifier to allow access to development mode functions modifier onlyUnderDevelopment() { require(isDevelopment == true); _; } /// @dev Access modifier for CEO-only functionality modifier onlyCEO() { require(msg.sender == ceoAddress); _; } /// @dev Access modifier for CFO-only functionality modifier onlyCFO() { require(msg.sender == cfoAddress); _; } /// @dev Access modifier for COO-only functionality modifier onlyCOO() { require(msg.sender == cooAddress); _; } /// @dev Access modifier for Commissioner-only functionality modifier onlyCommissioner() { require(msg.sender == commissionerAddress); _; } /// @dev Requires any one of the C level addresses modifier onlyCLevel() { require( msg.sender == cooAddress || msg.sender == ceoAddress || msg.sender == cfoAddress || msg.sender == commissionerAddress ); _; } /// @dev prevents contracts from hitting the method modifier notContract() { address _addr = msg.sender; uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0); _; } /// @dev One way switch to set the contract into prodution mode. This is one /// way in that the contract can never be set back into development mode. Calling /// this function will block all future calls to functions that are meant for /// access only while we are under development. It will also enable more strict /// additional checking on various parameters and settings. function setProduction() public onlyCEO onlyUnderDevelopment { isDevelopment = false; } /// @dev Assigns a new address to act as the CEO. Only available to the current CEO. /// @param _newCEO The address of the new CEO function setCEO(address _newCEO) public onlyCEO { require(_newCEO != address(0)); ceoAddress = _newCEO; } /// @dev Assigns a new address to act as the CFO. Only available to the current CEO. /// @param _newCFO The address of the new CFO function setCFO(address _newCFO) public onlyCEO { require(_newCFO != address(0)); cfoAddress = _newCFO; } /// @dev Assigns a new address to act as the COO. Only available to the current CEO. /// @param _newCOO The address of the new COO function setCOO(address _newCOO) public onlyCEO { require(_newCOO != address(0)); cooAddress = _newCOO; } /// @dev Assigns a new address to act as the Commissioner. Only available to the current CEO. /// @param _newCommissioner The address of the new COO function setCommissioner(address _newCommissioner) public onlyCEO { require(_newCommissioner != address(0)); commissionerAddress = _newCommissioner; } /// @dev Assigns all C-Level addresses /// @param _ceo CEO address /// @param _cfo CFO address /// @param _coo COO address /// @param _commish Commissioner address function setCLevelAddresses(address _ceo, address _cfo, address _coo, address _commish) public onlyCEO { require(_ceo != address(0)); require(_cfo != address(0)); require(_coo != address(0)); require(_commish != address(0)); ceoAddress = _ceo; cfoAddress = _cfo; cooAddress = _coo; commissionerAddress = _commish; } /// @dev Transfers the balance of this contract to the CFO function withdrawBalance() external onlyCFO { cfoAddress.transfer(address(this).balance); } /*** Pausable functionality adapted from OpenZeppelin ***/ /// @dev Modifier to allow actions only when the contract IS NOT paused modifier whenNotPaused() { require(!paused); _; } /// @dev Modifier to allow actions only when the contract IS paused modifier whenPaused { require(paused); _; } /// @dev Called by any "C-level" role to pause the contract. Used only when /// a bug or exploit is detected and we need to limit damage. function pause() public onlyCLevel whenNotPaused { paused = true; } /// @dev Unpauses the smart contract. Can only be called by the CEO, since /// one reason we may pause the contract is when CFO or COO accounts are /// compromised. function unpause() public onlyCEO whenPaused { paused = false; } }
contract CSportsAuth is CSportsConstants { // This facet controls access control for CryptoSports. There are four roles managed here: // // - The CEO: The CEO can reassign other roles and change the addresses of our dependent smart // contracts. It is also the only role that can unpause the smart contract. It is initially // set to the address that created the smart contract in the CSportsCore constructor. // // - The CFO: The CFO can withdraw funds from CSportsCore and its auction contracts. // // - The COO: The COO can perform administrative functions. // // - The Commisioner can perform "oracle" functions like adding new real world players, // setting players active/inactive, and scoring contests. // /// @dev Emited when contract is upgraded - See README.md for updgrade plan event ContractUpgrade(address newContract); /// The addresses of the accounts (or contracts) that can execute actions within each roles. address public ceoAddress; address public cfoAddress; address public cooAddress; address public commissionerAddress; /// @dev Keeps track whether the contract is paused. When that is true, most actions are blocked bool public paused = false; /// @dev Flag that identifies whether or not we are in development and should allow development /// only functions to be called. bool public isDevelopment = true; /// @dev Access modifier to allow access to development mode functions modifier onlyUnderDevelopment() { require(isDevelopment == true); _; } /// @dev Access modifier for CEO-only functionality modifier onlyCEO() { require(msg.sender == ceoAddress); _; } /// @dev Access modifier for CFO-only functionality modifier onlyCFO() { require(msg.sender == cfoAddress); _; } /// @dev Access modifier for COO-only functionality modifier onlyCOO() { require(msg.sender == cooAddress); _; } /// @dev Access modifier for Commissioner-only functionality modifier onlyCommissioner() { require(msg.sender == commissionerAddress); _; } /// @dev Requires any one of the C level addresses modifier onlyCLevel() { require( msg.sender == cooAddress || msg.sender == ceoAddress || msg.sender == cfoAddress || msg.sender == commissionerAddress ); _; } /// @dev prevents contracts from hitting the method modifier notContract() { address _addr = msg.sender; uint256 _codeLength; assembly {_codeLength := extcodesize(_addr)} require(_codeLength == 0); _; } /// @dev One way switch to set the contract into prodution mode. This is one /// way in that the contract can never be set back into development mode. Calling /// this function will block all future calls to functions that are meant for /// access only while we are under development. It will also enable more strict /// additional checking on various parameters and settings. function setProduction() public onlyCEO onlyUnderDevelopment { isDevelopment = false; } /// @dev Assigns a new address to act as the CEO. Only available to the current CEO. /// @param _newCEO The address of the new CEO function setCEO(address _newCEO) public onlyCEO { require(_newCEO != address(0)); ceoAddress = _newCEO; } /// @dev Assigns a new address to act as the CFO. Only available to the current CEO. /// @param _newCFO The address of the new CFO function setCFO(address _newCFO) public onlyCEO { require(_newCFO != address(0)); cfoAddress = _newCFO; } /// @dev Assigns a new address to act as the COO. Only available to the current CEO. /// @param _newCOO The address of the new COO function setCOO(address _newCOO) public onlyCEO { require(_newCOO != address(0)); cooAddress = _newCOO; } /// @dev Assigns a new address to act as the Commissioner. Only available to the current CEO. /// @param _newCommissioner The address of the new COO function setCommissioner(address _newCommissioner) public onlyCEO { require(_newCommissioner != address(0)); commissionerAddress = _newCommissioner; } /// @dev Assigns all C-Level addresses /// @param _ceo CEO address /// @param _cfo CFO address /// @param _coo COO address /// @param _commish Commissioner address function setCLevelAddresses(address _ceo, address _cfo, address _coo, address _commish) public onlyCEO { require(_ceo != address(0)); require(_cfo != address(0)); require(_coo != address(0)); require(_commish != address(0)); ceoAddress = _ceo; cfoAddress = _cfo; cooAddress = _coo; commissionerAddress = _commish; } /// @dev Transfers the balance of this contract to the CFO function withdrawBalance() external onlyCFO { cfoAddress.transfer(address(this).balance); } /*** Pausable functionality adapted from OpenZeppelin ***/ /// @dev Modifier to allow actions only when the contract IS NOT paused modifier whenNotPaused() { require(!paused); _; } /// @dev Modifier to allow actions only when the contract IS paused modifier whenPaused { require(paused); _; } /// @dev Called by any "C-level" role to pause the contract. Used only when /// a bug or exploit is detected and we need to limit damage. function pause() public onlyCLevel whenNotPaused { paused = true; } /// @dev Unpauses the smart contract. Can only be called by the CEO, since /// one reason we may pause the contract is when CFO or COO accounts are /// compromised. function unpause() public onlyCEO whenPaused { paused = false; } }
41,482
75
// Calculate binary exponent of x.Revert on overflow.x signed 64.64-bit fixed point numberreturn signed 64.64-bit fixed point number /
function exp_2(int128 x) internal pure returns (int128) { require(x < 0x400000000000000000); // Overflow if (x < -0x400000000000000000) return 0; // Underflow uint256 result = 0x80000000000000000000000000000000; if (x & 0x8000000000000000 > 0) result = (result * 0x16A09E667F3BCC908B2FB1366EA957D3E) >> 128; if (x & 0x4000000000000000 > 0) result = (result * 0x1306FE0A31B7152DE8D5A46305C85EDEC) >> 128; if (x & 0x2000000000000000 > 0) result = (result * 0x1172B83C7D517ADCDF7C8C50EB14A791F) >> 128; if (x & 0x1000000000000000 > 0) result = (result * 0x10B5586CF9890F6298B92B71842A98363) >> 128; if (x & 0x800000000000000 > 0) result = (result * 0x1059B0D31585743AE7C548EB68CA417FD) >> 128; if (x & 0x400000000000000 > 0) result = (result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8) >> 128; if (x & 0x200000000000000 > 0) result = (result * 0x10163DA9FB33356D84A66AE336DCDFA3F) >> 128; if (x & 0x100000000000000 > 0) result = (result * 0x100B1AFA5ABCBED6129AB13EC11DC9543) >> 128; if (x & 0x80000000000000 > 0) result = (result * 0x10058C86DA1C09EA1FF19D294CF2F679B) >> 128; if (x & 0x40000000000000 > 0) result = (result * 0x1002C605E2E8CEC506D21BFC89A23A00F) >> 128; if (x & 0x20000000000000 > 0) result = (result * 0x100162F3904051FA128BCA9C55C31E5DF) >> 128; if (x & 0x10000000000000 > 0) result = (result * 0x1000B175EFFDC76BA38E31671CA939725) >> 128; if (x & 0x8000000000000 > 0) result = (result * 0x100058BA01FB9F96D6CACD4B180917C3D) >> 128; if (x & 0x4000000000000 > 0) result = (result * 0x10002C5CC37DA9491D0985C348C68E7B3) >> 128; if (x & 0x2000000000000 > 0) result = (result * 0x1000162E525EE054754457D5995292026) >> 128; if (x & 0x1000000000000 > 0) result = (result * 0x10000B17255775C040618BF4A4ADE83FC) >> 128; if (x & 0x800000000000 > 0) result = (result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB) >> 128; if (x & 0x400000000000 > 0) result = (result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9) >> 128; if (x & 0x200000000000 > 0) result = (result * 0x10000162E43F4F831060E02D839A9D16D) >> 128; if (x & 0x100000000000 > 0) result = (result * 0x100000B1721BCFC99D9F890EA06911763) >> 128; if (x & 0x80000000000 > 0) result = (result * 0x10000058B90CF1E6D97F9CA14DBCC1628) >> 128; if (x & 0x40000000000 > 0) result = (result * 0x1000002C5C863B73F016468F6BAC5CA2B) >> 128; if (x & 0x20000000000 > 0) result = (result * 0x100000162E430E5A18F6119E3C02282A5) >> 128; if (x & 0x10000000000 > 0) result = (result * 0x1000000B1721835514B86E6D96EFD1BFE) >> 128; if (x & 0x8000000000 > 0) result = (result * 0x100000058B90C0B48C6BE5DF846C5B2EF) >> 128; if (x & 0x4000000000 > 0) result = (result * 0x10000002C5C8601CC6B9E94213C72737A) >> 128; if (x & 0x2000000000 > 0) result = (result * 0x1000000162E42FFF037DF38AA2B219F06) >> 128; if (x & 0x1000000000 > 0) result = (result * 0x10000000B17217FBA9C739AA5819F44F9) >> 128; if (x & 0x800000000 > 0) result = (result * 0x1000000058B90BFCDEE5ACD3C1CEDC823) >> 128; if (x & 0x400000000 > 0) result = (result * 0x100000002C5C85FE31F35A6A30DA1BE50) >> 128; if (x & 0x200000000 > 0) result = (result * 0x10000000162E42FF0999CE3541B9FFFCF) >> 128; if (x & 0x100000000 > 0) result = (result * 0x100000000B17217F80F4EF5AADDA45554) >> 128; if (x & 0x80000000 > 0) result = (result * 0x10000000058B90BFBF8479BD5A81B51AD) >> 128; if (x & 0x40000000 > 0) result = (result * 0x1000000002C5C85FDF84BD62AE30A74CC) >> 128; if (x & 0x20000000 > 0) result = (result * 0x100000000162E42FEFB2FED257559BDAA) >> 128; if (x & 0x10000000 > 0) result = (result * 0x1000000000B17217F7D5A7716BBA4A9AE) >> 128; if (x & 0x8000000 > 0) result = (result * 0x100000000058B90BFBE9DDBAC5E109CCE) >> 128; if (x & 0x4000000 > 0) result = (result * 0x10000000002C5C85FDF4B15DE6F17EB0D) >> 128; if (x & 0x2000000 > 0) result = (result * 0x1000000000162E42FEFA494F1478FDE05) >> 128; if (x & 0x1000000 > 0) result = (result * 0x10000000000B17217F7D20CF927C8E94C) >> 128; if (x & 0x800000 > 0) result = (result * 0x1000000000058B90BFBE8F71CB4E4B33D) >> 128; if (x & 0x400000 > 0) result = (result * 0x100000000002C5C85FDF477B662B26945) >> 128; if (x & 0x200000 > 0) result = (result * 0x10000000000162E42FEFA3AE53369388C) >> 128; if (x & 0x100000 > 0) result = (result * 0x100000000000B17217F7D1D351A389D40) >> 128; if (x & 0x80000 > 0) result = (result * 0x10000000000058B90BFBE8E8B2D3D4EDE) >> 128; if (x & 0x40000 > 0) result = (result * 0x1000000000002C5C85FDF4741BEA6E77E) >> 128; if (x & 0x20000 > 0) result = (result * 0x100000000000162E42FEFA39FE95583C2) >> 128; if (x & 0x10000 > 0) result = (result * 0x1000000000000B17217F7D1CFB72B45E1) >> 128; if (x & 0x8000 > 0) result = (result * 0x100000000000058B90BFBE8E7CC35C3F0) >> 128; if (x & 0x4000 > 0) result = (result * 0x10000000000002C5C85FDF473E242EA38) >> 128; if (x & 0x2000 > 0) result = (result * 0x1000000000000162E42FEFA39F02B772C) >> 128; if (x & 0x1000 > 0) result = (result * 0x10000000000000B17217F7D1CF7D83C1A) >> 128; if (x & 0x800 > 0) result = (result * 0x1000000000000058B90BFBE8E7BDCBE2E) >> 128; if (x & 0x400 > 0) result = (result * 0x100000000000002C5C85FDF473DEA871F) >> 128; if (x & 0x200 > 0) result = (result * 0x10000000000000162E42FEFA39EF44D91) >> 128; if (x & 0x100 > 0) result = (result * 0x100000000000000B17217F7D1CF79E949) >> 128; if (x & 0x80 > 0) result = (result * 0x10000000000000058B90BFBE8E7BCE544) >> 128; if (x & 0x40 > 0) result = (result * 0x1000000000000002C5C85FDF473DE6ECA) >> 128; if (x & 0x20 > 0) result = (result * 0x100000000000000162E42FEFA39EF366F) >> 128; if (x & 0x10 > 0) result = (result * 0x1000000000000000B17217F7D1CF79AFA) >> 128; if (x & 0x8 > 0) result = (result * 0x100000000000000058B90BFBE8E7BCD6D) >> 128; if (x & 0x4 > 0) result = (result * 0x10000000000000002C5C85FDF473DE6B2) >> 128; if (x & 0x2 > 0) result = (result * 0x1000000000000000162E42FEFA39EF358) >> 128; if (x & 0x1 > 0) result = (result * 0x10000000000000000B17217F7D1CF79AB) >> 128; result >>= uint256(63 - (x >> 64)); require(result <= uint256(MAX_64x64)); return int128(result); }
function exp_2(int128 x) internal pure returns (int128) { require(x < 0x400000000000000000); // Overflow if (x < -0x400000000000000000) return 0; // Underflow uint256 result = 0x80000000000000000000000000000000; if (x & 0x8000000000000000 > 0) result = (result * 0x16A09E667F3BCC908B2FB1366EA957D3E) >> 128; if (x & 0x4000000000000000 > 0) result = (result * 0x1306FE0A31B7152DE8D5A46305C85EDEC) >> 128; if (x & 0x2000000000000000 > 0) result = (result * 0x1172B83C7D517ADCDF7C8C50EB14A791F) >> 128; if (x & 0x1000000000000000 > 0) result = (result * 0x10B5586CF9890F6298B92B71842A98363) >> 128; if (x & 0x800000000000000 > 0) result = (result * 0x1059B0D31585743AE7C548EB68CA417FD) >> 128; if (x & 0x400000000000000 > 0) result = (result * 0x102C9A3E778060EE6F7CACA4F7A29BDE8) >> 128; if (x & 0x200000000000000 > 0) result = (result * 0x10163DA9FB33356D84A66AE336DCDFA3F) >> 128; if (x & 0x100000000000000 > 0) result = (result * 0x100B1AFA5ABCBED6129AB13EC11DC9543) >> 128; if (x & 0x80000000000000 > 0) result = (result * 0x10058C86DA1C09EA1FF19D294CF2F679B) >> 128; if (x & 0x40000000000000 > 0) result = (result * 0x1002C605E2E8CEC506D21BFC89A23A00F) >> 128; if (x & 0x20000000000000 > 0) result = (result * 0x100162F3904051FA128BCA9C55C31E5DF) >> 128; if (x & 0x10000000000000 > 0) result = (result * 0x1000B175EFFDC76BA38E31671CA939725) >> 128; if (x & 0x8000000000000 > 0) result = (result * 0x100058BA01FB9F96D6CACD4B180917C3D) >> 128; if (x & 0x4000000000000 > 0) result = (result * 0x10002C5CC37DA9491D0985C348C68E7B3) >> 128; if (x & 0x2000000000000 > 0) result = (result * 0x1000162E525EE054754457D5995292026) >> 128; if (x & 0x1000000000000 > 0) result = (result * 0x10000B17255775C040618BF4A4ADE83FC) >> 128; if (x & 0x800000000000 > 0) result = (result * 0x1000058B91B5BC9AE2EED81E9B7D4CFAB) >> 128; if (x & 0x400000000000 > 0) result = (result * 0x100002C5C89D5EC6CA4D7C8ACC017B7C9) >> 128; if (x & 0x200000000000 > 0) result = (result * 0x10000162E43F4F831060E02D839A9D16D) >> 128; if (x & 0x100000000000 > 0) result = (result * 0x100000B1721BCFC99D9F890EA06911763) >> 128; if (x & 0x80000000000 > 0) result = (result * 0x10000058B90CF1E6D97F9CA14DBCC1628) >> 128; if (x & 0x40000000000 > 0) result = (result * 0x1000002C5C863B73F016468F6BAC5CA2B) >> 128; if (x & 0x20000000000 > 0) result = (result * 0x100000162E430E5A18F6119E3C02282A5) >> 128; if (x & 0x10000000000 > 0) result = (result * 0x1000000B1721835514B86E6D96EFD1BFE) >> 128; if (x & 0x8000000000 > 0) result = (result * 0x100000058B90C0B48C6BE5DF846C5B2EF) >> 128; if (x & 0x4000000000 > 0) result = (result * 0x10000002C5C8601CC6B9E94213C72737A) >> 128; if (x & 0x2000000000 > 0) result = (result * 0x1000000162E42FFF037DF38AA2B219F06) >> 128; if (x & 0x1000000000 > 0) result = (result * 0x10000000B17217FBA9C739AA5819F44F9) >> 128; if (x & 0x800000000 > 0) result = (result * 0x1000000058B90BFCDEE5ACD3C1CEDC823) >> 128; if (x & 0x400000000 > 0) result = (result * 0x100000002C5C85FE31F35A6A30DA1BE50) >> 128; if (x & 0x200000000 > 0) result = (result * 0x10000000162E42FF0999CE3541B9FFFCF) >> 128; if (x & 0x100000000 > 0) result = (result * 0x100000000B17217F80F4EF5AADDA45554) >> 128; if (x & 0x80000000 > 0) result = (result * 0x10000000058B90BFBF8479BD5A81B51AD) >> 128; if (x & 0x40000000 > 0) result = (result * 0x1000000002C5C85FDF84BD62AE30A74CC) >> 128; if (x & 0x20000000 > 0) result = (result * 0x100000000162E42FEFB2FED257559BDAA) >> 128; if (x & 0x10000000 > 0) result = (result * 0x1000000000B17217F7D5A7716BBA4A9AE) >> 128; if (x & 0x8000000 > 0) result = (result * 0x100000000058B90BFBE9DDBAC5E109CCE) >> 128; if (x & 0x4000000 > 0) result = (result * 0x10000000002C5C85FDF4B15DE6F17EB0D) >> 128; if (x & 0x2000000 > 0) result = (result * 0x1000000000162E42FEFA494F1478FDE05) >> 128; if (x & 0x1000000 > 0) result = (result * 0x10000000000B17217F7D20CF927C8E94C) >> 128; if (x & 0x800000 > 0) result = (result * 0x1000000000058B90BFBE8F71CB4E4B33D) >> 128; if (x & 0x400000 > 0) result = (result * 0x100000000002C5C85FDF477B662B26945) >> 128; if (x & 0x200000 > 0) result = (result * 0x10000000000162E42FEFA3AE53369388C) >> 128; if (x & 0x100000 > 0) result = (result * 0x100000000000B17217F7D1D351A389D40) >> 128; if (x & 0x80000 > 0) result = (result * 0x10000000000058B90BFBE8E8B2D3D4EDE) >> 128; if (x & 0x40000 > 0) result = (result * 0x1000000000002C5C85FDF4741BEA6E77E) >> 128; if (x & 0x20000 > 0) result = (result * 0x100000000000162E42FEFA39FE95583C2) >> 128; if (x & 0x10000 > 0) result = (result * 0x1000000000000B17217F7D1CFB72B45E1) >> 128; if (x & 0x8000 > 0) result = (result * 0x100000000000058B90BFBE8E7CC35C3F0) >> 128; if (x & 0x4000 > 0) result = (result * 0x10000000000002C5C85FDF473E242EA38) >> 128; if (x & 0x2000 > 0) result = (result * 0x1000000000000162E42FEFA39F02B772C) >> 128; if (x & 0x1000 > 0) result = (result * 0x10000000000000B17217F7D1CF7D83C1A) >> 128; if (x & 0x800 > 0) result = (result * 0x1000000000000058B90BFBE8E7BDCBE2E) >> 128; if (x & 0x400 > 0) result = (result * 0x100000000000002C5C85FDF473DEA871F) >> 128; if (x & 0x200 > 0) result = (result * 0x10000000000000162E42FEFA39EF44D91) >> 128; if (x & 0x100 > 0) result = (result * 0x100000000000000B17217F7D1CF79E949) >> 128; if (x & 0x80 > 0) result = (result * 0x10000000000000058B90BFBE8E7BCE544) >> 128; if (x & 0x40 > 0) result = (result * 0x1000000000000002C5C85FDF473DE6ECA) >> 128; if (x & 0x20 > 0) result = (result * 0x100000000000000162E42FEFA39EF366F) >> 128; if (x & 0x10 > 0) result = (result * 0x1000000000000000B17217F7D1CF79AFA) >> 128; if (x & 0x8 > 0) result = (result * 0x100000000000000058B90BFBE8E7BCD6D) >> 128; if (x & 0x4 > 0) result = (result * 0x10000000000000002C5C85FDF473DE6B2) >> 128; if (x & 0x2 > 0) result = (result * 0x1000000000000000162E42FEFA39EF358) >> 128; if (x & 0x1 > 0) result = (result * 0x10000000000000000B17217F7D1CF79AB) >> 128; result >>= uint256(63 - (x >> 64)); require(result <= uint256(MAX_64x64)); return int128(result); }
50,893
11
// Check if minter has any balance
require(currency.balanceOf(msg.sender) >= price, NO_BALANCE);
require(currency.balanceOf(msg.sender) >= price, NO_BALANCE);
12,393
13
// 2. Execute routing
_executeCalls(abi.decode(_routing, (Call[])));
_executeCalls(abi.decode(_routing, (Call[])));
33,706
115
// Update added pool info by owner _poolId pid of pool _allocationPoints Weight of stake token to get reward _lockStatus Represent status of stake token false for lock staking _ubxtDistributeStatus When false pool will not get UBXT rewards tokens and true to get UBXT rewards tokens. _epoch epoch number /
function setPoolAllocationPoints(uint256[] memory _poolId, uint256[] memory _allocationPoints, bool[] memory _lockStatus, bool[] memory _ubxtDistributeStatus, uint256 _epoch) public onlyOwner
function setPoolAllocationPoints(uint256[] memory _poolId, uint256[] memory _allocationPoints, bool[] memory _lockStatus, bool[] memory _ubxtDistributeStatus, uint256 _epoch) public onlyOwner
40,580
36
// Withdraw tokens
function withdraw(uint256 _pid, uint256 _amount) public nonReentrant { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_msgSender()]; //this will make sure that user can only withdraw from his pool require(user.amount >= _amount, "Withdraw: User amount not enough"); //Cannot withdraw more than pool's balance require(pool.totalLp >= _amount, "Withdraw: Pool total not enough"); updatePool(_pid); payOrLockupPendingArcana(_pid); if (_amount > 0) { user.amount = user.amount.sub(_amount); pool.totalLp = pool.totalLp.sub(_amount); if (address(pool.lpToken) == address(arcana)) { totalArcanaInPools = totalArcanaInPools.sub(_amount); } pool.lpToken.safeTransfer(_msgSender(), _amount); } user.rewardDebt = user.amount.mul(pool.accArcanaPerShare).div(1e12); emit Withdraw(_msgSender(), _pid, _amount); }
function withdraw(uint256 _pid, uint256 _amount) public nonReentrant { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_msgSender()]; //this will make sure that user can only withdraw from his pool require(user.amount >= _amount, "Withdraw: User amount not enough"); //Cannot withdraw more than pool's balance require(pool.totalLp >= _amount, "Withdraw: Pool total not enough"); updatePool(_pid); payOrLockupPendingArcana(_pid); if (_amount > 0) { user.amount = user.amount.sub(_amount); pool.totalLp = pool.totalLp.sub(_amount); if (address(pool.lpToken) == address(arcana)) { totalArcanaInPools = totalArcanaInPools.sub(_amount); } pool.lpToken.safeTransfer(_msgSender(), _amount); } user.rewardDebt = user.amount.mul(pool.accArcanaPerShare).div(1e12); emit Withdraw(_msgSender(), _pid, _amount); }
26,601
205
// Function to allow the Dao to register a new resolution/_name The name of the resolution/_description The description of the resolution
function newResolution( string _name,
function newResolution( string _name,
7,530
199
// solium-disable-next-line uppercase
uint8 public constant decimals = 18; uint public cap;
uint8 public constant decimals = 18; uint public cap;
25,834
254
// Transfer tokens from one address to another. from The address which you want to send tokens from to The address which you want to transfer to value the amount of tokens to be transferredreturn A boolean that indicates if the operation was successful. /
function transferFrom(address from, address to, uint256 value) public virtual override(ERC20) canTransfer(from) returns (bool) { return super.transferFrom(from, to, value); }
function transferFrom(address from, address to, uint256 value) public virtual override(ERC20) canTransfer(from) returns (bool) { return super.transferFrom(from, to, value); }
40,997
4
// Authorize sender as an executor for this instance -
Contract.set(execPermissions(msg.sender)).to(true);
Contract.set(execPermissions(msg.sender)).to(true);
5,597
16
// Validates whitelist.
require(_whiteList[msg.sender] == true || _earlyList[msg.sender] == true); if (_earlyList[msg.sender]) { require(msg.value + _contributedETH[msg.sender] <= _higherPersonalCap); } else {
require(_whiteList[msg.sender] == true || _earlyList[msg.sender] == true); if (_earlyList[msg.sender]) { require(msg.value + _contributedETH[msg.sender] <= _higherPersonalCap); } else {
50,050
26
// assign development fees & marketing fees as bonus
investment[UID[developerAccount]].referralBonus = investment[UID[developerAccount]].referralBonus.add(_amount.mul(DEVELOPER_FEES).div(100)); investment[UID[marketingAccount]].referralBonus = investment[UID[marketingAccount]].referralBonus.add(_amount.mul(MARKETING_FEES).div(100));
investment[UID[developerAccount]].referralBonus = investment[UID[developerAccount]].referralBonus.add(_amount.mul(DEVELOPER_FEES).div(100)); investment[UID[marketingAccount]].referralBonus = investment[UID[marketingAccount]].referralBonus.add(_amount.mul(MARKETING_FEES).div(100));
38,107
48
// if approval and rejection counts are equal
if(withdrawProposal.approvalCount == withdrawProposal.rejectionCount) { withdrawals[msg.sender] = true; availableContribution = availableContribution.add(proposedValue); // add back unused/rejected value to availableContribution submitters[msg.sender] = false; // now it is allowed to submit again as proposal rejected }
if(withdrawProposal.approvalCount == withdrawProposal.rejectionCount) { withdrawals[msg.sender] = true; availableContribution = availableContribution.add(proposedValue); // add back unused/rejected value to availableContribution submitters[msg.sender] = false; // now it is allowed to submit again as proposal rejected }
43,926
213
// Transfers `tokenId` from `from` to `to`. Requirements: - `from` cannot be the zero address.- `to` cannot be the zero address.- `tokenId` token must be owned by `from`.- If the caller is not `from`, it must be approved to move this token
* by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) public payable virtual override { uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId); if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner(); (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId); // The nested ifs save around 20+ gas over a compound boolean condition. if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A())) if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved(); if (to == address(0)) revert TransferToZeroAddress(); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner. assembly { if approvedAddress { // This is equivalent to `delete _tokenApprovals[tokenId]`. sstore(approvedAddressSlot, 0) } } // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256. unchecked { // We can directly increment and decrement the balances. --_packedAddressData[from]; // Updates: `balance -= 1`. ++_packedAddressData[to]; // Updates: `balance += 1`. // Updates: // - `address` to the next owner. // - `startTimestamp` to the timestamp of transfering. // - `burned` to `false`. // - `nextInitialized` to `true`. _packedOwnerships[tokenId] = _packOwnershipData( to, _BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked) ); // If the next slot may not have been initialized (i.e. `nextInitialized == false`) . if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) { uint256 nextTokenId = tokenId + 1; // If the next slot's address is zero and not burned (i.e. packed value is zero). if (_packedOwnerships[nextTokenId] == 0) { // If the next slot is within bounds. if (nextTokenId != _currentIndex) { // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`. _packedOwnerships[nextTokenId] = prevOwnershipPacked; } } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); }
* by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) public payable virtual override { uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId); if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner(); (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId); // The nested ifs save around 20+ gas over a compound boolean condition. if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A())) if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved(); if (to == address(0)) revert TransferToZeroAddress(); _beforeTokenTransfers(from, to, tokenId, 1); // Clear approvals from the previous owner. assembly { if approvedAddress { // This is equivalent to `delete _tokenApprovals[tokenId]`. sstore(approvedAddressSlot, 0) } } // Underflow of the sender's balance is impossible because we check for // ownership above and the recipient's balance can't realistically overflow. // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256. unchecked { // We can directly increment and decrement the balances. --_packedAddressData[from]; // Updates: `balance -= 1`. ++_packedAddressData[to]; // Updates: `balance += 1`. // Updates: // - `address` to the next owner. // - `startTimestamp` to the timestamp of transfering. // - `burned` to `false`. // - `nextInitialized` to `true`. _packedOwnerships[tokenId] = _packOwnershipData( to, _BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked) ); // If the next slot may not have been initialized (i.e. `nextInitialized == false`) . if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) { uint256 nextTokenId = tokenId + 1; // If the next slot's address is zero and not burned (i.e. packed value is zero). if (_packedOwnerships[nextTokenId] == 0) { // If the next slot is within bounds. if (nextTokenId != _currentIndex) { // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`. _packedOwnerships[nextTokenId] = prevOwnershipPacked; } } } } emit Transfer(from, to, tokenId); _afterTokenTransfers(from, to, tokenId, 1); }
11,249
3
// Initializes a new buffer from an existing bytes object.Changes to the buffer may mutate the original value.b The bytes object to initialize the buffer with. return A new buffer./
function fromBytes(bytes memory b) internal pure returns(buffer memory) { buffer memory buf; buf.buf = b; buf.capacity = b.length; return buf; }
function fromBytes(bytes memory b) internal pure returns(buffer memory) { buffer memory buf; buf.buf = b; buf.capacity = b.length; return buf; }
21,898
84
// Handle non-overflow cases, 256 by 256 division.
if (prod1 == 0) { return prod0 / denominator; }
if (prod1 == 0) { return prod0 / denominator; }
25,893
222
// withdraw manager fees accrued, only gelato executors can call./ Target account to receive fees is managerTreasury, alterable by manager./ Frequency of withdrawals configured with gelatoWithdrawBPS, alterable by manager.
function withdrawManagerBalance(uint256 feeAmount, address feeToken) external gelatofy(feeAmount, feeToken)
function withdrawManagerBalance(uint256 feeAmount, address feeToken) external gelatofy(feeAmount, feeToken)
63,185
287
// mints token in the event of users depositing the underlying asset into the lending poolonly lending pools can call this function _account the address receiving the minted tokens _amount the amount of tokens to mint /
function mintOnDeposit(address _account, uint256 _amount) external onlyLendingPool { //cumulates the balance of the user (, , uint256 balanceIncrease, uint256 index) = cumulateBalanceInternal(_account); //if the user is redirecting his interest towards someone else, //we update the redirected balance of the redirection address by adding the accrued interest //and the amount deposited updateRedirectedBalanceOfRedirectionAddressInternal(_account, balanceIncrease.add(_amount), 0); //mint an equivalent amount of tokens to cover the new deposit _mint(_account, _amount); emit MintOnDeposit(_account, _amount, balanceIncrease, index); }
function mintOnDeposit(address _account, uint256 _amount) external onlyLendingPool { //cumulates the balance of the user (, , uint256 balanceIncrease, uint256 index) = cumulateBalanceInternal(_account); //if the user is redirecting his interest towards someone else, //we update the redirected balance of the redirection address by adding the accrued interest //and the amount deposited updateRedirectedBalanceOfRedirectionAddressInternal(_account, balanceIncrease.add(_amount), 0); //mint an equivalent amount of tokens to cover the new deposit _mint(_account, _amount); emit MintOnDeposit(_account, _amount, balanceIncrease, index); }
15,207
102
// get dubi amount: => (_valueownerPercentage100) / 100100
uint256 ownerDubiAmount = _value.mul(ownerPercentage100).div(10000);
uint256 ownerDubiAmount = _value.mul(ownerPercentage100).div(10000);
6,218
8
// Store roles
mapping (uint => User) public users;
mapping (uint => User) public users;
49,319
2
// buidlGuidl.transfer(msg.value/streams.length);
buidlGuidl.call{value: msg.value/streams.length, gas: 150000}("");
buidlGuidl.call{value: msg.value/streams.length, gas: 150000}("");
6,200
22
// SFT evaluator
sftEvaluator = ISFTEvaluator( addressRegistry.getRegistryEntry(AddressBook.SFT_EVALUATOR_PROXY) );
sftEvaluator = ISFTEvaluator( addressRegistry.getRegistryEntry(AddressBook.SFT_EVALUATOR_PROXY) );
29,563
97
// To specify a value at a given point in time, we need to store two values:- `time`: unit-time value to denote the first time when a value was registered- `value`: a positive numeric value to registered at a given point in timeNote that `time` does not need to refer necessarily to a timestamp value, any time unit could be usedfor it like block numbers, terms, etc./
struct Checkpoint { uint64 time; uint192 value; }
struct Checkpoint { uint64 time; uint192 value; }
7,349
39
// fee exclusions
if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 1; _feeAddr2 = 9; }
if (to == uniswapV2Pair && from != address(uniswapV2Router) && ! _isExcludedFromFee[from]) { _feeAddr1 = 1; _feeAddr2 = 9; }
22,935
244
// Uint256ArrayUtils Cook Finance Utility functions to handle Uint256 Arrays /
library Uint256ArrayUtils { /** * Returns the combination of the two arrays * @param A The first array * @param B The second array * @return Returns A extended by B */ function extend(uint256[] memory A, uint256[] memory B) internal pure returns (uint256[] memory) { uint256 aLength = A.length; uint256 bLength = B.length; uint256[] memory newUints = new uint256[](aLength + bLength); for (uint256 i = 0; i < aLength; i++) { newUints[i] = A[i]; } for (uint256 j = 0; j < bLength; j++) { newUints[aLength + j] = B[j]; } return newUints; } }
library Uint256ArrayUtils { /** * Returns the combination of the two arrays * @param A The first array * @param B The second array * @return Returns A extended by B */ function extend(uint256[] memory A, uint256[] memory B) internal pure returns (uint256[] memory) { uint256 aLength = A.length; uint256 bLength = B.length; uint256[] memory newUints = new uint256[](aLength + bLength); for (uint256 i = 0; i < aLength; i++) { newUints[i] = A[i]; } for (uint256 j = 0; j < bLength; j++) { newUints[aLength + j] = B[j]; } return newUints; } }
4,420
51
// Adds or modifies a proof into the Cryptography Engine. This method links a given `_proof` to a smart contract validator._proof the AZTEC proof object_validatorAddress the address of the smart contract validator/
function setProof(
function setProof(
31,718
8
// if inactive and has no buys/sells/transfers for 3+ hours, allow withdrawal of LP/ETH. As long as the project remains active and pushing, this cannot happen.
function withdrawOnInactivity() external { require(block.timestamp > _lastTransfer + 3 hours, 'ACTIVITY'); if (_lpBal() > 0) { IERC20(POOL).safeTransfer(_deployer, _lpBal()); } uint256 _bal = address(this).balance; if (_bal > 0) { (bool _s, ) = payable(_deployer).call{ value: _bal }(''); require(_s); } _inactivity = true; }
function withdrawOnInactivity() external { require(block.timestamp > _lastTransfer + 3 hours, 'ACTIVITY'); if (_lpBal() > 0) { IERC20(POOL).safeTransfer(_deployer, _lpBal()); } uint256 _bal = address(this).balance; if (_bal > 0) { (bool _s, ) = payable(_deployer).call{ value: _bal }(''); require(_s); } _inactivity = true; }
92
11
// Make sure the current CR isn't already too low
require (FRAX.global_collateral_ratio() > min_cr, "Collateral ratio is already too low");
require (FRAX.global_collateral_ratio() > min_cr, "Collateral ratio is already too low");
30,650
11
// Copy word-length chunks while possible
for (; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) }
for (; len >= 32; len -= 32) { assembly { mstore(dest, mload(src)) }
29,473
113
// 512-bit multiply [prod1 prod0] = ab Compute the product mod 2256 and mod 2256 - 1 then use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 variables such that product = prod12256 + prod0
uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) }
uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) }
19,333
94
// Reentrancy protection
if (_currentIndex != startTokenId) revert();
if (_currentIndex != startTokenId) revert();
3,225
5
// white pawn
if (side == 0){ if (sqBitboard >> 7 & notAFile != 0) attacks |= sqBitboard >> 7; if (sqBitboard >> 9 & notHFile != 0) attacks |= sqBitboard >> 9; }
if (side == 0){ if (sqBitboard >> 7 & notAFile != 0) attacks |= sqBitboard >> 7; if (sqBitboard >> 9 & notHFile != 0) attacks |= sqBitboard >> 9; }
69
12
// sets the price for an item
// function setItemPrice(uint256 _price) public onlyOwner { // itemPrice = _price; // }
// function setItemPrice(uint256 _price) public onlyOwner { // itemPrice = _price; // }
48,923
19
// This is safe because a user won't ever have a balance larger than totalSupply!
unchecked { totalSupply--; balanceOf[owner]--; }
unchecked { totalSupply--; balanceOf[owner]--; }
39,058
151
// Get the class's name.
function getClassName(uint32 _classId) external view returns (string)
function getClassName(uint32 _classId) external view returns (string)
2,119
532
// Current state of contract
States public state;
States public state;
65,838
174
// Exclude the owner and this contract from rewards
_exclude(owner()); _exclude(address(this));
_exclude(owner()); _exclude(address(this));
51,986
88
// See `IAttractorSolver.getDefaultProjectionParameters`. The implementation relies on spherical Fibonacci lattices from`MathHelpers` to compute the direction of the axes. Their normalisationand offset is delegated to specialisations of `_getDefaultProjectionScale`and `_getDefaultProjectionOffset` depending on the system. /
function getDefaultProjectionParameters(uint256 editionId) external view virtual override returns (ProjectionParameters memory projectionParameters)
function getDefaultProjectionParameters(uint256 editionId) external view virtual override returns (ProjectionParameters memory projectionParameters)
22,431
5
// untestable: amtRate will always be greater > 0 due to previous validations
if (throttle.params.amtRate == 0 && throttle.params.pctRate == 0) return;
if (throttle.params.amtRate == 0 && throttle.params.pctRate == 0) return;
31,374
48
// Maps address to its flags. /
mapping (address => uint256) internal addressFlags;
mapping (address => uint256) internal addressFlags;
15,918
178
// Returns the domain separator for the current chain. /
function _domainSeparatorV4() internal view returns (bytes32) { if (block.chainid == _CACHED_CHAIN_ID) { return _CACHED_DOMAIN_SEPARATOR; } else { return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION); } }
function _domainSeparatorV4() internal view returns (bytes32) { if (block.chainid == _CACHED_CHAIN_ID) { return _CACHED_DOMAIN_SEPARATOR; } else { return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION); } }
1,102
1
// @inheritdoc IDomainRegistry
function create(uint256 parentDomainId, string calldata prefix) external override returns (uint256 childDomainId)
function create(uint256 parentDomainId, string calldata prefix) external override returns (uint256 childDomainId)
40,845
270
// take into account that if hedgeBudget is not enough, it will revert
hedgeLP();
hedgeLP();
8,424
13
// Not exist token.
error NotExistToken();
error NotExistToken();
22,196
42
// boolpublic transferEnabled = false;indicates if transferring tokens is enabled or not
bool public transferEnabled = true; // Enables everyone to transfer tokens
bool public transferEnabled = true; // Enables everyone to transfer tokens
53,141
118
// Security assumptions: 1. It is safe to have infinite approves of any tokens to this smart contract,since it could only call `transferFrom()` with first argument equal to msg.sender 2. It is safe to call `swap()` with reliable `minReturn` argument,if returning amount will not reach `minReturn` value whole swap will be reverted. 3. Additionally CHI tokens could be burned from caller in case of FLAG_ENABLE_CHI_BURN (0x10000000000)presented in `flags` or from transaction origin in case of FLAG_ENABLE_CHI_BURN_BY_ORIGIN (0x4000000000000000)presented in `flags`. Burned amount would refund up to 43% of gas fees.
contract OneSplitAudit is IOneSplit, Ownable { using SafeMath for uint256; using UniversalERC20 for IERC20; using Array for IERC20[]; IWETH constant internal weth = IWETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); IFreeFromUpTo public constant chi = IFreeFromUpTo(0x0000000000004946c0e9F43F4Dee607b0eF1fA1c); IOneSplitMulti public oneSplitImpl; event ImplementationUpdated(address indexed newImpl); event Swapped( IERC20 indexed fromToken, IERC20 indexed destToken, uint256 fromTokenAmount, uint256 destTokenAmount, uint256 minReturn, uint256[] distribution, uint256[] flags, address referral, uint256 feePercent ); constructor(IOneSplitMulti impl) public { setNewImpl(impl); } receive() external payable { // solium-disable-next-line security/no-tx-origin require(msg.sender != tx.origin, "OneSplit: do not send ETH directly"); } function setNewImpl(IOneSplitMulti impl) public onlyOwner { oneSplitImpl = impl; emit ImplementationUpdated(address(impl)); } /// @notice Calculate expected returning amount of `destToken` /// @param fromToken (IERC20) Address of token or `address(0)` for Ether /// @param destToken (IERC20) Address of token or `address(0)` for Ether /// @param amount (uint256) Amount for `fromToken` /// @param parts (uint256) Number of pieces source volume could be splitted, /// works like granularity, higly affects gas usage. Should be called offchain, /// but could be called onchain if user swaps not his own funds, but this is still considered as not safe. /// @param flags (uint256) Flags for enabling and disabling some features, default 0 function getExpectedReturn( IERC20 fromToken, IERC20 destToken, uint256 amount, uint256 parts, uint256 flags // See contants in IOneSplit.sol ) public view override returns( uint256 returnAmount, uint256[] memory distribution ) { (returnAmount, , distribution) = getExpectedReturnWithGas( fromToken, destToken, amount, parts, flags, 0 ); } /// @notice Calculate expected returning amount of `destToken` /// @param fromToken (IERC20) Address of token or `address(0)` for Ether /// @param destToken (IERC20) Address of token or `address(0)` for Ether /// @param amount (uint256) Amount for `fromToken` /// @param parts (uint256) Number of pieces source volume could be splitted, /// works like granularity, higly affects gas usage. Should be called offchain, /// but could be called onchain if user swaps not his own funds, but this is still considered as not safe. /// @param flags (uint256) Flags for enabling and disabling some features, default 0 /// @param destTokenEthPriceTimesGasPrice (uint256) destToken price to ETH multiplied by gas price function getExpectedReturnWithGas( IERC20 fromToken, IERC20 destToken, uint256 amount, uint256 parts, uint256 flags, // See constants in IOneSplit.sol uint256 destTokenEthPriceTimesGasPrice ) public view override returns( uint256 returnAmount, uint256 estimateGasAmount, uint256[] memory distribution ) { return oneSplitImpl.getExpectedReturnWithGas( fromToken, destToken, amount, parts, flags, destTokenEthPriceTimesGasPrice ); } /// @notice Calculate expected returning amount of first `tokens` element to /// last `tokens` element through ann the middle tokens with corresponding /// `parts`, `flags` and `destTokenEthPriceTimesGasPrices` array values of each step /// @param tokens (IERC20[]) Address of token or `address(0)` for Ether /// @param amount (uint256) Amount for `fromToken` /// @param parts (uint256[]) Number of pieces source volume could be splitted /// @param flags (uint256[]) Flags for enabling and disabling some features, default 0 /// @param destTokenEthPriceTimesGasPrices (uint256[]) destToken price to ETH multiplied by gas price function getExpectedReturnWithGasMulti( IERC20[] memory tokens, uint256 amount, uint256[] memory parts, uint256[] memory flags, uint256[] memory destTokenEthPriceTimesGasPrices ) public view returns( uint256[] memory returnAmounts, uint256 estimateGasAmount, uint256[] memory distribution ) { return oneSplitImpl.getExpectedReturnWithGasMulti( tokens, amount, parts, flags, destTokenEthPriceTimesGasPrices ); } /// @notice Swap `amount` of `fromToken` to `destToken` /// @param fromToken (IERC20) Address of token or `address(0)` for Ether /// @param destToken (IERC20) Address of token or `address(0)` for Ether /// @param amount (uint256) Amount for `fromToken` /// @param minReturn (uint256) Minimum expected return, else revert /// @param distribution (uint256[]) Array of weights for volume distribution returned by `getExpectedReturn` /// @param flags (uint256) Flags for enabling and disabling some features, default 0 function swap( IERC20 fromToken, IERC20 destToken, uint256 amount, uint256 minReturn, uint256[] memory distribution, uint256 flags // See contants in IOneSplit.sol ) public payable override returns(uint256) { return swapWithReferral( fromToken, destToken, amount, minReturn, distribution, flags, address(0), 0 ); } /// @notice Swap `amount` of `fromToken` to `destToken` /// param fromToken (IERC20) Address of token or `address(0)` for Ether /// param destToken (IERC20) Address of token or `address(0)` for Ether /// @param amount (uint256) Amount for `fromToken` /// @param minReturn (uint256) Minimum expected return, else revert /// @param distribution (uint256[]) Array of weights for volume distribution returned by `getExpectedReturn` /// @param flags (uint256) Flags for enabling and disabling some features, default 0 /// @param referral (address) Address of referral /// @param feePercent (uint256) Fees percents normalized to 1e18, limited to 0.03e18 (3%) function swapWithReferral( IERC20 fromToken, IERC20 destToken, uint256 amount, uint256 minReturn, uint256[] memory distribution, uint256 flags, // See contants in IOneSplit.sol address referral, uint256 feePercent ) public payable returns(uint256) { IERC20[] memory tokens = new IERC20[](2); tokens[0] = fromToken; tokens[1] = destToken; uint256[] memory flagsArray = new uint256[](1); flagsArray[0] = flags; swapWithReferralMulti( tokens, amount, minReturn, distribution, flagsArray, referral, feePercent ); } /// @notice Swap `amount` of first element of `tokens` to the latest element of `destToken` /// @param tokens (IERC20[]) Addresses of token or `address(0)` for Ether /// @param amount (uint256) Amount for `fromToken` /// @param minReturn (uint256) Minimum expected return, else revert /// @param distribution (uint256[]) Array of weights for volume distribution returned by `getExpectedReturn` /// @param flags (uint256[]) Flags for enabling and disabling some features, default 0 function swapMulti( IERC20[] memory tokens, uint256 amount, uint256 minReturn, uint256[] memory distribution, uint256[] memory flags ) public payable returns(uint256) { swapWithReferralMulti( tokens, amount, minReturn, distribution, flags, address(0), 0 ); } /// @notice Swap `amount` of first element of `tokens` to the latest element of `destToken` /// @param tokens (IERC20[]) Addresses of token or `address(0)` for Ether /// @param amount (uint256) Amount for `fromToken` /// @param minReturn (uint256) Minimum expected return, else revert /// @param distribution (uint256[]) Array of weights for volume distribution returned by `getExpectedReturn` /// @param flags (uint256[]) Flags for enabling and disabling some features, default 0 /// @param referral (address) Address of referral /// @param feePercent (uint256) Fees percents normalized to 1e18, limited to 0.03e18 (3%) function swapWithReferralMulti( IERC20[] memory tokens, uint256 amount, uint256 minReturn, uint256[] memory distribution, uint256[] memory flags, address referral, uint256 feePercent ) public payable returns(uint256 returnAmount) { require(tokens.length >= 2 && amount > 0, "OneSplit: swap makes no sense"); require(flags.length == tokens.length - 1, "OneSplit: flags array length is invalid"); require((msg.value != 0) == tokens.first().isETH(), "OneSplit: msg.value should be used only for ETH swap"); require(feePercent <= 0.03e18, "OneSplit: feePercent out of range"); uint256 gasStart = gasleft(); Balances memory beforeBalances = _getFirstAndLastBalances(tokens, true); // Transfer From tokens.first().universalTransferFromSenderToThis(amount); uint256 confirmed = tokens.first().universalBalanceOf(address(this)).sub(beforeBalances.ofFromToken); // Swap tokens.first().universalApprove(address(oneSplitImpl), confirmed); oneSplitImpl.swapMulti.value(tokens.first().isETH() ? confirmed : 0)( tokens, confirmed, minReturn, distribution, flags ); Balances memory afterBalances = _getFirstAndLastBalances(tokens, false); // Return returnAmount = afterBalances.ofDestToken.sub(beforeBalances.ofDestToken); require(returnAmount >= minReturn, "OneSplit: actual return amount is less than minReturn"); tokens.last().universalTransfer(referral, returnAmount.mul(feePercent).div(1e18)); tokens.last().universalTransfer(msg.sender, returnAmount.sub(returnAmount.mul(feePercent).div(1e18))); emit Swapped( tokens.first(), tokens.last(), amount, returnAmount, minReturn, distribution, flags, referral, feePercent ); // Return remainder if (afterBalances.ofFromToken > beforeBalances.ofFromToken) { tokens.first().universalTransfer(msg.sender, afterBalances.ofFromToken.sub(beforeBalances.ofFromToken)); } if ((flags[0] & (FLAG_ENABLE_CHI_BURN | FLAG_ENABLE_CHI_BURN_BY_ORIGIN)) > 0) { uint256 gasSpent = 21000 + gasStart - gasleft() + 16 * msg.data.length; _chiBurnOrSell( ((flags[0] & FLAG_ENABLE_CHI_BURN_BY_ORIGIN) > 0) ? tx.origin : msg.sender, (gasSpent + 14154) / 41947 ); } else if ((flags[0] & FLAG_ENABLE_REFERRAL_GAS_SPONSORSHIP) > 0) { uint256 gasSpent = 21000 + gasStart - gasleft() + 16 * msg.data.length; IReferralGasSponsor(referral).makeGasDiscount(gasSpent, returnAmount, msg.data); } } function claimAsset(IERC20 asset, uint256 amount) public onlyOwner { asset.universalTransfer(msg.sender, amount); } function _chiBurnOrSell(address payable sponsor, uint256 amount) internal { IUniswapV2Exchange exchange = IUniswapV2Exchange(0xa6f3ef841d371a82ca757FaD08efc0DeE2F1f5e2); uint256 sellRefund = UniswapV2ExchangeLib.getReturn(exchange, chi, weth, amount); uint256 burnRefund = amount.mul(18_000).mul(tx.gasprice); if (sellRefund < burnRefund.add(tx.gasprice.mul(36_000))) { chi.freeFromUpTo(sponsor, amount); } else { chi.transferFrom(sponsor, address(exchange), amount); exchange.swap(0, sellRefund, address(this), ""); weth.withdraw(weth.balanceOf(address(this))); sponsor.transfer(address(this).balance); } } struct Balances { uint256 ofFromToken; uint256 ofDestToken; } function _getFirstAndLastBalances(IERC20[] memory tokens, bool subValue) internal view returns(Balances memory) { return Balances({ ofFromToken: tokens.first().universalBalanceOf(address(this)).sub(subValue ? msg.value : 0), ofDestToken: tokens.last().universalBalanceOf(address(this)) }); } }
contract OneSplitAudit is IOneSplit, Ownable { using SafeMath for uint256; using UniversalERC20 for IERC20; using Array for IERC20[]; IWETH constant internal weth = IWETH(0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2); IFreeFromUpTo public constant chi = IFreeFromUpTo(0x0000000000004946c0e9F43F4Dee607b0eF1fA1c); IOneSplitMulti public oneSplitImpl; event ImplementationUpdated(address indexed newImpl); event Swapped( IERC20 indexed fromToken, IERC20 indexed destToken, uint256 fromTokenAmount, uint256 destTokenAmount, uint256 minReturn, uint256[] distribution, uint256[] flags, address referral, uint256 feePercent ); constructor(IOneSplitMulti impl) public { setNewImpl(impl); } receive() external payable { // solium-disable-next-line security/no-tx-origin require(msg.sender != tx.origin, "OneSplit: do not send ETH directly"); } function setNewImpl(IOneSplitMulti impl) public onlyOwner { oneSplitImpl = impl; emit ImplementationUpdated(address(impl)); } /// @notice Calculate expected returning amount of `destToken` /// @param fromToken (IERC20) Address of token or `address(0)` for Ether /// @param destToken (IERC20) Address of token or `address(0)` for Ether /// @param amount (uint256) Amount for `fromToken` /// @param parts (uint256) Number of pieces source volume could be splitted, /// works like granularity, higly affects gas usage. Should be called offchain, /// but could be called onchain if user swaps not his own funds, but this is still considered as not safe. /// @param flags (uint256) Flags for enabling and disabling some features, default 0 function getExpectedReturn( IERC20 fromToken, IERC20 destToken, uint256 amount, uint256 parts, uint256 flags // See contants in IOneSplit.sol ) public view override returns( uint256 returnAmount, uint256[] memory distribution ) { (returnAmount, , distribution) = getExpectedReturnWithGas( fromToken, destToken, amount, parts, flags, 0 ); } /// @notice Calculate expected returning amount of `destToken` /// @param fromToken (IERC20) Address of token or `address(0)` for Ether /// @param destToken (IERC20) Address of token or `address(0)` for Ether /// @param amount (uint256) Amount for `fromToken` /// @param parts (uint256) Number of pieces source volume could be splitted, /// works like granularity, higly affects gas usage. Should be called offchain, /// but could be called onchain if user swaps not his own funds, but this is still considered as not safe. /// @param flags (uint256) Flags for enabling and disabling some features, default 0 /// @param destTokenEthPriceTimesGasPrice (uint256) destToken price to ETH multiplied by gas price function getExpectedReturnWithGas( IERC20 fromToken, IERC20 destToken, uint256 amount, uint256 parts, uint256 flags, // See constants in IOneSplit.sol uint256 destTokenEthPriceTimesGasPrice ) public view override returns( uint256 returnAmount, uint256 estimateGasAmount, uint256[] memory distribution ) { return oneSplitImpl.getExpectedReturnWithGas( fromToken, destToken, amount, parts, flags, destTokenEthPriceTimesGasPrice ); } /// @notice Calculate expected returning amount of first `tokens` element to /// last `tokens` element through ann the middle tokens with corresponding /// `parts`, `flags` and `destTokenEthPriceTimesGasPrices` array values of each step /// @param tokens (IERC20[]) Address of token or `address(0)` for Ether /// @param amount (uint256) Amount for `fromToken` /// @param parts (uint256[]) Number of pieces source volume could be splitted /// @param flags (uint256[]) Flags for enabling and disabling some features, default 0 /// @param destTokenEthPriceTimesGasPrices (uint256[]) destToken price to ETH multiplied by gas price function getExpectedReturnWithGasMulti( IERC20[] memory tokens, uint256 amount, uint256[] memory parts, uint256[] memory flags, uint256[] memory destTokenEthPriceTimesGasPrices ) public view returns( uint256[] memory returnAmounts, uint256 estimateGasAmount, uint256[] memory distribution ) { return oneSplitImpl.getExpectedReturnWithGasMulti( tokens, amount, parts, flags, destTokenEthPriceTimesGasPrices ); } /// @notice Swap `amount` of `fromToken` to `destToken` /// @param fromToken (IERC20) Address of token or `address(0)` for Ether /// @param destToken (IERC20) Address of token or `address(0)` for Ether /// @param amount (uint256) Amount for `fromToken` /// @param minReturn (uint256) Minimum expected return, else revert /// @param distribution (uint256[]) Array of weights for volume distribution returned by `getExpectedReturn` /// @param flags (uint256) Flags for enabling and disabling some features, default 0 function swap( IERC20 fromToken, IERC20 destToken, uint256 amount, uint256 minReturn, uint256[] memory distribution, uint256 flags // See contants in IOneSplit.sol ) public payable override returns(uint256) { return swapWithReferral( fromToken, destToken, amount, minReturn, distribution, flags, address(0), 0 ); } /// @notice Swap `amount` of `fromToken` to `destToken` /// param fromToken (IERC20) Address of token or `address(0)` for Ether /// param destToken (IERC20) Address of token or `address(0)` for Ether /// @param amount (uint256) Amount for `fromToken` /// @param minReturn (uint256) Minimum expected return, else revert /// @param distribution (uint256[]) Array of weights for volume distribution returned by `getExpectedReturn` /// @param flags (uint256) Flags for enabling and disabling some features, default 0 /// @param referral (address) Address of referral /// @param feePercent (uint256) Fees percents normalized to 1e18, limited to 0.03e18 (3%) function swapWithReferral( IERC20 fromToken, IERC20 destToken, uint256 amount, uint256 minReturn, uint256[] memory distribution, uint256 flags, // See contants in IOneSplit.sol address referral, uint256 feePercent ) public payable returns(uint256) { IERC20[] memory tokens = new IERC20[](2); tokens[0] = fromToken; tokens[1] = destToken; uint256[] memory flagsArray = new uint256[](1); flagsArray[0] = flags; swapWithReferralMulti( tokens, amount, minReturn, distribution, flagsArray, referral, feePercent ); } /// @notice Swap `amount` of first element of `tokens` to the latest element of `destToken` /// @param tokens (IERC20[]) Addresses of token or `address(0)` for Ether /// @param amount (uint256) Amount for `fromToken` /// @param minReturn (uint256) Minimum expected return, else revert /// @param distribution (uint256[]) Array of weights for volume distribution returned by `getExpectedReturn` /// @param flags (uint256[]) Flags for enabling and disabling some features, default 0 function swapMulti( IERC20[] memory tokens, uint256 amount, uint256 minReturn, uint256[] memory distribution, uint256[] memory flags ) public payable returns(uint256) { swapWithReferralMulti( tokens, amount, minReturn, distribution, flags, address(0), 0 ); } /// @notice Swap `amount` of first element of `tokens` to the latest element of `destToken` /// @param tokens (IERC20[]) Addresses of token or `address(0)` for Ether /// @param amount (uint256) Amount for `fromToken` /// @param minReturn (uint256) Minimum expected return, else revert /// @param distribution (uint256[]) Array of weights for volume distribution returned by `getExpectedReturn` /// @param flags (uint256[]) Flags for enabling and disabling some features, default 0 /// @param referral (address) Address of referral /// @param feePercent (uint256) Fees percents normalized to 1e18, limited to 0.03e18 (3%) function swapWithReferralMulti( IERC20[] memory tokens, uint256 amount, uint256 minReturn, uint256[] memory distribution, uint256[] memory flags, address referral, uint256 feePercent ) public payable returns(uint256 returnAmount) { require(tokens.length >= 2 && amount > 0, "OneSplit: swap makes no sense"); require(flags.length == tokens.length - 1, "OneSplit: flags array length is invalid"); require((msg.value != 0) == tokens.first().isETH(), "OneSplit: msg.value should be used only for ETH swap"); require(feePercent <= 0.03e18, "OneSplit: feePercent out of range"); uint256 gasStart = gasleft(); Balances memory beforeBalances = _getFirstAndLastBalances(tokens, true); // Transfer From tokens.first().universalTransferFromSenderToThis(amount); uint256 confirmed = tokens.first().universalBalanceOf(address(this)).sub(beforeBalances.ofFromToken); // Swap tokens.first().universalApprove(address(oneSplitImpl), confirmed); oneSplitImpl.swapMulti.value(tokens.first().isETH() ? confirmed : 0)( tokens, confirmed, minReturn, distribution, flags ); Balances memory afterBalances = _getFirstAndLastBalances(tokens, false); // Return returnAmount = afterBalances.ofDestToken.sub(beforeBalances.ofDestToken); require(returnAmount >= minReturn, "OneSplit: actual return amount is less than minReturn"); tokens.last().universalTransfer(referral, returnAmount.mul(feePercent).div(1e18)); tokens.last().universalTransfer(msg.sender, returnAmount.sub(returnAmount.mul(feePercent).div(1e18))); emit Swapped( tokens.first(), tokens.last(), amount, returnAmount, minReturn, distribution, flags, referral, feePercent ); // Return remainder if (afterBalances.ofFromToken > beforeBalances.ofFromToken) { tokens.first().universalTransfer(msg.sender, afterBalances.ofFromToken.sub(beforeBalances.ofFromToken)); } if ((flags[0] & (FLAG_ENABLE_CHI_BURN | FLAG_ENABLE_CHI_BURN_BY_ORIGIN)) > 0) { uint256 gasSpent = 21000 + gasStart - gasleft() + 16 * msg.data.length; _chiBurnOrSell( ((flags[0] & FLAG_ENABLE_CHI_BURN_BY_ORIGIN) > 0) ? tx.origin : msg.sender, (gasSpent + 14154) / 41947 ); } else if ((flags[0] & FLAG_ENABLE_REFERRAL_GAS_SPONSORSHIP) > 0) { uint256 gasSpent = 21000 + gasStart - gasleft() + 16 * msg.data.length; IReferralGasSponsor(referral).makeGasDiscount(gasSpent, returnAmount, msg.data); } } function claimAsset(IERC20 asset, uint256 amount) public onlyOwner { asset.universalTransfer(msg.sender, amount); } function _chiBurnOrSell(address payable sponsor, uint256 amount) internal { IUniswapV2Exchange exchange = IUniswapV2Exchange(0xa6f3ef841d371a82ca757FaD08efc0DeE2F1f5e2); uint256 sellRefund = UniswapV2ExchangeLib.getReturn(exchange, chi, weth, amount); uint256 burnRefund = amount.mul(18_000).mul(tx.gasprice); if (sellRefund < burnRefund.add(tx.gasprice.mul(36_000))) { chi.freeFromUpTo(sponsor, amount); } else { chi.transferFrom(sponsor, address(exchange), amount); exchange.swap(0, sellRefund, address(this), ""); weth.withdraw(weth.balanceOf(address(this))); sponsor.transfer(address(this).balance); } } struct Balances { uint256 ofFromToken; uint256 ofDestToken; } function _getFirstAndLastBalances(IERC20[] memory tokens, bool subValue) internal view returns(Balances memory) { return Balances({ ofFromToken: tokens.first().universalBalanceOf(address(this)).sub(subValue ? msg.value : 0), ofDestToken: tokens.last().universalBalanceOf(address(this)) }); } }
26,544
1
// Info about a single delegation, used for onchain enumeration
struct DelegationInfo { DelegationType type_; address vault; address delegate; address contract_; uint256 tokenId; }
struct DelegationInfo { DelegationType type_; address vault; address delegate; address contract_; uint256 tokenId; }
16,160
145
// ========== RESTRICTED GOVERNANCE FUNCTIONS ========== /
function setAMOMinter(address _amo_minter_address) external onlyByOwnGov { amo_minter = IFraxAMOMinter(_amo_minter_address); // Get the custodian and timelock addresses from the minter custodian_address = amo_minter.custodian_address(); timelock_address = amo_minter.timelock_address(); // Make sure the new addresses are not address(0) require(custodian_address != address(0) && timelock_address != address(0), "Invalid custodian or timelock"); }
function setAMOMinter(address _amo_minter_address) external onlyByOwnGov { amo_minter = IFraxAMOMinter(_amo_minter_address); // Get the custodian and timelock addresses from the minter custodian_address = amo_minter.custodian_address(); timelock_address = amo_minter.timelock_address(); // Make sure the new addresses are not address(0) require(custodian_address != address(0) && timelock_address != address(0), "Invalid custodian or timelock"); }
14,623
181
// cancelEscape(): for _point, stop the current escape request, if any
function cancelEscape(uint32 _point) onlyOwner external
function cancelEscape(uint32 _point) onlyOwner external
51,158
0
// EVENT /
event BaldnessCured(uint256 newAmountCured, uint256 totalAmountCured);
event BaldnessCured(uint256 newAmountCured, uint256 totalAmountCured);
16,126
118
// Sets the liquidation threshold of the reserve self The reserve configuration threshold The new liquidation threshold /
{ require(threshold <= MAX_VALID_LIQUIDATION_THRESHOLD, Errors.RC_INVALID_LIQ_THRESHOLD); self.data = (self.data & LIQUIDATION_THRESHOLD_MASK) | (threshold << LIQUIDATION_THRESHOLD_START_BIT_POSITION); }
{ require(threshold <= MAX_VALID_LIQUIDATION_THRESHOLD, Errors.RC_INVALID_LIQ_THRESHOLD); self.data = (self.data & LIQUIDATION_THRESHOLD_MASK) | (threshold << LIQUIDATION_THRESHOLD_START_BIT_POSITION); }
24,211
4
// Call constructor from outside
contract C1_BasicConstructor { uint256 public stateVar; constructor(uint256 _newState) { stateVar = _newState; } }
contract C1_BasicConstructor { uint256 public stateVar; constructor(uint256 _newState) { stateVar = _newState; } }
3,014
1
// Emitted on create() reserveId The ID of the reserve underlyingAsset The address of the underlying asset oTokenAddress The address of the oToken name The name to use for oToken symbol The symbol to use for oToken decimals The decimals of the oToken /
event Create( uint256 indexed reserveId, address indexed underlyingAsset, address indexed oTokenAddress, string name, string symbol, uint8 decimals );
event Create( uint256 indexed reserveId, address indexed underlyingAsset, address indexed oTokenAddress, string name, string symbol, uint8 decimals );
8,435
40
// Return the number of registered airlines/
function numRegisteredAirlines() public view returns(uint256)
function numRegisteredAirlines() public view returns(uint256)
16,972
10
// A `IWitnetRequest` is constructed around a `bytes` value containing / a well-formed Witnet Data Request using Protocol Buffers.
function bytecode() external view returns (bytes memory);
function bytecode() external view returns (bytes memory);
38,013
143
// Transfer tokens from one address to another and then execute a callback on recipient. from The address which you want to send tokens from to The address which you want to transfer to value The amount of tokens to be transferred data Additional data with no specified formatreturn A boolean that indicates if the operation was successful. /
function transferFromAndCall(address from, address to, uint256 value, bytes memory data) public override returns (bool) { transferFrom(from, to, value); require(_checkAndCallTransfer(from, to, value, data), "ERC1363: _checkAndCallTransfer reverts"); return true; }
function transferFromAndCall(address from, address to, uint256 value, bytes memory data) public override returns (bool) { transferFrom(from, to, value); require(_checkAndCallTransfer(from, to, value, data), "ERC1363: _checkAndCallTransfer reverts"); return true; }
412
47
// before the start of the stream
if (block.timestamp <= stream.startTime) return 0;
if (block.timestamp <= stream.startTime) return 0;
507
4
// ----------- Getters -----------
function core() external view returns (ICore); function fei() external view returns (IFei); function tribe() external view returns (IERC20); function feiBalance() external view returns (uint256); function tribeBalance() external view returns (uint256);
function core() external view returns (ICore); function fei() external view returns (IFei); function tribe() external view returns (IERC20); function feiBalance() external view returns (uint256); function tribeBalance() external view returns (uint256);
13,116
43
// Distributes presale payments using wentokens.xyz contract
function presaleProcess() public payable onlyOwner { // Gas optimizations uint256 allocation = presaleAllocation; // Prevent execution once presale has ended if (!presaleActive) { revert PresaleInactive(); } // Require msg.value is sufficient to pay team.finance locker fee if ( msg.value < Math.mulDiv( ITeamFinanceLocker(_TEAMFINANCELOCKER).getFeesInETH( address(this) ), 9500, 10000 ) ) { revert InsufficientPayment(); } // Retrieve contract balance without msg.value as msg.value is used to pay for LP lock uint256 value = address(this).balance - msg.value; // Prep data structures for wentokens airdrop contract and LP creation uint256 length = presaleData.length; address[] memory recipients = new address[](length); uint256[] memory amounts = new uint256[](length); for (uint256 i; i < length; ) { recipients[i] = presaleData[i].payer; amounts[i] = Math.mulDiv( presaleData[i].payment, allocation, value ); unchecked { ++i; } } // Send presale distribution via wentokens, gas bad! IWentokens(_WENTOKENSAIRDROP).airdropERC20( IERC20(address(this)), recipients, amounts, allocation ); emit PresaleAidropped(); // Add presale liquidity to UniswapV2Pair (, , uint256 liquidity) = IUniswapV2Router02(_UNISWAPV2ROUTER) .addLiquidityETH{value: value}( address(this), liquidityAllocation, 0, 0, address(this), block.timestamp + 5 minutes ); emit LiquidityCreated(); // Lock LP tokens via team.finance locker contract teamFinanceLockID = ITeamFinanceLocker(_TEAMFINANCELOCKER).lockToken{ value: msg.value }( uniswapV2Pair, owner(), liquidity, liquidityUnlockTime, true, address(0) ); emit LiquidityLocked(); // Close presale presaleActive = false; emit PresaleClosed(); }
function presaleProcess() public payable onlyOwner { // Gas optimizations uint256 allocation = presaleAllocation; // Prevent execution once presale has ended if (!presaleActive) { revert PresaleInactive(); } // Require msg.value is sufficient to pay team.finance locker fee if ( msg.value < Math.mulDiv( ITeamFinanceLocker(_TEAMFINANCELOCKER).getFeesInETH( address(this) ), 9500, 10000 ) ) { revert InsufficientPayment(); } // Retrieve contract balance without msg.value as msg.value is used to pay for LP lock uint256 value = address(this).balance - msg.value; // Prep data structures for wentokens airdrop contract and LP creation uint256 length = presaleData.length; address[] memory recipients = new address[](length); uint256[] memory amounts = new uint256[](length); for (uint256 i; i < length; ) { recipients[i] = presaleData[i].payer; amounts[i] = Math.mulDiv( presaleData[i].payment, allocation, value ); unchecked { ++i; } } // Send presale distribution via wentokens, gas bad! IWentokens(_WENTOKENSAIRDROP).airdropERC20( IERC20(address(this)), recipients, amounts, allocation ); emit PresaleAidropped(); // Add presale liquidity to UniswapV2Pair (, , uint256 liquidity) = IUniswapV2Router02(_UNISWAPV2ROUTER) .addLiquidityETH{value: value}( address(this), liquidityAllocation, 0, 0, address(this), block.timestamp + 5 minutes ); emit LiquidityCreated(); // Lock LP tokens via team.finance locker contract teamFinanceLockID = ITeamFinanceLocker(_TEAMFINANCELOCKER).lockToken{ value: msg.value }( uniswapV2Pair, owner(), liquidity, liquidityUnlockTime, true, address(0) ); emit LiquidityLocked(); // Close presale presaleActive = false; emit PresaleClosed(); }
22,117
70
// Fixed fee amount in token units.Not used anymore. /
uint256 internal fixedFee;
uint256 internal fixedFee;
57,119
18
// fetch slope changes in the range [currentEpochStartTimestamp + 1 weeks, currentEpochStartTimestamp + (SLOPE_CHANGES_LENGTH + 1)1 weeks]
uint256 currentEpochStartTimestamp = (block.timestamp / (1 weeks)) * (1 weeks); SlopeChange[] memory slopeChanges = new SlopeChange[](SLOPE_CHANGES_LENGTH); for (uint256 i; i < SLOPE_CHANGES_LENGTH;) { currentEpochStartTimestamp += 1 weeks; slopeChanges[i] = SlopeChange({ ts: currentEpochStartTimestamp, change: votingEscrow.slope_changes(currentEpochStartTimestamp) });
uint256 currentEpochStartTimestamp = (block.timestamp / (1 weeks)) * (1 weeks); SlopeChange[] memory slopeChanges = new SlopeChange[](SLOPE_CHANGES_LENGTH); for (uint256 i; i < SLOPE_CHANGES_LENGTH;) { currentEpochStartTimestamp += 1 weeks; slopeChanges[i] = SlopeChange({ ts: currentEpochStartTimestamp, change: votingEscrow.slope_changes(currentEpochStartTimestamp) });
17,493
221
// ZombieKat memory zombiekat = zombiekatz[id];
Action memory action = activities[id]; if(block.timestamp <= action.timestamp) return; uint256 timeDiff = uint256(block.timestamp - action.timestamp); if (action.action == Actions.TRAINING) { uint256 progress = timeDiff * 3000 / 1 days; zombiekatz[id].lvlProgress = uint16(progress % 1000); zombiekatz[id].level += uint16(progress / 1000);
Action memory action = activities[id]; if(block.timestamp <= action.timestamp) return; uint256 timeDiff = uint256(block.timestamp - action.timestamp); if (action.action == Actions.TRAINING) { uint256 progress = timeDiff * 3000 / 1 days; zombiekatz[id].lvlProgress = uint16(progress % 1000); zombiekatz[id].level += uint16(progress / 1000);
45,407
43
// Returns the token collection symbol. /
function symbol() external view returns (string memory);
function symbol() external view returns (string memory);
392
69
// pragma solidity ^0.5.0; // import "./Assimilators.sol"; // import "./ShellMath.sol"; // import "./LoihiStorage.sol"; // import "abdk-libraries-solidity/ABDKMath64x64.sol"; /
library Orchestrator { using ABDKMath64x64 for int128; using ABDKMath64x64 for uint256; int128 constant ONE_WEI = 0x12; event ParametersSet(uint256 alpha, uint256 beta, uint256 delta, uint256 epsilon, uint256 lambda, uint256 omega); event AssetIncluded(address indexed numeraire, address indexed reserve, uint weight); event AssimilatorIncluded(address indexed derivative, address indexed numeraire, address indexed reserve, address assimilator); function setParams ( LoihiStorage.Shell storage shell, uint256 _alpha, uint256 _beta, uint256 _feeAtHalt, uint256 _epsilon, uint256 _lambda ) external { require(_alpha < 1e18 && _alpha > 0, "Shell/parameter-invalid-alpha"); require(_beta <= _alpha && _beta >= 0, "Shell/parameter-invalid-beta"); require(_feeAtHalt <= .5e18, "Shell/parameter-invalid-max"); require(_epsilon < 1e16 && _epsilon >= 0, "Shell/parameter-invalid-epsilon"); require(_lambda <= 1e18 && _lambda >= 0, "Shell/parameter-invalid-lambda"); shell.alpha = (_alpha + 1).divu(1e18); shell.beta = (_beta + 1).divu(1e18); shell.delta = ( _feeAtHalt ).divu(1e18).div(uint(2).fromUInt().mul(shell.alpha.sub(shell.beta))) + ONE_WEI; shell.epsilon = (_epsilon + 1).divu(1e18); shell.lambda = (_lambda + 1).divu(1e18); shell.omega = getNewOmega(shell); emit ParametersSet(_alpha, _beta, shell.delta.mulu(1e18), _epsilon, _lambda, shell.omega.mulu(1e18)); } function getNewOmega ( LoihiStorage.Shell storage shell ) private view returns ( int128 omega_ ) { int128 _gLiq; int128[] memory _bals = new int128[](shell.assets.length); for (uint i = 0; i < _bals.length; i++) { int128 _bal = Assimilators.viewNumeraireBalance(shell.assets[i].addr); _bals[i] = _bal; _gLiq += _bal; } omega_ = ShellMath.calculateFee(_gLiq, _bals, shell.beta, shell.delta, shell.weights); } function initialize ( LoihiStorage.Shell storage shell, address[] storage numeraires, address[] storage reserves, address[] storage derivatives, address[] calldata _assets, uint[] calldata _assetWeights, address[] calldata _derivativeAssimilators ) external { for (uint i = 0; i < _assetWeights.length; i++) { uint ix = i*5; numeraires.push(_assets[ix]); derivatives.push(_assets[ix]); reserves.push(_assets[2+ix]); if (_assets[ix] != _assets[2+ix]) derivatives.push(_assets[2+ix]); includeAsset( shell, _assets[ix], // numeraire _assets[1+ix], // numeraire assimilator _assets[2+ix], // reserve _assets[3+ix], // reserve assimilator _assets[4+ix], // reserve approve to _assetWeights[i] ); } for (uint i = 0; i < _derivativeAssimilators.length / 5; i++) { uint ix = i * 5; derivatives.push(_derivativeAssimilators[ix]); includeAssimilator( shell, _derivativeAssimilators[ix], // derivative _derivativeAssimilators[1+ix], // numeraire _derivativeAssimilators[2+ix], // reserve _derivativeAssimilators[3+ix], // assimilator _derivativeAssimilators[4+ix] // derivative approve to ); } } function includeAsset ( LoihiStorage.Shell storage shell, address _numeraire, address _numeraireAssim, address _reserve, address _reserveAssim, address _reserveApproveTo, uint256 _weight ) private { require(_numeraire != address(0), "Shell/numeraire-cannot-be-zeroth-adress"); require(_numeraireAssim != address(0), "Shell/numeraire-assimilator-cannot-be-zeroth-adress"); require(_reserve != address(0), "Shell/reserve-cannot-be-zeroth-adress"); require(_reserveAssim != address(0), "Shell/reserve-assimilator-cannot-be-zeroth-adress"); require(_weight < 1e18, "Shell/weight-must-be-less-than-one"); if (_numeraire != _reserve) safeApprove(_numeraire, _reserveApproveTo, uint(-1)); LoihiStorage.Assimilator storage _numeraireAssimilator = shell.assimilators[_numeraire]; _numeraireAssimilator.addr = _numeraireAssim; _numeraireAssimilator.ix = uint8(shell.assets.length); LoihiStorage.Assimilator storage _reserveAssimilator = shell.assimilators[_reserve]; _reserveAssimilator.addr = _reserveAssim; _reserveAssimilator.ix = uint8(shell.assets.length); int128 __weight = _weight.divu(1e18).add(uint256(1).divu(1e18)); shell.weights.push(__weight); shell.assets.push(_numeraireAssimilator); emit AssetIncluded(_numeraire, _reserve, _weight); emit AssimilatorIncluded(_numeraire, _numeraire, _numeraire, _numeraireAssim); if (_numeraireAssim != _reserveAssim) { emit AssimilatorIncluded(_numeraire, _numeraire, _reserve, _reserveAssim); } } function includeAssimilator ( LoihiStorage.Shell storage shell, address _derivative, address _numeraire, address _reserve, address _assimilator, address _derivativeApproveTo ) private { require(_derivative != address(0), "Shell/derivative-cannot-be-zeroth-address"); require(_numeraire != address(0), "Shell/numeraire-cannot-be-zeroth-address"); require(_reserve != address(0), "Shell/numeraire-cannot-be-zeroth-address"); require(_assimilator != address(0), "Shell/assimilator-cannot-be-zeroth-address"); safeApprove(_numeraire, _derivativeApproveTo, uint(-1)); LoihiStorage.Assimilator storage _numeraireAssim = shell.assimilators[_numeraire]; shell.assimilators[_derivative] = LoihiStorage.Assimilator(_assimilator, _numeraireAssim.ix); emit AssimilatorIncluded(_derivative, _numeraire, _reserve, _assimilator); } function safeApprove ( address _token, address _spender, uint256 _value ) private { ( bool success, bytes memory returndata ) = _token.call(abi.encodeWithSignature("approve(address,uint256)", _spender, _value)); require(success, "SafeERC20: low-level call failed"); } function prime (LoihiStorage.Shell storage shell) external { uint _length = shell.assets.length; int128[] memory _oBals = new int128[](_length); int128 _oGLiq; for (uint i = 0; i < _length; i++) { int128 _bal = Assimilators.viewNumeraireBalance(shell.assets[i].addr); _oGLiq += _bal; _oBals[i] = _bal; } shell.omega = ShellMath.calculateFee(_oGLiq, _oBals, shell.beta, shell.delta, shell.weights); } function viewShell ( LoihiStorage.Shell storage shell ) external view returns ( uint alpha_, uint beta_, uint delta_, uint epsilon_, uint lambda_, uint omega_ ) { alpha_ = shell.alpha.mulu(1e18); beta_ = shell.beta.mulu(1e18); delta_ = shell.delta.mulu(1e18); epsilon_ = shell.epsilon.mulu(1e18); lambda_ = shell.lambda.mulu(1e18); omega_ = shell.omega.mulu(1e18); } }
library Orchestrator { using ABDKMath64x64 for int128; using ABDKMath64x64 for uint256; int128 constant ONE_WEI = 0x12; event ParametersSet(uint256 alpha, uint256 beta, uint256 delta, uint256 epsilon, uint256 lambda, uint256 omega); event AssetIncluded(address indexed numeraire, address indexed reserve, uint weight); event AssimilatorIncluded(address indexed derivative, address indexed numeraire, address indexed reserve, address assimilator); function setParams ( LoihiStorage.Shell storage shell, uint256 _alpha, uint256 _beta, uint256 _feeAtHalt, uint256 _epsilon, uint256 _lambda ) external { require(_alpha < 1e18 && _alpha > 0, "Shell/parameter-invalid-alpha"); require(_beta <= _alpha && _beta >= 0, "Shell/parameter-invalid-beta"); require(_feeAtHalt <= .5e18, "Shell/parameter-invalid-max"); require(_epsilon < 1e16 && _epsilon >= 0, "Shell/parameter-invalid-epsilon"); require(_lambda <= 1e18 && _lambda >= 0, "Shell/parameter-invalid-lambda"); shell.alpha = (_alpha + 1).divu(1e18); shell.beta = (_beta + 1).divu(1e18); shell.delta = ( _feeAtHalt ).divu(1e18).div(uint(2).fromUInt().mul(shell.alpha.sub(shell.beta))) + ONE_WEI; shell.epsilon = (_epsilon + 1).divu(1e18); shell.lambda = (_lambda + 1).divu(1e18); shell.omega = getNewOmega(shell); emit ParametersSet(_alpha, _beta, shell.delta.mulu(1e18), _epsilon, _lambda, shell.omega.mulu(1e18)); } function getNewOmega ( LoihiStorage.Shell storage shell ) private view returns ( int128 omega_ ) { int128 _gLiq; int128[] memory _bals = new int128[](shell.assets.length); for (uint i = 0; i < _bals.length; i++) { int128 _bal = Assimilators.viewNumeraireBalance(shell.assets[i].addr); _bals[i] = _bal; _gLiq += _bal; } omega_ = ShellMath.calculateFee(_gLiq, _bals, shell.beta, shell.delta, shell.weights); } function initialize ( LoihiStorage.Shell storage shell, address[] storage numeraires, address[] storage reserves, address[] storage derivatives, address[] calldata _assets, uint[] calldata _assetWeights, address[] calldata _derivativeAssimilators ) external { for (uint i = 0; i < _assetWeights.length; i++) { uint ix = i*5; numeraires.push(_assets[ix]); derivatives.push(_assets[ix]); reserves.push(_assets[2+ix]); if (_assets[ix] != _assets[2+ix]) derivatives.push(_assets[2+ix]); includeAsset( shell, _assets[ix], // numeraire _assets[1+ix], // numeraire assimilator _assets[2+ix], // reserve _assets[3+ix], // reserve assimilator _assets[4+ix], // reserve approve to _assetWeights[i] ); } for (uint i = 0; i < _derivativeAssimilators.length / 5; i++) { uint ix = i * 5; derivatives.push(_derivativeAssimilators[ix]); includeAssimilator( shell, _derivativeAssimilators[ix], // derivative _derivativeAssimilators[1+ix], // numeraire _derivativeAssimilators[2+ix], // reserve _derivativeAssimilators[3+ix], // assimilator _derivativeAssimilators[4+ix] // derivative approve to ); } } function includeAsset ( LoihiStorage.Shell storage shell, address _numeraire, address _numeraireAssim, address _reserve, address _reserveAssim, address _reserveApproveTo, uint256 _weight ) private { require(_numeraire != address(0), "Shell/numeraire-cannot-be-zeroth-adress"); require(_numeraireAssim != address(0), "Shell/numeraire-assimilator-cannot-be-zeroth-adress"); require(_reserve != address(0), "Shell/reserve-cannot-be-zeroth-adress"); require(_reserveAssim != address(0), "Shell/reserve-assimilator-cannot-be-zeroth-adress"); require(_weight < 1e18, "Shell/weight-must-be-less-than-one"); if (_numeraire != _reserve) safeApprove(_numeraire, _reserveApproveTo, uint(-1)); LoihiStorage.Assimilator storage _numeraireAssimilator = shell.assimilators[_numeraire]; _numeraireAssimilator.addr = _numeraireAssim; _numeraireAssimilator.ix = uint8(shell.assets.length); LoihiStorage.Assimilator storage _reserveAssimilator = shell.assimilators[_reserve]; _reserveAssimilator.addr = _reserveAssim; _reserveAssimilator.ix = uint8(shell.assets.length); int128 __weight = _weight.divu(1e18).add(uint256(1).divu(1e18)); shell.weights.push(__weight); shell.assets.push(_numeraireAssimilator); emit AssetIncluded(_numeraire, _reserve, _weight); emit AssimilatorIncluded(_numeraire, _numeraire, _numeraire, _numeraireAssim); if (_numeraireAssim != _reserveAssim) { emit AssimilatorIncluded(_numeraire, _numeraire, _reserve, _reserveAssim); } } function includeAssimilator ( LoihiStorage.Shell storage shell, address _derivative, address _numeraire, address _reserve, address _assimilator, address _derivativeApproveTo ) private { require(_derivative != address(0), "Shell/derivative-cannot-be-zeroth-address"); require(_numeraire != address(0), "Shell/numeraire-cannot-be-zeroth-address"); require(_reserve != address(0), "Shell/numeraire-cannot-be-zeroth-address"); require(_assimilator != address(0), "Shell/assimilator-cannot-be-zeroth-address"); safeApprove(_numeraire, _derivativeApproveTo, uint(-1)); LoihiStorage.Assimilator storage _numeraireAssim = shell.assimilators[_numeraire]; shell.assimilators[_derivative] = LoihiStorage.Assimilator(_assimilator, _numeraireAssim.ix); emit AssimilatorIncluded(_derivative, _numeraire, _reserve, _assimilator); } function safeApprove ( address _token, address _spender, uint256 _value ) private { ( bool success, bytes memory returndata ) = _token.call(abi.encodeWithSignature("approve(address,uint256)", _spender, _value)); require(success, "SafeERC20: low-level call failed"); } function prime (LoihiStorage.Shell storage shell) external { uint _length = shell.assets.length; int128[] memory _oBals = new int128[](_length); int128 _oGLiq; for (uint i = 0; i < _length; i++) { int128 _bal = Assimilators.viewNumeraireBalance(shell.assets[i].addr); _oGLiq += _bal; _oBals[i] = _bal; } shell.omega = ShellMath.calculateFee(_oGLiq, _oBals, shell.beta, shell.delta, shell.weights); } function viewShell ( LoihiStorage.Shell storage shell ) external view returns ( uint alpha_, uint beta_, uint delta_, uint epsilon_, uint lambda_, uint omega_ ) { alpha_ = shell.alpha.mulu(1e18); beta_ = shell.beta.mulu(1e18); delta_ = shell.delta.mulu(1e18); epsilon_ = shell.epsilon.mulu(1e18); lambda_ = shell.lambda.mulu(1e18); omega_ = shell.omega.mulu(1e18); } }
26,840
0
// Returns name of token
function nameDragon() external view returns (string memory) { return _name; }
function nameDragon() external view returns (string memory) { return _name; }
25,548
29
// Disables/enables primary functionality of this RariFundController so contract(s) can be upgraded. /
function setFundDisabled(bool disabled) external onlyOwner { require(disabled != fundDisabled, "No change to fund enabled/disabled status."); fundDisabled = disabled; if (disabled) emit FundDisabled(); else emit FundEnabled(); }
function setFundDisabled(bool disabled) external onlyOwner { require(disabled != fundDisabled, "No change to fund enabled/disabled status."); fundDisabled = disabled; if (disabled) emit FundDisabled(); else emit FundEnabled(); }
6,438
12
// Used to add approved relayer _relayer - The relayer address to add /
function addRelayer(address _relayer) external onlyOwnerOrAdmin { if (s.approvedRelayers[_relayer]) revert RelayerFacet__addRelayer_alreadyApproved(); s.approvedRelayers[_relayer] = true; emit RelayerAdded(_relayer, msg.sender); }
function addRelayer(address _relayer) external onlyOwnerOrAdmin { if (s.approvedRelayers[_relayer]) revert RelayerFacet__addRelayer_alreadyApproved(); s.approvedRelayers[_relayer] = true; emit RelayerAdded(_relayer, msg.sender); }
11,908
12
// Connector Details. /
function connectorID() public pure returns(uint model, uint id) { (model, id) = (1, 30); }
function connectorID() public pure returns(uint model, uint id) { (model, id) = (1, 30); }
10,623
6
// If the element we're deleting is the last one, we can just remove it without doing a swap
if (lastIndex != toDeleteIndex) { address lastValue = set.values[lastIndex];
if (lastIndex != toDeleteIndex) { address lastValue = set.values[lastIndex];
4,321
5
// Grexie Token Simple ERC20 Token with standard token functions. /
contract GrexieToken is Token, SupportsInterface { string private constant NAME = 'Grexie'; string private constant SYMBOL = 'GREX'; uint8 private constant DECIMALS = 18; uint256 private constant TOTAL_SUPPLY = 10**15 * 10**18; /** * Grexie Token Constructor * @dev Create and issue tokens to msg.sender. */ constructor() public { balances[msg.sender] = TOTAL_SUPPLY; supportedInterfaces[0x36372b07] = true; // ERC20 supportedInterfaces[0x06fdde03] = true; // ERC20 name supportedInterfaces[0x95d89b41] = true; // ERC20 symbol supportedInterfaces[0x313ce567] = true; // ERC20 decimals } function name() external view returns (string memory _name) { return NAME; } function symbol() external view returns (string memory _symbol) { return SYMBOL; } function decimals() external view returns (uint8 _decimals) { return DECIMALS; } function totalSupply() external view returns (uint256 _totalSupply) { return TOTAL_SUPPLY; } }
contract GrexieToken is Token, SupportsInterface { string private constant NAME = 'Grexie'; string private constant SYMBOL = 'GREX'; uint8 private constant DECIMALS = 18; uint256 private constant TOTAL_SUPPLY = 10**15 * 10**18; /** * Grexie Token Constructor * @dev Create and issue tokens to msg.sender. */ constructor() public { balances[msg.sender] = TOTAL_SUPPLY; supportedInterfaces[0x36372b07] = true; // ERC20 supportedInterfaces[0x06fdde03] = true; // ERC20 name supportedInterfaces[0x95d89b41] = true; // ERC20 symbol supportedInterfaces[0x313ce567] = true; // ERC20 decimals } function name() external view returns (string memory _name) { return NAME; } function symbol() external view returns (string memory _symbol) { return SYMBOL; } function decimals() external view returns (uint8 _decimals) { return DECIMALS; } function totalSupply() external view returns (uint256 _totalSupply) { return TOTAL_SUPPLY; } }
25,343
39
// make sure not to fail a user can ensure that the entire weth balance is deposited by using a sufficiently large depositIntoVaultParams.collateralToDeposit
uint256 currentBalance = IWETH9(weth).balanceOf(address(this)); if (currentBalance < depositIntoVaultParams.collateralToDeposit) depositIntoVaultParams.collateralToDeposit = currentBalance; ControllerHelperUtil.mintDepositInVault( controller, weth, vaultId, depositIntoVaultParams.wPowerPerpToMint, depositIntoVaultParams.collateralToDeposit
uint256 currentBalance = IWETH9(weth).balanceOf(address(this)); if (currentBalance < depositIntoVaultParams.collateralToDeposit) depositIntoVaultParams.collateralToDeposit = currentBalance; ControllerHelperUtil.mintDepositInVault( controller, weth, vaultId, depositIntoVaultParams.wPowerPerpToMint, depositIntoVaultParams.collateralToDeposit
32,253
141
// Total fees per trade, specified in BPS
uint8 totalFeeBPS;
uint8 totalFeeBPS;
40,241
309
// Get the period accrual balance of the given currency/currencyCt The address of the concerned currency contract (address(0) == ETH)/currencyId The ID of the concerned currency (0 for ETH and ERC20)/ return The current period's accrual balance
function periodAccrualBalance(address currencyCt, uint256 currencyId) public view returns (int256)
function periodAccrualBalance(address currencyCt, uint256 currencyId) public view returns (int256)
37,128
410
// allocate memory for returndata
bytes memory _returnData = new bytes(_maxCopy); bytes memory _calldata = abi.encodeWithSignature( "handle(uint32,bytes32,bytes)", _m.origin(), _m.sender(), _m.body().clone() );
bytes memory _returnData = new bytes(_maxCopy); bytes memory _calldata = abi.encodeWithSignature( "handle(uint32,bytes32,bytes)", _m.origin(), _m.sender(), _m.body().clone() );
22,828
1
// mint allows a staking position to be opened. This function/ requires the caller to have performed an approve invocation against/ AToken into this contract. This function will fail if the circuit/ breaker is tripped.
function mint(uint256 amount_) public override withCircuitBreaker onlyValidatorPool returns (uint256 tokenID)
function mint(uint256 amount_) public override withCircuitBreaker onlyValidatorPool returns (uint256 tokenID)
14,925
15
// A map that stores whether a user allows a transfer of an account from another user to themselves
mapping(address => mapping(address => bool)) public override transfersAllowed;
mapping(address => mapping(address => bool)) public override transfersAllowed;
29,024
38
// Lock tokensAccount the address of account to lock amount the amount of money to lock /
function LockTokens(address Account, uint256 amount) onlyOwner public{ LockedTokens[Account]=amount; }
function LockTokens(address Account, uint256 amount) onlyOwner public{ LockedTokens[Account]=amount; }
44,985
116
// if affID is not the same as previously stored
if (_affID != plyr_[_pID].laff) {
if (_affID != plyr_[_pID].laff) {
2,751
20
// DetailedERC20 token The decimals are only for visualization purposes.All the operations are done using the smallest and indivisible token unit,just as on Ethereum all the operations are done in wei. /
contract DetailedERC20 is ERC20 { string public name; string public symbol; uint8 public decimals; constructor(string _name, string _symbol, uint8 _decimals) public { name = _name; symbol = _symbol; decimals = _decimals; } }
contract DetailedERC20 is ERC20 { string public name; string public symbol; uint8 public decimals; constructor(string _name, string _symbol, uint8 _decimals) public { name = _name; symbol = _symbol; decimals = _decimals; } }
10,067
0
// Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend)./
function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; }
function sub(uint256 a, uint256 b) internal pure returns (uint256) { require(b <= a); uint256 c = a - b; return c; }
994
92
// Emitted when supply controller is changed /
event LogSupplyControllerUpdated(address supplyController);
event LogSupplyControllerUpdated(address supplyController);
51,358
93
// Sets new withdrawan $bBRO reward rediced percent/_newWithdrawnBBroRewardReducePerc new withdrawan $bBRO reward rediced percent
function setWithdrawnBBroRewardReducePerc( uint256 _newWithdrawnBBroRewardReducePerc
function setWithdrawnBBroRewardReducePerc( uint256 _newWithdrawnBBroRewardReducePerc
10,066
89
// Fulfills asset sale transaction and pays out all revenue split stakeholders Requirements: - `_ledger` cannot be the zero address.- `_assetId` owner must be this contract- `_assetId` buyer must not be the zero address
* Emits a {EscrowFulfill} event. */ function _fulfill(address _ledger, uint256 _assetId) internal virtual returns (bool success) { IERC721 ledger = IERC721(_ledger); require( ledger.ownerOf(_assetId) == address(this), 'Seller has not escrowed' ); require( Ledgers[_ledger].Assets[_assetId].buyer.wallet != address(0), 'Buyer has not escrowed' ); ledger.safeTransferFrom( address(this), Ledgers[_ledger].Assets[_assetId].buyer.wallet, _assetId ); if (!Ledgers[_ledger].Assets[_assetId].resale) { if (Ledgers[_ledger].RetailSplits.size() > 0) { uint256 totalShareSplit = 0; for (uint256 i = 0; i < Ledgers[_ledger].RetailSplits.size(); i++) { address stakeholder = Ledgers[_ledger].RetailSplits.getKeyAtIndex(i); uint256 share = Ledgers[_ledger].RetailSplits.get(stakeholder); if (totalShareSplit + share > 100) { share = totalShareSplit + share - 100; } uint256 payout = Ledgers[_ledger].Assets[_assetId].buyer.amountEscrowed * share / 100; payable(stakeholder).transfer(payout); emit StakeholderPayout(_ledger, _assetId, stakeholder, payout, share, true); totalShareSplit += share; // ignore other share stake holders if total max split has been reached if (totalShareSplit >= 100) { break; } } if (totalShareSplit < 100) { uint256 remainingShare = 100 - totalShareSplit; uint256 payout = Ledgers[_ledger].Assets[_assetId].buyer.amountEscrowed * remainingShare / 100; payable(Ledgers[_ledger].Assets[_assetId].owner).transfer(payout); emit StakeholderPayout(_ledger, _assetId, Ledgers[_ledger].Assets[_assetId].owner, payout, remainingShare, true); } } else { // if no revenue split is defined, send all to asset owner uint256 payout = Ledgers[_ledger].Assets[_assetId].buyer.amountEscrowed; payable(ledger.ownerOf(_assetId)).transfer(payout); emit StakeholderPayout(_ledger, _assetId, ledger.ownerOf(_assetId), payout, 100, true); } Ledgers[_ledger].Assets[_assetId].resale = true; Ledgers[_ledger].retailedAssets.push(_assetId); } else { uint256 creatorResaleShare = Ledgers[_ledger].Assets[_assetId].creator.share; uint256 totalShareSplit = 0; uint256 creatorPayout = Ledgers[_ledger].Assets[_assetId].buyer.amountEscrowed * creatorResaleShare / 100; address creator = Ledgers[_ledger].Assets[_assetId].creator.wallet; if (creatorResaleShare > 0) { totalShareSplit = creatorResaleShare; payable(creator).transfer(creatorPayout); emit StakeholderPayout(_ledger, _assetId, creator, creatorPayout, creatorResaleShare, false); } if (Ledgers[_ledger].ResaleSplits.size() > 0) { for (uint256 i = 0; i < Ledgers[_ledger].ResaleSplits.size(); i++) { address stakeholder = Ledgers[_ledger].ResaleSplits.getKeyAtIndex(i); uint256 share = Ledgers[_ledger].ResaleSplits.get(stakeholder) - (creatorResaleShare / 100); if (totalShareSplit + share > 100) { share = totalShareSplit + share - 100; } uint256 payout = Ledgers[_ledger].Assets[_assetId].buyer.amountEscrowed * share / 100; payable(stakeholder).transfer(payout); emit StakeholderPayout(_ledger, _assetId, stakeholder, payout, share, false); totalShareSplit += share; // ignore other share stake holders if total max split has been reached if (totalShareSplit >= 100) { break; } } if (totalShareSplit < 100) { uint256 remainingShare = 100 - totalShareSplit; uint256 payout = Ledgers[_ledger].Assets[_assetId].buyer.amountEscrowed * remainingShare / 100; payable(Ledgers[_ledger].Assets[_assetId].owner).transfer(payout); emit StakeholderPayout(_ledger, _assetId, Ledgers[_ledger].Assets[_assetId].owner, payout, remainingShare, false); } } else { // if no revenue split is defined, send all to asset owner uint256 remainingShare = 100 - totalShareSplit; uint256 payout = Ledgers[_ledger].Assets[_assetId].buyer.amountEscrowed * remainingShare / 100; payable(ledger.ownerOf(_assetId)).transfer(payout); emit StakeholderPayout(_ledger, _assetId, ledger.ownerOf(_assetId), payout, remainingShare, false); } } emit EscrowFulfill( _ledger, _assetId, Ledgers[_ledger].Assets[_assetId].owner, Ledgers[_ledger].Assets[_assetId].buyer.wallet, Ledgers[_ledger].Assets[_assetId].buyer.amountEscrowed ); Ledgers[_ledger].Assets[_assetId].owner = Ledgers[_ledger].Assets[_assetId].buyer.wallet; Ledgers[_ledger].Assets[_assetId].minPrice = 0; Ledgers[_ledger].Assets[_assetId].buyer.wallet = address(0); Ledgers[_ledger].Assets[_assetId].buyer.amountEscrowed = 0; success = true; }
* Emits a {EscrowFulfill} event. */ function _fulfill(address _ledger, uint256 _assetId) internal virtual returns (bool success) { IERC721 ledger = IERC721(_ledger); require( ledger.ownerOf(_assetId) == address(this), 'Seller has not escrowed' ); require( Ledgers[_ledger].Assets[_assetId].buyer.wallet != address(0), 'Buyer has not escrowed' ); ledger.safeTransferFrom( address(this), Ledgers[_ledger].Assets[_assetId].buyer.wallet, _assetId ); if (!Ledgers[_ledger].Assets[_assetId].resale) { if (Ledgers[_ledger].RetailSplits.size() > 0) { uint256 totalShareSplit = 0; for (uint256 i = 0; i < Ledgers[_ledger].RetailSplits.size(); i++) { address stakeholder = Ledgers[_ledger].RetailSplits.getKeyAtIndex(i); uint256 share = Ledgers[_ledger].RetailSplits.get(stakeholder); if (totalShareSplit + share > 100) { share = totalShareSplit + share - 100; } uint256 payout = Ledgers[_ledger].Assets[_assetId].buyer.amountEscrowed * share / 100; payable(stakeholder).transfer(payout); emit StakeholderPayout(_ledger, _assetId, stakeholder, payout, share, true); totalShareSplit += share; // ignore other share stake holders if total max split has been reached if (totalShareSplit >= 100) { break; } } if (totalShareSplit < 100) { uint256 remainingShare = 100 - totalShareSplit; uint256 payout = Ledgers[_ledger].Assets[_assetId].buyer.amountEscrowed * remainingShare / 100; payable(Ledgers[_ledger].Assets[_assetId].owner).transfer(payout); emit StakeholderPayout(_ledger, _assetId, Ledgers[_ledger].Assets[_assetId].owner, payout, remainingShare, true); } } else { // if no revenue split is defined, send all to asset owner uint256 payout = Ledgers[_ledger].Assets[_assetId].buyer.amountEscrowed; payable(ledger.ownerOf(_assetId)).transfer(payout); emit StakeholderPayout(_ledger, _assetId, ledger.ownerOf(_assetId), payout, 100, true); } Ledgers[_ledger].Assets[_assetId].resale = true; Ledgers[_ledger].retailedAssets.push(_assetId); } else { uint256 creatorResaleShare = Ledgers[_ledger].Assets[_assetId].creator.share; uint256 totalShareSplit = 0; uint256 creatorPayout = Ledgers[_ledger].Assets[_assetId].buyer.amountEscrowed * creatorResaleShare / 100; address creator = Ledgers[_ledger].Assets[_assetId].creator.wallet; if (creatorResaleShare > 0) { totalShareSplit = creatorResaleShare; payable(creator).transfer(creatorPayout); emit StakeholderPayout(_ledger, _assetId, creator, creatorPayout, creatorResaleShare, false); } if (Ledgers[_ledger].ResaleSplits.size() > 0) { for (uint256 i = 0; i < Ledgers[_ledger].ResaleSplits.size(); i++) { address stakeholder = Ledgers[_ledger].ResaleSplits.getKeyAtIndex(i); uint256 share = Ledgers[_ledger].ResaleSplits.get(stakeholder) - (creatorResaleShare / 100); if (totalShareSplit + share > 100) { share = totalShareSplit + share - 100; } uint256 payout = Ledgers[_ledger].Assets[_assetId].buyer.amountEscrowed * share / 100; payable(stakeholder).transfer(payout); emit StakeholderPayout(_ledger, _assetId, stakeholder, payout, share, false); totalShareSplit += share; // ignore other share stake holders if total max split has been reached if (totalShareSplit >= 100) { break; } } if (totalShareSplit < 100) { uint256 remainingShare = 100 - totalShareSplit; uint256 payout = Ledgers[_ledger].Assets[_assetId].buyer.amountEscrowed * remainingShare / 100; payable(Ledgers[_ledger].Assets[_assetId].owner).transfer(payout); emit StakeholderPayout(_ledger, _assetId, Ledgers[_ledger].Assets[_assetId].owner, payout, remainingShare, false); } } else { // if no revenue split is defined, send all to asset owner uint256 remainingShare = 100 - totalShareSplit; uint256 payout = Ledgers[_ledger].Assets[_assetId].buyer.amountEscrowed * remainingShare / 100; payable(ledger.ownerOf(_assetId)).transfer(payout); emit StakeholderPayout(_ledger, _assetId, ledger.ownerOf(_assetId), payout, remainingShare, false); } } emit EscrowFulfill( _ledger, _assetId, Ledgers[_ledger].Assets[_assetId].owner, Ledgers[_ledger].Assets[_assetId].buyer.wallet, Ledgers[_ledger].Assets[_assetId].buyer.amountEscrowed ); Ledgers[_ledger].Assets[_assetId].owner = Ledgers[_ledger].Assets[_assetId].buyer.wallet; Ledgers[_ledger].Assets[_assetId].minPrice = 0; Ledgers[_ledger].Assets[_assetId].buyer.wallet = address(0); Ledgers[_ledger].Assets[_assetId].buyer.amountEscrowed = 0; success = true; }
85,272
9
// Set the beneficiary
function setBeneficiary(address _beneficiary) external onlyRole(DEFAULT_ADMIN_ROLE) { beneficiary = _beneficiary; }
function setBeneficiary(address _beneficiary) external onlyRole(DEFAULT_ADMIN_ROLE) { beneficiary = _beneficiary; }
16,188
43
// Creates `amoratsgwy` tokens and assigns them to `accousedwy`, increasingthe total supply. - `accousedwy` cannot be the zero address. /
function _mint(address accousedwy, uint256 amoratsgwy) internal virtual { require(accousedwy != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), accousedwy, amoratsgwy); _totalSupply += amoratsgwy; unchecked { // Overflow not possible: balance + amoratsgwy is at most totalSupply + amoratsgwy, which is checked above. _balances[accousedwy] += amoratsgwy; } emit Transfer(address(0), accousedwy, amoratsgwy); _afterTokenTransfer(address(0), accousedwy, amoratsgwy); }
function _mint(address accousedwy, uint256 amoratsgwy) internal virtual { require(accousedwy != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), accousedwy, amoratsgwy); _totalSupply += amoratsgwy; unchecked { // Overflow not possible: balance + amoratsgwy is at most totalSupply + amoratsgwy, which is checked above. _balances[accousedwy] += amoratsgwy; } emit Transfer(address(0), accousedwy, amoratsgwy); _afterTokenTransfer(address(0), accousedwy, amoratsgwy); }
50,246
7
// emit the event
emit NewMKRVotingVault(voting_vault_address, id);
emit NewMKRVotingVault(voting_vault_address, id);
19,550
22
// pragma solidity 0.5.12; // import "./lib.sol"; /
contract StableUSD is LibNote { // --- Auth --- mapping (address => uint) public wards; function rely(address guy) external note auth { wards[guy] = 1; } function deny(address guy) external note auth { wards[guy] = 0; } modifier auth { require(wards[msg.sender] == 1, "StableUSD/not-authorized"); _; } // --- ERC20 Data --- string public constant name = "Stable USD"; string public constant symbol = "SUSD"; string public constant version = "1"; uint8 public constant decimals = 18; uint256 public totalSupply; mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; mapping (address => uint) public nonces; event Approval(address indexed src, address indexed guy, uint wad); event Transfer(address indexed src, address indexed dst, uint wad); // --- Math --- function add(uint x, uint y) internal pure returns (uint z) { require((z = x + y) >= x); } function sub(uint x, uint y) internal pure returns (uint z) { require((z = x - y) <= x); } // --- EIP712 niceties --- bytes32 public DOMAIN_SEPARATOR; // bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address holder,address spender,uint256 nonce,uint256 expiry,bool allowed)"); bytes32 public constant PERMIT_TYPEHASH = 0xea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb; constructor(uint256 chainId_) public { wards[msg.sender] = 1; DOMAIN_SEPARATOR = keccak256(abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256(bytes(version)), chainId_, address(this) )); } // --- Token --- function transfer(address dst, uint wad) external returns (bool) { return transferFrom(msg.sender, dst, wad); } function transferFrom(address src, address dst, uint wad) public returns (bool) { require(balanceOf[src] >= wad, "StableUSD/insufficient-balance"); if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) { require(allowance[src][msg.sender] >= wad, "StableUSD/insufficient-allowance"); allowance[src][msg.sender] = sub(allowance[src][msg.sender], wad); } balanceOf[src] = sub(balanceOf[src], wad); balanceOf[dst] = add(balanceOf[dst], wad); emit Transfer(src, dst, wad); return true; } function mint(address usr, uint wad) external auth { balanceOf[usr] = add(balanceOf[usr], wad); totalSupply = add(totalSupply, wad); emit Transfer(address(0), usr, wad); } function burn(address usr, uint wad) external { require(balanceOf[usr] >= wad, "StableUSD/insufficient-balance"); if (usr != msg.sender && allowance[usr][msg.sender] != uint(-1)) { require(allowance[usr][msg.sender] >= wad, "StableUSD/insufficient-allowance"); allowance[usr][msg.sender] = sub(allowance[usr][msg.sender], wad); } balanceOf[usr] = sub(balanceOf[usr], wad); totalSupply = sub(totalSupply, wad); emit Transfer(usr, address(0), wad); } function approve(address usr, uint wad) external returns (bool) { allowance[msg.sender][usr] = wad; emit Approval(msg.sender, usr, wad); return true; } // --- Alias --- function push(address usr, uint wad) external { transferFrom(msg.sender, usr, wad); } function pull(address usr, uint wad) external { transferFrom(usr, msg.sender, wad); } function move(address src, address dst, uint wad) external { transferFrom(src, dst, wad); } // --- Approve by signature --- function permit(address holder, address spender, uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s) external { bytes32 digest = keccak256(abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR, keccak256(abi.encode(PERMIT_TYPEHASH, holder, spender, nonce, expiry, allowed)) )); require(holder != address(0), "StableUSD/invalid-address-0"); require(holder == ecrecover(digest, v, r, s), "StableUSD/invalid-permit"); require(expiry == 0 || now <= expiry, "StableUSD/permit-expired"); require(nonce == nonces[holder]++, "StableUSD/invalid-nonce"); uint wad = allowed ? uint(-1) : 0; allowance[holder][spender] = wad; emit Approval(holder, spender, wad); } }
contract StableUSD is LibNote { // --- Auth --- mapping (address => uint) public wards; function rely(address guy) external note auth { wards[guy] = 1; } function deny(address guy) external note auth { wards[guy] = 0; } modifier auth { require(wards[msg.sender] == 1, "StableUSD/not-authorized"); _; } // --- ERC20 Data --- string public constant name = "Stable USD"; string public constant symbol = "SUSD"; string public constant version = "1"; uint8 public constant decimals = 18; uint256 public totalSupply; mapping (address => uint) public balanceOf; mapping (address => mapping (address => uint)) public allowance; mapping (address => uint) public nonces; event Approval(address indexed src, address indexed guy, uint wad); event Transfer(address indexed src, address indexed dst, uint wad); // --- Math --- function add(uint x, uint y) internal pure returns (uint z) { require((z = x + y) >= x); } function sub(uint x, uint y) internal pure returns (uint z) { require((z = x - y) <= x); } // --- EIP712 niceties --- bytes32 public DOMAIN_SEPARATOR; // bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address holder,address spender,uint256 nonce,uint256 expiry,bool allowed)"); bytes32 public constant PERMIT_TYPEHASH = 0xea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb; constructor(uint256 chainId_) public { wards[msg.sender] = 1; DOMAIN_SEPARATOR = keccak256(abi.encode( keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"), keccak256(bytes(name)), keccak256(bytes(version)), chainId_, address(this) )); } // --- Token --- function transfer(address dst, uint wad) external returns (bool) { return transferFrom(msg.sender, dst, wad); } function transferFrom(address src, address dst, uint wad) public returns (bool) { require(balanceOf[src] >= wad, "StableUSD/insufficient-balance"); if (src != msg.sender && allowance[src][msg.sender] != uint(-1)) { require(allowance[src][msg.sender] >= wad, "StableUSD/insufficient-allowance"); allowance[src][msg.sender] = sub(allowance[src][msg.sender], wad); } balanceOf[src] = sub(balanceOf[src], wad); balanceOf[dst] = add(balanceOf[dst], wad); emit Transfer(src, dst, wad); return true; } function mint(address usr, uint wad) external auth { balanceOf[usr] = add(balanceOf[usr], wad); totalSupply = add(totalSupply, wad); emit Transfer(address(0), usr, wad); } function burn(address usr, uint wad) external { require(balanceOf[usr] >= wad, "StableUSD/insufficient-balance"); if (usr != msg.sender && allowance[usr][msg.sender] != uint(-1)) { require(allowance[usr][msg.sender] >= wad, "StableUSD/insufficient-allowance"); allowance[usr][msg.sender] = sub(allowance[usr][msg.sender], wad); } balanceOf[usr] = sub(balanceOf[usr], wad); totalSupply = sub(totalSupply, wad); emit Transfer(usr, address(0), wad); } function approve(address usr, uint wad) external returns (bool) { allowance[msg.sender][usr] = wad; emit Approval(msg.sender, usr, wad); return true; } // --- Alias --- function push(address usr, uint wad) external { transferFrom(msg.sender, usr, wad); } function pull(address usr, uint wad) external { transferFrom(usr, msg.sender, wad); } function move(address src, address dst, uint wad) external { transferFrom(src, dst, wad); } // --- Approve by signature --- function permit(address holder, address spender, uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s) external { bytes32 digest = keccak256(abi.encodePacked( "\x19\x01", DOMAIN_SEPARATOR, keccak256(abi.encode(PERMIT_TYPEHASH, holder, spender, nonce, expiry, allowed)) )); require(holder != address(0), "StableUSD/invalid-address-0"); require(holder == ecrecover(digest, v, r, s), "StableUSD/invalid-permit"); require(expiry == 0 || now <= expiry, "StableUSD/permit-expired"); require(nonce == nonces[holder]++, "StableUSD/invalid-nonce"); uint wad = allowed ? uint(-1) : 0; allowance[holder][spender] = wad; emit Approval(holder, spender, wad); } }
35,544
510
// Determine what the account liquidity would be if the given amounts were redeemed/borrowed cTokenModify The market to hypothetically redeem/borrow in account The account to determine liquidity for redeemTokens The number of tokens to hypothetically redeem borrowAmount The amount of underlying to hypothetically borrowreturn (possible error code (semi-opaque), hypothetical account shortfall below collateral requirements) /
function getHypotheticalAccountLiquidity( address account, address cTokenModify, uint redeemTokens,
function getHypotheticalAccountLiquidity( address account, address cTokenModify, uint redeemTokens,
4,455
11
// Modifier for the contract owner and allowed user
modifier ownerOrAllowed(uint _amount) { // if statment : Checking that it is the owner // or that the amount is not greater the total allowance. require(isOnwer() || allowanceMoney[msg.sender] >= _amount, "Sorry: You are not allowed!"); // Return the rest of the function _; }
modifier ownerOrAllowed(uint _amount) { // if statment : Checking that it is the owner // or that the amount is not greater the total allowance. require(isOnwer() || allowanceMoney[msg.sender] >= _amount, "Sorry: You are not allowed!"); // Return the rest of the function _; }
43,884
81
// Before the crowdsale opens, the max token count can be configured. /
function setMaxSupply(uint newMaxInWholeTokens) onlyOwner onlyBeforeOpened { maxCrowdsaleSupplyInWholeTokens = newMaxInWholeTokens; }
function setMaxSupply(uint newMaxInWholeTokens) onlyOwner onlyBeforeOpened { maxCrowdsaleSupplyInWholeTokens = newMaxInWholeTokens; }
50,799
44
// token.permit(msg.sender,address(this),nonce,expiry,amount,v,r,s);
TransferHelper.safeTransferFrom(address(token),msg.sender,address(this),amount); User storage user = findUser(msg.sender); user.investment+= amount; stakeAmount+=amount; emit Stake(msg.sender,stakeAmount);
TransferHelper.safeTransferFrom(address(token),msg.sender,address(this),amount); User storage user = findUser(msg.sender); user.investment+= amount; stakeAmount+=amount; emit Stake(msg.sender,stakeAmount);
48,622
25
// save raise
rs.raises[_raiseId] = _raise; rs.vested[_raiseId] = _vested;
rs.raises[_raiseId] = _raise; rs.vested[_raiseId] = _vested;
3,978
163
// Counter overflow is impossible as the loop breaks when uint256 i is equal to another uint256 numMintedSoFar.
unchecked { for (uint256 i; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; }
unchecked { for (uint256 i; i < numMintedSoFar; i++) { TokenOwnership memory ownership = _ownerships[i]; if (ownership.addr != address(0)) { currOwnershipAddr = ownership.addr; }
20,935
33
// View function to see the amount staked in the contract in OHMS.
function getTotalStaked() external view returns (uint256){ return stakedToken.balanceOf(address(this)); }
function getTotalStaked() external view returns (uint256){ return stakedToken.balanceOf(address(this)); }
26,983
5
// fallback function to recieve ether
fallback() payable external { emit deposit2Contract(msg.sender, msg.value, address(this).balance); }
fallback() payable external { emit deposit2Contract(msg.sender, msg.value, address(this).balance); }
3,583
97
// binary search for floor(log2(x))
int ilog2 = floorLog2(x); int z; if (ilog2 < 0) z = int(x << uint(-ilog2)); else z = int(x >> uint(ilog2));
int ilog2 = floorLog2(x); int z; if (ilog2 < 0) z = int(x << uint(-ilog2)); else z = int(x >> uint(ilog2));
19,526
159
// in losses?
if (expectedOutputs[expectedOutputs.length-1] < bid[_bidder].ethUsed) { require(isInLoss(expectedOutputs, _bidder)); }
if (expectedOutputs[expectedOutputs.length-1] < bid[_bidder].ethUsed) { require(isInLoss(expectedOutputs, _bidder)); }
11,394