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 |
|---|---|---|---|---|
293 | // Gets the net-asset value of the Rise Token in specified token This function may revert if _quote token is not configured in Rari Fuse Price Oracle _shares The amount of Rise Token _quote The token address used as quotereturn _value The net-asset value of the Rise Token in token decimals precision (ex: USDC is 1e6) / | function value(
uint256 _shares,
address _quote
| function value(
uint256 _shares,
address _quote
| 16,639 |
9 | // Set type of Oracle | constructor() public {
wards[msg.sender] = 1;
}
| constructor() public {
wards[msg.sender] = 1;
}
| 16,095 |
10 | // Events/ Emitted when a new token is created. tokenId The ID of the created token. uri The URI of the token's metadata. timestamp The timestamp of the event. / | event TokenCreated(uint256 tokenId, string uri, uint256 timestamp);
| event TokenCreated(uint256 tokenId, string uri, uint256 timestamp);
| 24,460 |
57 | // ensure that the country is the same as the current token ID | require(tokenId / LOCATION_MULTIPLIER == country, 'Country not valid');
Commitment memory existingCommitment = _validateAndDeleteCommitment(country, commitment);
delete _tokenChallengeExpirations[_msgSender()];
emit TokenChallengeCompleted(_msgSender(), tokenId);
| require(tokenId / LOCATION_MULTIPLIER == country, 'Country not valid');
Commitment memory existingCommitment = _validateAndDeleteCommitment(country, commitment);
delete _tokenChallengeExpirations[_msgSender()];
emit TokenChallengeCompleted(_msgSender(), tokenId);
| 52,329 |
2 | // The timestamp when tokens can be redeemed. | uint256 public immutable override unlockTimestamp;
| uint256 public immutable override unlockTimestamp;
| 54,575 |
120 | // Leaves the contract without owner. It will not be possible to call`onlyOwner` functions anymore. NOTE: Renouncing ownership will leave the contract without an owner,thereby removing any functionality that is only available to the owner. NOTE: This function is not safe, as it doesn’t check owner is calling it.Make sure you check it before calling it. / | function _renounceOwnership() internal {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
| function _renounceOwnership() internal {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
| 31,820 |
766 | // trader that opened the swap | address indexed buyer,
| address indexed buyer,
| 7,776 |
157 | // transfer funds from the caller in the from reserve token | ensureTransferFrom(_fromToken, msg.sender, this, _amount);
| ensureTransferFrom(_fromToken, msg.sender, this, _amount);
| 25,267 |
158 | // Contract module which provides a basic access control mechanism, wherethere is an account (an minter) that can be granted exclusive access tospecific functions. By default, the minter account will be the one that deploys the contract. This | * can later be changed with {transferMintership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyMinter`, which can be applied to your functions to restrict their use to
* the minter.
*/
contract Mintable is Context {
/**
* @dev So here we seperate the rights of the classic ownership into 'owner' and 'minter'
* this way the developer/owner stays the 'owner' and can make changes like adding a pool
* at any time but cannot mint anymore as soon as the 'minter' gets changes (to the chef contract)
*/
address private _minter;
event MintershipTransferred(address indexed previousMinter, address indexed newMinter);
/**
* @dev Initializes the contract setting the deployer as the initial minter.
*/
constructor () internal {
address msgSender = _msgSender();
_minter = msgSender;
emit MintershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current minter.
*/
function minter() public view returns (address) {
return _minter;
}
/**
* @dev Throws if called by any account other than the minter.
*/
modifier onlyMinter() {
require(_minter == _msgSender(), "Mintable: caller is not the minter");
_;
}
/**
* @dev Transfers mintership of the contract to a new account (`newMinter`).
* Can only be called by the current minter.
*/
function transferMintership(address newMinter) public virtual onlyMinter {
require(newMinter != address(0), "Mintable: new minter is the zero address");
emit MintershipTransferred(_minter, newMinter);
_minter = newMinter;
}
}
| * can later be changed with {transferMintership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyMinter`, which can be applied to your functions to restrict their use to
* the minter.
*/
contract Mintable is Context {
/**
* @dev So here we seperate the rights of the classic ownership into 'owner' and 'minter'
* this way the developer/owner stays the 'owner' and can make changes like adding a pool
* at any time but cannot mint anymore as soon as the 'minter' gets changes (to the chef contract)
*/
address private _minter;
event MintershipTransferred(address indexed previousMinter, address indexed newMinter);
/**
* @dev Initializes the contract setting the deployer as the initial minter.
*/
constructor () internal {
address msgSender = _msgSender();
_minter = msgSender;
emit MintershipTransferred(address(0), msgSender);
}
/**
* @dev Returns the address of the current minter.
*/
function minter() public view returns (address) {
return _minter;
}
/**
* @dev Throws if called by any account other than the minter.
*/
modifier onlyMinter() {
require(_minter == _msgSender(), "Mintable: caller is not the minter");
_;
}
/**
* @dev Transfers mintership of the contract to a new account (`newMinter`).
* Can only be called by the current minter.
*/
function transferMintership(address newMinter) public virtual onlyMinter {
require(newMinter != address(0), "Mintable: new minter is the zero address");
emit MintershipTransferred(_minter, newMinter);
_minter = newMinter;
}
}
| 16,966 |
46 | // offchain wei/token balances do not exceed onchain total wei/token | require(weiBalances[0].add(weiBalances[1]) <= channel.weiBalances[2], "wei must be conserved");
require(tokenBalances[0].add(tokenBalances[1]) <= channel.tokenBalances[2], "tokens must be conserved");
| require(weiBalances[0].add(weiBalances[1]) <= channel.weiBalances[2], "wei must be conserved");
require(tokenBalances[0].add(tokenBalances[1]) <= channel.tokenBalances[2], "tokens must be conserved");
| 23,252 |
88 | // Calculate uniswap time-weighted average price Underflow is a property of the accumulators: https:uniswap.org/audit.htmlorgc9b3190 | FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(uint224((nowCumulativePrice - oldCumulativePrice) / timeElapsed));
uint rawUniswapPriceMantissa = priceAverage.decode112with18();
uint unscaledPriceMantissa = mul(rawUniswapPriceMantissa, conversionFactor);
uint anchorPrice;
| FixedPoint.uq112x112 memory priceAverage = FixedPoint.uq112x112(uint224((nowCumulativePrice - oldCumulativePrice) / timeElapsed));
uint rawUniswapPriceMantissa = priceAverage.decode112with18();
uint unscaledPriceMantissa = mul(rawUniswapPriceMantissa, conversionFactor);
uint anchorPrice;
| 12,884 |
26 | // team | address payable internal MARK = 0x35e9034f47cc00b8A9b555fC1FDB9598b2c245fD;
address payable internal JARED = 0x5eCb4D3B4b451b838242c3CF8404ef18f5C486aB;
address payable internal LOUIS = 0x454f203260a74C0A8B5c0a78fbA5B4e8B31dCC63;
address payable internal LOTTO = 0x1EF0Bab01329a6CE39e92eA6B88828430B1Cd91f;
address payable internal DONATOR = 0x723e82Eb1A1b419Fb36e9bD65E50A979cd13d341;
address payable internal KEVIN = 0x3487b398546C9b757921df6dE78EC308203f5830;
address payable internal AMIRIS = 0x406D1fC98D231aD69807Cd41d4D6F8273401354f;
| address payable internal MARK = 0x35e9034f47cc00b8A9b555fC1FDB9598b2c245fD;
address payable internal JARED = 0x5eCb4D3B4b451b838242c3CF8404ef18f5C486aB;
address payable internal LOUIS = 0x454f203260a74C0A8B5c0a78fbA5B4e8B31dCC63;
address payable internal LOTTO = 0x1EF0Bab01329a6CE39e92eA6B88828430B1Cd91f;
address payable internal DONATOR = 0x723e82Eb1A1b419Fb36e9bD65E50A979cd13d341;
address payable internal KEVIN = 0x3487b398546C9b757921df6dE78EC308203f5830;
address payable internal AMIRIS = 0x406D1fC98D231aD69807Cd41d4D6F8273401354f;
| 32,923 |
52 | // Sets `newManager` as the manager for `account`. A manager of anaccount is able to set interface implementers for it. By default, each account is its own manager. Passing a value of `0x0` in`newManager` will reset the manager to this initial state. | * Emits a {ManagerChanged} event.
*
* Requirements:
*
* - the caller must be the current manager for `account`.
*/
function setManager(address account, address newManager) external;
/**
* @dev Returns the manager for `account`.
*
* See {setManager}.
*/
function getManager(address account) external view returns (address);
/**
* @dev Sets the `implementer` contract as ``account``'s implementer for
* `interfaceHash`.
*
* `account` being the zero address is an alias for the caller's address.
* The zero address can also be used in `implementer` to remove an old one.
*
* See {interfaceHash} to learn how these are created.
*
* Emits an {InterfaceImplementerSet} event.
*
* Requirements:
*
* - the caller must be the current manager for `account`.
* - `interfaceHash` must not be an {IERC165} interface id (i.e. it must not
* end in 28 zeroes).
* - `implementer` must implement {IERC1820Implementer} and return true when
* queried for support, unless `implementer` is the caller. See
* {IERC1820Implementer-canImplementInterfaceForAddress}.
*/
function setInterfaceImplementer(
address account,
bytes32 _interfaceHash,
address implementer
) external;
/**
* @dev Returns the implementer of `interfaceHash` for `account`. If no such
* implementer is registered, returns the zero address.
*
* If `interfaceHash` is an {IERC165} interface id (i.e. it ends with 28
* zeroes), `account` will be queried for support of it.
*
* `account` being the zero address is an alias for the caller's address.
*/
function getInterfaceImplementer(address account, bytes32 _interfaceHash) external view returns (address);
/**
* @dev Returns the interface hash for an `interfaceName`, as defined in the
* corresponding
* https://eips.ethereum.org/EIPS/eip-1820#interface-name[section of the EIP].
*/
function interfaceHash(string calldata interfaceName) external pure returns (bytes32);
/**
* @notice Updates the cache with whether the contract implements an ERC165 interface or not.
* @param account Address of the contract for which to update the cache.
* @param interfaceId ERC165 interface for which to update the cache.
*/
function updateERC165Cache(address account, bytes4 interfaceId) external;
/**
* @notice Checks whether a contract implements an ERC165 interface or not.
* If the result is not cached a direct lookup on the contract address is performed.
* If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling
* {updateERC165Cache} with the contract address.
* @param account Address of the contract to check.
* @param interfaceId ERC165 interface to check.
* @return True if `account` implements `interfaceId`, false otherwise.
*/
function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool);
/**
* @notice Checks whether a contract implements an ERC165 interface or not without using nor updating the cache.
* @param account Address of the contract to check.
* @param interfaceId ERC165 interface to check.
* @return True if `account` implements `interfaceId`, false otherwise.
*/
function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool);
event InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer);
event ManagerChanged(address indexed account, address indexed newManager);
}
| * Emits a {ManagerChanged} event.
*
* Requirements:
*
* - the caller must be the current manager for `account`.
*/
function setManager(address account, address newManager) external;
/**
* @dev Returns the manager for `account`.
*
* See {setManager}.
*/
function getManager(address account) external view returns (address);
/**
* @dev Sets the `implementer` contract as ``account``'s implementer for
* `interfaceHash`.
*
* `account` being the zero address is an alias for the caller's address.
* The zero address can also be used in `implementer` to remove an old one.
*
* See {interfaceHash} to learn how these are created.
*
* Emits an {InterfaceImplementerSet} event.
*
* Requirements:
*
* - the caller must be the current manager for `account`.
* - `interfaceHash` must not be an {IERC165} interface id (i.e. it must not
* end in 28 zeroes).
* - `implementer` must implement {IERC1820Implementer} and return true when
* queried for support, unless `implementer` is the caller. See
* {IERC1820Implementer-canImplementInterfaceForAddress}.
*/
function setInterfaceImplementer(
address account,
bytes32 _interfaceHash,
address implementer
) external;
/**
* @dev Returns the implementer of `interfaceHash` for `account`. If no such
* implementer is registered, returns the zero address.
*
* If `interfaceHash` is an {IERC165} interface id (i.e. it ends with 28
* zeroes), `account` will be queried for support of it.
*
* `account` being the zero address is an alias for the caller's address.
*/
function getInterfaceImplementer(address account, bytes32 _interfaceHash) external view returns (address);
/**
* @dev Returns the interface hash for an `interfaceName`, as defined in the
* corresponding
* https://eips.ethereum.org/EIPS/eip-1820#interface-name[section of the EIP].
*/
function interfaceHash(string calldata interfaceName) external pure returns (bytes32);
/**
* @notice Updates the cache with whether the contract implements an ERC165 interface or not.
* @param account Address of the contract for which to update the cache.
* @param interfaceId ERC165 interface for which to update the cache.
*/
function updateERC165Cache(address account, bytes4 interfaceId) external;
/**
* @notice Checks whether a contract implements an ERC165 interface or not.
* If the result is not cached a direct lookup on the contract address is performed.
* If the result is not cached or the cached value is out-of-date, the cache MUST be updated manually by calling
* {updateERC165Cache} with the contract address.
* @param account Address of the contract to check.
* @param interfaceId ERC165 interface to check.
* @return True if `account` implements `interfaceId`, false otherwise.
*/
function implementsERC165Interface(address account, bytes4 interfaceId) external view returns (bool);
/**
* @notice Checks whether a contract implements an ERC165 interface or not without using nor updating the cache.
* @param account Address of the contract to check.
* @param interfaceId ERC165 interface to check.
* @return True if `account` implements `interfaceId`, false otherwise.
*/
function implementsERC165InterfaceNoCache(address account, bytes4 interfaceId) external view returns (bool);
event InterfaceImplementerSet(address indexed account, bytes32 indexed interfaceHash, address indexed implementer);
event ManagerChanged(address indexed account, address indexed newManager);
}
| 31,556 |
1 | // mint VOLT to the target address and deplete the buffer/ pausable and depletes the msg.sender's buffer/to the recipient address of the minted VOLT/amount the amount of VOLT to mint | function mintVolt(address to, uint256 amount)
external
virtual
override
whenNotPaused
{
_depleteIndividualBuffer(msg.sender, amount);
_mintVolt(to, amount);
}
| function mintVolt(address to, uint256 amount)
external
virtual
override
whenNotPaused
{
_depleteIndividualBuffer(msg.sender, amount);
_mintVolt(to, amount);
}
| 9,550 |
10 | // The initial global index | uint256 public constant globalInitialIndex = 1e36;
uint256 public inflationSpeed = 0;
| uint256 public constant globalInitialIndex = 1e36;
uint256 public inflationSpeed = 0;
| 20,096 |
34 | // TODO: handle order outside of the book, where next or prev is nil | Order storage order = book.orders[id];
| Order storage order = book.orders[id];
| 5,049 |
10 | // function for the developer to change the address./ | function changeDev(address payable _dev) external returns (bool) {
require(msg.sender == dev, "change developer: not the current developer");
dev = _dev;
}
| function changeDev(address payable _dev) external returns (bool) {
require(msg.sender == dev, "change developer: not the current developer");
dev = _dev;
}
| 49,180 |
1 | // The governor unsets oracle token factor for a token. | event UnsetTokenFactor(address indexed token);
| event UnsetTokenFactor(address indexed token);
| 47,515 |
116 | // send fees | provider0.token.safeTransfer(feesController.feesTo(), feesAmount0);
provider1.token.safeTransfer(feesController.feesTo(), feesAmount1);
uint256 spentAmount0;
uint256 spentAmount1;
uint256 liquidity;
uint256[] memory returnedValues = new uint256[](3);
| provider0.token.safeTransfer(feesController.feesTo(), feesAmount0);
provider1.token.safeTransfer(feesController.feesTo(), feesAmount1);
uint256 spentAmount0;
uint256 spentAmount1;
uint256 liquidity;
uint256[] memory returnedValues = new uint256[](3);
| 60,063 |
89 | // See {IERC1155-safeTransferFrom}. / | function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not owner nor approved"
| function safeTransferFrom(
address from,
address to,
uint256 id,
uint256 amount,
bytes memory data
) public virtual override {
require(
from == _msgSender() || isApprovedForAll(from, _msgSender()),
"ERC1155: caller is not owner nor approved"
| 32,679 |
26 | // -------------------------------------------------------------------------- //erc20 // -------------------------------------------------------------------------- / | function name() public pure returns (string memory) {
return _name;
}
| function name() public pure returns (string memory) {
return _name;
}
| 27,572 |
257 | // Get the next harvest delay. | uint64 newHarvestDelay = nextHarvestDelay;
| uint64 newHarvestDelay = nextHarvestDelay;
| 55,489 |
41 | // New round reset count | if (HighJackpot[msg.sender] != 1){
HighJackpot[msg.sender] = 1;
}
| if (HighJackpot[msg.sender] != 1){
HighJackpot[msg.sender] = 1;
}
| 34,225 |
109 | // ORG.JSON storage update orgId ORGiD hash orgJsonHash ORG.JSON keccak256 hash orgJsonUri ORG.JSON URI orgJsonUriBackup1 ORG.JSON URI backup orgJsonUriBackup2 ORG.JSON URI backup / | function _updateOrgJson(
bytes32 orgId,
bytes32 orgJsonHash,
string memory orgJsonUri,
string memory orgJsonUriBackup1,
string memory orgJsonUriBackup2
| function _updateOrgJson(
bytes32 orgId,
bytes32 orgJsonHash,
string memory orgJsonUri,
string memory orgJsonUriBackup1,
string memory orgJsonUriBackup2
| 66,755 |
306 | // Check and update atomic volume limit | _checkAndUpdateAtomicVolume(sourceSusdValue);
| _checkAndUpdateAtomicVolume(sourceSusdValue);
| 38,121 |
24 | // Transfer tokens from one address to another.Note that while this function emits an Approval event, this is not required as per the specification,and other compliant implementations may not emit the event. from address The address which you want to send tokens from to address The address which you want to transfer to value uint256 the amount of tokens to be transferred / | function transferFrom(address from, address to, uint256 value) public returns (bool) {
_transfer(from, to, value);
_approve(from, msg.sender, _allowed[from][msg.sender].sub(value));
return true;
}
| function transferFrom(address from, address to, uint256 value) public returns (bool) {
_transfer(from, to, value);
_approve(from, msg.sender, _allowed[from][msg.sender].sub(value));
return true;
}
| 422 |
13 | // If Red and Blue have exploded at the same time, return the amounted invested | if (red.lastUpdate == blue.lastUpdate && red.lastUpdate + DELAY < block.timestamp) {
for (i = 0; i < red.members.length; i++) {
balances[red.members[i]] += INVEST_AMOUNT;
}
| if (red.lastUpdate == blue.lastUpdate && red.lastUpdate + DELAY < block.timestamp) {
for (i = 0; i < red.members.length; i++) {
balances[red.members[i]] += INVEST_AMOUNT;
}
| 23,641 |
1 | // disable transfers | function _transfer(address _from, address _to, uint256 _amount) internal override {
revert("NON_TRANSFERABLE");
}
| function _transfer(address _from, address _to, uint256 _amount) internal override {
revert("NON_TRANSFERABLE");
}
| 28,779 |
4 | // MasterCopy - Base for master copy contracts (should always be first super contract)/ This contract is tightly coupled to our proxy contract (see `proxies/Proxy.sol`)/Richard Meissner - <richard@gnosis.io> | contract MasterCopy is SelfAuthorized {
event ChangedMasterCopy(address masterCopy);
// masterCopy always needs to be first declared variable, to ensure that it is at the same location as in the Proxy contract.
// It should also always be ensured that the address is stored alone (uses a full word)
address masterCopy;
/// @dev Allows to upgrade the contract. This can only be done via a Safe transaction.
/// @param _masterCopy New contract address.
function changeMasterCopy(address _masterCopy)
public
authorized
{
// Master copy address cannot be null.
require(_masterCopy != address(0), "Invalid master copy address provided");
masterCopy = _masterCopy;
emit ChangedMasterCopy(_masterCopy);
}
}
| contract MasterCopy is SelfAuthorized {
event ChangedMasterCopy(address masterCopy);
// masterCopy always needs to be first declared variable, to ensure that it is at the same location as in the Proxy contract.
// It should also always be ensured that the address is stored alone (uses a full word)
address masterCopy;
/// @dev Allows to upgrade the contract. This can only be done via a Safe transaction.
/// @param _masterCopy New contract address.
function changeMasterCopy(address _masterCopy)
public
authorized
{
// Master copy address cannot be null.
require(_masterCopy != address(0), "Invalid master copy address provided");
masterCopy = _masterCopy;
emit ChangedMasterCopy(_masterCopy);
}
}
| 1,861 |
36 | // Start the game Start a new game. Initialize game opponent, game time and status._gameOpponent The game opponent contract address_gameTime The game begin time. optional/ | function beginGame(address _gameOpponent, uint64 _gameTime) onlyOwner public {
require(_gameOpponent != address(this));
// 1514764800 = 2018-01-01
require(_gameTime == 0 || (_gameTime > 1514764800));
gameOpponent = _gameOpponent;
gameTime = _gameTime;
status = 0;
emit BeginGame(address(this), _gameOpponent, _gameTime);
}
| function beginGame(address _gameOpponent, uint64 _gameTime) onlyOwner public {
require(_gameOpponent != address(this));
// 1514764800 = 2018-01-01
require(_gameTime == 0 || (_gameTime > 1514764800));
gameOpponent = _gameOpponent;
gameTime = _gameTime;
status = 0;
emit BeginGame(address(this), _gameOpponent, _gameTime);
}
| 31,175 |
36 | // Add the FRAX and the collateral to the metapool | uint256 min_lp_out = (_MIM_Convex_AMOunt.add(threeCRV_received)).mul(slippage_metapool).div(PRICE_PRECISION);
metapool_LP_received = mim3crv_metapool.add_liquidity([_MIM_Convex_AMOunt, threeCRV_received], min_lp_out);
| uint256 min_lp_out = (_MIM_Convex_AMOunt.add(threeCRV_received)).mul(slippage_metapool).div(PRICE_PRECISION);
metapool_LP_received = mim3crv_metapool.add_liquidity([_MIM_Convex_AMOunt, threeCRV_received], min_lp_out);
| 49,290 |
313 | // We need to calculate what the updated cash will be after we transfer out to the user | (err, localResults.updatedCash) = sub(localResults.currentCash, amount);
if (err != Error.NO_ERROR) {
| (err, localResults.updatedCash) = sub(localResults.currentCash, amount);
if (err != Error.NO_ERROR) {
| 3,722 |
3 | // Record the from chain txs that have been processed | mapping(uint64 => mapping(bytes32 => bool)) FromChainTxExist;
| mapping(uint64 => mapping(bytes32 => bool)) FromChainTxExist;
| 48,044 |
75 | // 0.000001 TOKEN | require(balance >= decimal / MIN_BALANCE, "ERR_MIN_BALANCE");
_totalWeight = _totalWeight.badd(denorm);
require(_totalWeight <= MAX_TOTAL_WEIGHT, "ERR_MAX_TOTAL_WEIGHT");
_records[token] = Record({
bound: true,
index: _tokens.length,
denorm: denorm,
balance: balance
| require(balance >= decimal / MIN_BALANCE, "ERR_MIN_BALANCE");
_totalWeight = _totalWeight.badd(denorm);
require(_totalWeight <= MAX_TOTAL_WEIGHT, "ERR_MAX_TOTAL_WEIGHT");
_records[token] = Record({
bound: true,
index: _tokens.length,
denorm: denorm,
balance: balance
| 26,632 |
60 | // Deposit multiple tokens to the vault. Quantities should be in theorder of the addresses of the tokens being deposited. _tokens Array of the addresses of the ERC20 tokens_quantities Array of the number of tokens to deposit / | function batchDeposit(
| function batchDeposit(
| 17,300 |
1 | // set the configuration of the LayerZero messaging library of the specified version_version - messaging library version_chainId - the chainId for the pending config change_configType - type of configuration. every messaging library has its own convention._config - configuration in the bytes. can encode arbitrary content. | function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config) external;
| function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config) external;
| 16,444 |
47 | // settles accrued interest for all active loans from a loan pool/loanId existing loan id | function settleInterest(bytes32 loanId) external;
function setDepositAmount(
bytes32 loanId,
uint256 depositValueAsLoanToken,
uint256 depositValueAsCollateralToken
) external;
function transferLoan(bytes32 loanId, address newOwner) external;
| function settleInterest(bytes32 loanId) external;
function setDepositAmount(
bytes32 loanId,
uint256 depositValueAsLoanToken,
uint256 depositValueAsCollateralToken
) external;
function transferLoan(bytes32 loanId, address newOwner) external;
| 5,447 |
13 | // Return aggregated normalized amount. | function getAggregatedNormalizedAmount() external view override onlyOwner returns (uint256) {
return aggregatedNormalizedAmount;
}
| function getAggregatedNormalizedAmount() external view override onlyOwner returns (uint256) {
return aggregatedNormalizedAmount;
}
| 16,497 |
2 | // note: this is not the way to do this for production, but we're taking a shortcut for a hackathon | mapping(uint256 => mapping(uint256 => bool)) public familyMembers; // familyID => personID => valid
mapping(uint256 => uint256) public familyMembersCount; // familyID => person count
mapping(uint256 => mapping(uint256 => uint256)) public familyRoles; // familyID => personID => role
mapping(uint256 => mapping(bytes32 => bool)) public familyInvites; // familyID => hashed invite => valid
| mapping(uint256 => mapping(uint256 => bool)) public familyMembers; // familyID => personID => valid
mapping(uint256 => uint256) public familyMembersCount; // familyID => person count
mapping(uint256 => mapping(uint256 => uint256)) public familyRoles; // familyID => personID => role
mapping(uint256 => mapping(bytes32 => bool)) public familyInvites; // familyID => hashed invite => valid
| 24,764 |
45 | // new "memory end" including padding (the string isn't larger than 32 bytes) | mstore(0x40, add(result, 0x40))
| mstore(0x40, add(result, 0x40))
| 2,015 |
60 | // Returns an amount in eth equivilent to USD at the set rate | function usdToEth(uint) public constant returns(uint);
| function usdToEth(uint) public constant returns(uint);
| 16,854 |
93 | // Create a mask of 1's where new cards should go. | uint _newMask;
for (uint _i=0; _i<5; _i++) {
if (_draws & 2**_i == 0) continue;
_newMask |= 63 * (2**(6*_i));
}
| uint _newMask;
for (uint _i=0; _i<5; _i++) {
if (_draws & 2**_i == 0) continue;
_newMask |= 63 * (2**(6*_i));
}
| 82,971 |
443 | // Decrease the number of votes delegated to the previous representative. | if (srcRep != address(0)) {
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
| if (srcRep != address(0)) {
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
| 39,571 |
158 | // Allocates swap fees accured in the contract. / | function allocateFees() public {
require(msg.sender == strategist || msg.sender == governance, "not authorized");
uint256 balance = IERC20(acBtc).balanceOf(address(this));
if (balance > 0 && reserveRate > 0 && reserve != address(0x0)) {
uint256 reserveAmount = balance.mul(reserveRate).div(reserveRateMax);
IERC20(acBtc).safeTransfer(reserve, reserveAmount);
balance = balance.sub(reserveAmount);
}
IERC20(acBtc).safeTransfer(acBtcVault, balance);
}
| function allocateFees() public {
require(msg.sender == strategist || msg.sender == governance, "not authorized");
uint256 balance = IERC20(acBtc).balanceOf(address(this));
if (balance > 0 && reserveRate > 0 && reserve != address(0x0)) {
uint256 reserveAmount = balance.mul(reserveRate).div(reserveRateMax);
IERC20(acBtc).safeTransfer(reserve, reserveAmount);
balance = balance.sub(reserveAmount);
}
IERC20(acBtc).safeTransfer(acBtcVault, balance);
}
| 55,382 |
2 | // Mints tokens to the recipients in amounts specified This function should be protected by a role so that it is not callable by any address recipients addresses to airdrop tokens to amounts amount of tokens to airdrop to recipients / | function airdrop(address[] calldata recipients, uint256[] calldata amounts) external;
| function airdrop(address[] calldata recipients, uint256[] calldata amounts) external;
| 28,107 |
170 | // owner gets the first 10 Bats | _safeMint( t1, 1);
| _safeMint( t1, 1);
| 38,495 |
26 | // This is used to mint new tokensCan only be executed by the staking, and merged miner validator contracts_recipient This is the person who will received the mint tokens_amount This is the amount of tokens that they will receive and which will be generated / | function mint(
address _recipient,
uint256 _amount)
public
onlyMinters
returns (bool)
| function mint(
address _recipient,
uint256 _amount)
public
onlyMinters
returns (bool)
| 941 |
55 | // Converts a `uint` to its ASCII `string` decimal representation. / | function toString(uint value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint temp = value;
uint digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint(value % 10)));
value /= 10;
}
return string(buffer);
}
| function toString(uint value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint temp = value;
uint digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint(value % 10)));
value /= 10;
}
return string(buffer);
}
| 34,283 |
92 | // column0_row14/ mload(0x1440), memory/address_diff_0 = column6_row2 - column6_row0. | let val := addmod(/*column6_row2*/ mload(0x1a80), sub(PRIME, /*column6_row0*/ mload(0x1a40)), PRIME)
mstore(0x2500, val)
| let val := addmod(/*column6_row2*/ mload(0x1a80), sub(PRIME, /*column6_row0*/ mload(0x1a40)), PRIME)
mstore(0x2500, val)
| 20,231 |
2 | // Tests if a transfer can occur between the from/to addresses and returns an error string when it would failcompliance The Compliance addresstoken The address of the token that triggered the checkinitiator The address initiating the transferfrom The address of the senderto The address of the receivertokens The number of tokens being transferred return The error message / | function test(ICompliance compliance, IT0ken token, address initiator, address from, address to, uint256 tokens)
external
view
| function test(ICompliance compliance, IT0ken token, address initiator, address from, address to, uint256 tokens)
external
view
| 40,282 |
171 | // debit balance of caller for holdOption, credit exercisedOptions | balances[holderTicketAddress][msg.sender] =
safeSub(balances[holderTicketAddress][msg.sender], ticketsExcercised);
exercisedOptions[holderTicketAddress] =
safeAdd(exercisedOptions[holderTicketAddress], ticketsExcercised);
| balances[holderTicketAddress][msg.sender] =
safeSub(balances[holderTicketAddress][msg.sender], ticketsExcercised);
exercisedOptions[holderTicketAddress] =
safeAdd(exercisedOptions[holderTicketAddress], ticketsExcercised);
| 3,536 |
8 | // Provable callback function | function __callback(bytes32 myid, string memory result) public {
// require(msg.sender != provable_cbAddress());
numberOfPosts = parseInt(result);
if (numberOfPosts >= adQuota) {
influencerPayout();
}
emit LogAdConfirmations(numberOfPosts);
}
| function __callback(bytes32 myid, string memory result) public {
// require(msg.sender != provable_cbAddress());
numberOfPosts = parseInt(result);
if (numberOfPosts >= adQuota) {
influencerPayout();
}
emit LogAdConfirmations(numberOfPosts);
}
| 38,684 |
2 | // Get Arbitrum block number (distinct from L1 block number; Arbitrum genesis block has block number 0)return block number as int / | function arbBlockNumber() external view returns (uint256);
| function arbBlockNumber() external view returns (uint256);
| 19,518 |
294 | // Assume it is the test ENS | if (ens.owner(node) != address(this)) {
| if (ens.owner(node) != address(this)) {
| 76,673 |
13 | // epoch finalized/_epochNumber number of the epoch being finalized/_epochHash claim being submitted by this epoch | event FinalizeEpoch(uint256 indexed _epochNumber, bytes32 _epochHash);
| event FinalizeEpoch(uint256 indexed _epochNumber, bytes32 _epochHash);
| 43,151 |
89 | // Mapping for the counters of songs minted for each song | mapping(uint256 => uint256) private _songSerials;
| mapping(uint256 => uint256) private _songSerials;
| 27,908 |
54 | // Reference to contest contract ownership of player tokens | address public contestContractAddress;
| address public contestContractAddress;
| 12,298 |
8 | // Function Modifiers//Blocks a function from being called when the parent signals that the system should be pausedvia an isUpgrading function. / | modifier onlyWhenNotPaused() {
address owner = _getOwner();
// We do a low-level call because there's no guarantee that the owner actually *is* an
// L1ChugSplashDeployer contract and Solidity will throw errors if we do a normal call and
// it turns out that it isn't the right type of contract.
(bool success, bytes memory returndata) = owner.staticcall(
abi.encodeWithSelector(iL1ChugSplashDeployer.isUpgrading.selector)
);
// If the call was unsuccessful then we assume that there's no "isUpgrading" method and we
// can just continue as normal. We also expect that the return value is exactly 32 bytes
// long. If this isn't the case then we can safely ignore the result.
if (success && returndata.length == 32) {
// Although the expected value is a *boolean*, it's safer to decode as a uint256 in the
// case that the isUpgrading function returned something other than 0 or 1. But we only
// really care about the case where this value is 0 (= false).
uint256 ret = abi.decode(returndata, (uint256));
require(ret == 0, "L1ChugSplashProxy: system is currently being upgraded");
}
_;
}
| modifier onlyWhenNotPaused() {
address owner = _getOwner();
// We do a low-level call because there's no guarantee that the owner actually *is* an
// L1ChugSplashDeployer contract and Solidity will throw errors if we do a normal call and
// it turns out that it isn't the right type of contract.
(bool success, bytes memory returndata) = owner.staticcall(
abi.encodeWithSelector(iL1ChugSplashDeployer.isUpgrading.selector)
);
// If the call was unsuccessful then we assume that there's no "isUpgrading" method and we
// can just continue as normal. We also expect that the return value is exactly 32 bytes
// long. If this isn't the case then we can safely ignore the result.
if (success && returndata.length == 32) {
// Although the expected value is a *boolean*, it's safer to decode as a uint256 in the
// case that the isUpgrading function returned something other than 0 or 1. But we only
// really care about the case where this value is 0 (= false).
uint256 ret = abi.decode(returndata, (uint256));
require(ret == 0, "L1ChugSplashProxy: system is currently being upgraded");
}
_;
}
| 14,597 |
55 | // NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}.TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the`0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc` / | function implementation() external ifAdmin returns (address) {
return _implementation();
}
| function implementation() external ifAdmin returns (address) {
return _implementation();
}
| 5,013 |
17 | // Sets the initial stage parameter./ | function initStage(uint256 _rId, uint256 _sId)
private
| function initStage(uint256 _rId, uint256 _sId)
private
| 85,159 |
31 | // Checks if a given drip is executable._name Drip to check. return True if the drip is executable, reverts otherwise. / | function executable(string calldata _name) public view returns (bool) {
DripState storage state = drips[_name];
// Only allow active drips to be executed, an obvious security measure.
require(
state.status == DripStatus.ACTIVE,
"Drippie: selected drip does not exist or is not currently active"
);
// Don't drip if the drip interval has not yet elapsed since the last time we dripped. This
// is a safety measure that prevents a malicious recipient from, e.g., spending all of
// their funds and repeatedly requesting new drips. Limits the potential impact of a
// compromised recipient to just a single drip interval, after which the drip can be paused
// by the owner address.
require(
state.last + state.config.interval <= block.timestamp,
"Drippie: drip interval has not elapsed since last drip"
);
// Make sure we're allowed to execute this drip.
require(
state.config.dripcheck.check(state.config.checkparams),
"Drippie: dripcheck failed so drip is not yet ready to be triggered"
);
// Alright, we're good to execute.
return true;
}
| function executable(string calldata _name) public view returns (bool) {
DripState storage state = drips[_name];
// Only allow active drips to be executed, an obvious security measure.
require(
state.status == DripStatus.ACTIVE,
"Drippie: selected drip does not exist or is not currently active"
);
// Don't drip if the drip interval has not yet elapsed since the last time we dripped. This
// is a safety measure that prevents a malicious recipient from, e.g., spending all of
// their funds and repeatedly requesting new drips. Limits the potential impact of a
// compromised recipient to just a single drip interval, after which the drip can be paused
// by the owner address.
require(
state.last + state.config.interval <= block.timestamp,
"Drippie: drip interval has not elapsed since last drip"
);
// Make sure we're allowed to execute this drip.
require(
state.config.dripcheck.check(state.config.checkparams),
"Drippie: dripcheck failed so drip is not yet ready to be triggered"
);
// Alright, we're good to execute.
return true;
}
| 10,597 |
0 | // These values are set very low in the beginnign to allow the DAO to quickly interveen in case of maliscious attacks or other problems. Once the DAO has reched a more mature stage these will be voted to be 3-4 days each | uint256 public warmUpDuration = 1 hours;
uint256 public activeDuration = 1 hours;
uint256 public queueDuration = 1 hours;
uint256 public gracePeriodDuration = 1 hours;
uint256 public gradualWeightUpdate = 13300; // 2 days in blocks
uint256 public acceptanceThreshold = 60;
uint256 public minQuorum = 40;
| uint256 public warmUpDuration = 1 hours;
uint256 public activeDuration = 1 hours;
uint256 public queueDuration = 1 hours;
uint256 public gracePeriodDuration = 1 hours;
uint256 public gradualWeightUpdate = 13300; // 2 days in blocks
uint256 public acceptanceThreshold = 60;
uint256 public minQuorum = 40;
| 6,937 |
37 | // In our sample we have created securites tokens and fractional securities for the tokens upto 18 digits | decimals = 2; // Number of Digits [0-18] If an organization wants to fractionalize the securities
| decimals = 2; // Number of Digits [0-18] If an organization wants to fractionalize the securities
| 4,781 |
43 | // Returns a boolean flag of whether the `revealNumber` function can be called at the current block/ by the specified validator. Used by the `revealNumber` function and the `TxPermission` contract./_miningAddress The mining address of validator which tries to call the `revealNumber` function./_number The validator's number passed to the `revealNumber` function. | function revealNumberCallable(address _miningAddress, uint256 _number) public view returns(bool) {
return _revealNumberCallable(_miningAddress, _number);
}
| function revealNumberCallable(address _miningAddress, uint256 _number) public view returns(bool) {
return _revealNumberCallable(_miningAddress, _number);
}
| 12,496 |
7 | // --------------------------------------------------------------------------------/Stores GlobalTradeItemNumber which is a Unique ID/newGlobalTradeItemNumber Unique ID | function setGlobalTradeItemNumber(uint newGlobalTradeItemNumber) public onlyOwner
| function setGlobalTradeItemNumber(uint newGlobalTradeItemNumber) public onlyOwner
| 7,502 |
122 | // gets the currently active vault ID | uint256 vaultID = controller.getAccountVaultCounter(address(this));
GammaTypes.Vault memory vault =
controller.getVault(address(this), vaultID);
require(vault.shortOtokens.length > 0, "No short");
| uint256 vaultID = controller.getAccountVaultCounter(address(this));
GammaTypes.Vault memory vault =
controller.getVault(address(this), vaultID);
require(vault.shortOtokens.length > 0, "No short");
| 59,266 |
62 | // Checks if first Exp is less than second Exp. / | function lessThanExp(Exp memory left, Exp memory right) pure internal returns (bool) {
return left.mantissa < right.mantissa;
}
| function lessThanExp(Exp memory left, Exp memory right) pure internal returns (bool) {
return left.mantissa < right.mantissa;
}
| 14,207 |
23 | // Unpause this contract. / | function unpause()
external
onlyRole(DEFAULT_ADMIN_ROLE)
| function unpause()
external
onlyRole(DEFAULT_ADMIN_ROLE)
| 43,462 |
4 | // if less than 0.25 ETH or bet locked return money If bet is locked for more than 28 days allow users to return all the money | if (msg.value < 250 finney ||
(block.number >= betLockTime && betLockTime != 0 && block.number < betLockTime + 161280)) {
msg.sender.send(msg.value);
return;
}
| if (msg.value < 250 finney ||
(block.number >= betLockTime && betLockTime != 0 && block.number < betLockTime + 161280)) {
msg.sender.send(msg.value);
return;
}
| 37,053 |
86 | // get balance after future trasfer | uint256 estimateBalance = balanceOf(from).sub(amount);
| uint256 estimateBalance = balanceOf(from).sub(amount);
| 19,117 |
215 | // ---------------------------- ONLY FACTORY --------------------------- //Mints an ERC721 token for the user and stores the original asset used to create the new asset if any/_owner The account address that signed the transaction/_replicatedTokenId The token id of the replicated asset, 0 if no replication/ return The minted token's id | function mint(address _owner, uint256 _replicatedTokenId) public onlyFactory returns (uint256) {
_tokenIds.increment();
uint256 tokenId = _tokenIds.current();
_safeMint(_owner, tokenId);
// Stores the first asset of the replication chain as the original
if (_replicatedTokenId == 0) {
return tokenId;
}
require(_exists(_replicatedTokenId), "NA: NON_EXISTENT_TOKEN_ID");
require(tokenId != _replicatedTokenId, "NA: SELF_DUPLICATION");
uint256 originalTokenId = originalAsset[_replicatedTokenId];
originalAsset[tokenId] = originalTokenId != 0 ? originalTokenId : _replicatedTokenId;
return tokenId;
}
| function mint(address _owner, uint256 _replicatedTokenId) public onlyFactory returns (uint256) {
_tokenIds.increment();
uint256 tokenId = _tokenIds.current();
_safeMint(_owner, tokenId);
// Stores the first asset of the replication chain as the original
if (_replicatedTokenId == 0) {
return tokenId;
}
require(_exists(_replicatedTokenId), "NA: NON_EXISTENT_TOKEN_ID");
require(tokenId != _replicatedTokenId, "NA: SELF_DUPLICATION");
uint256 originalTokenId = originalAsset[_replicatedTokenId];
originalAsset[tokenId] = originalTokenId != 0 ? originalTokenId : _replicatedTokenId;
return tokenId;
}
| 60,303 |
265 | // Notifies the controller about a token transfer allowing the controller to decide whetherto allow it or react if desired (only callable from the token).Initialization check is implicitly provided by `onlyToken()`._from The origin of the transfer_to The destination of the transfer_amount The amount of the transfer return False if the controller does not authorize the transfer/ | function onTransfer(address _from, address _to, uint256 _amount) external onlyToken returns (bool) {
return _isBalanceIncreaseAllowed(_to, _amount) && _transferableBalance(_from, getTimestamp()) >= _amount;
}
| function onTransfer(address _from, address _to, uint256 _amount) external onlyToken returns (bool) {
return _isBalanceIncreaseAllowed(_to, _amount) && _transferableBalance(_from, getTimestamp()) >= _amount;
}
| 44,913 |
381 | // contract responsible for investments accounting | FundsRegistry public m_funds;
| FundsRegistry public m_funds;
| 85,825 |
101 | // Function for split proportions | function _splitPayment(uint256 amount, uint256 burnProp, uint256 charityProp, uint256 devProp) public returns (bool) {
require(burnProp.add(charityProp).add(devProp) == 10000, 'Proportions must sum to 10000');
uint256 burnAmount = burnProp.mul(amount).div(10000);
uint256 charityAmount = charityProp.mul(amount).div(10000);
uint256 developerAmount = devProp.mul(amount).div(10000);
// Burn. Charity and Developer cut
_burn(msg.sender, burnAmount);
_transfer(msg.sender, charityWallet, charityAmount);
_transfer(msg.sender, developerWallet, developerAmount);
return true;
}
| function _splitPayment(uint256 amount, uint256 burnProp, uint256 charityProp, uint256 devProp) public returns (bool) {
require(burnProp.add(charityProp).add(devProp) == 10000, 'Proportions must sum to 10000');
uint256 burnAmount = burnProp.mul(amount).div(10000);
uint256 charityAmount = charityProp.mul(amount).div(10000);
uint256 developerAmount = devProp.mul(amount).div(10000);
// Burn. Charity and Developer cut
_burn(msg.sender, burnAmount);
_transfer(msg.sender, charityWallet, charityAmount);
_transfer(msg.sender, developerWallet, developerAmount);
return true;
}
| 12,200 |
39 | // Unfinalized rewards are always earned from stake in the prior epoch so we want the stake at `currentEpoch_-1`. | uint256 unfinalizedStakeBalance = delegatedStake.currentEpoch >= currentEpoch_.safeSub(1) ?
delegatedStake.currentEpochBalance :
delegatedStake.nextEpochBalance;
| uint256 unfinalizedStakeBalance = delegatedStake.currentEpoch >= currentEpoch_.safeSub(1) ?
delegatedStake.currentEpochBalance :
delegatedStake.nextEpochBalance;
| 11,495 |
115 | // See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is notrequired by the EIP. See the note at the beginning of {ERC20}. Requirements: - `sender` and `recipient` cannot be the zero address.- `sender` must have a balance of at least `amount`.- the caller must have allowance for ``sender``'s tokens of at least`amount`. / | function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
| function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
| 36,418 |
33 | // Adds single address to whitelist.Use this also to update _beneficiary Address to be added to the whitelist / | function addToWhitelist(address _beneficiary, uint256 _cap, bool _accredited) external onlyOwner {
caps[_beneficiary] = _cap;
accredited[_beneficiary] = _accredited;
}
| function addToWhitelist(address _beneficiary, uint256 _cap, bool _accredited) external onlyOwner {
caps[_beneficiary] = _cap;
accredited[_beneficiary] = _accredited;
}
| 87,930 |
27 | // Note: Intentionally not using _safeMint(). | uint256 tokenId = _mint(sender);
require(
tokenId < mintArgs.maxTokenIdExclusive,
"Series max supply exceeded"
);
require(
tokenId < MAX_SUPPLY,
"Global max supply exceeded"
);
| uint256 tokenId = _mint(sender);
require(
tokenId < mintArgs.maxTokenIdExclusive,
"Series max supply exceeded"
);
require(
tokenId < MAX_SUPPLY,
"Global max supply exceeded"
);
| 30,886 |
76 | // Credit fillers for each fill.wantAmount,and credit the operator/ for each fill.feeAmount. See the `trade` method for param details./_values Values from `trade` | function _creditFillBalances(
uint256[] memory _increments,
uint256[] memory _values
)
private
pure
| function _creditFillBalances(
uint256[] memory _increments,
uint256[] memory _values
)
private
pure
| 42,970 |
23 | // transactionsByStore[_storeHash].push(transactDetails); |
bytes32 transactionHash=keccak256(abi.encodePacked(_amount, _storeHash,_typeOfTrans,_itemHash ,now));
transactionDetails.amount=_amount;
transactionDetails.buyer=msg.sender;
transactionDetails.seller= store[_storeHash].owner;
transactionDetails.storeHash=_storeHash;
transactionDetails.transactionHash=transactionHash;
transactionDetails.typeOfTrans = _typeOfTrans;
|
bytes32 transactionHash=keccak256(abi.encodePacked(_amount, _storeHash,_typeOfTrans,_itemHash ,now));
transactionDetails.amount=_amount;
transactionDetails.buyer=msg.sender;
transactionDetails.seller= store[_storeHash].owner;
transactionDetails.storeHash=_storeHash;
transactionDetails.transactionHash=transactionHash;
transactionDetails.typeOfTrans = _typeOfTrans;
| 48,780 |
22 | // Compute fees for right order | matchedFillResults.right.makerFeePaid = safeGetPartialAmountFloor(
matchedFillResults.right.makerAssetFilledAmount,
rightOrder.makerAssetAmount,
rightOrder.makerFee
);
matchedFillResults.right.takerFeePaid = safeGetPartialAmountFloor(
matchedFillResults.right.takerAssetFilledAmount,
rightOrder.takerAssetAmount,
rightOrder.takerFee
);
| matchedFillResults.right.makerFeePaid = safeGetPartialAmountFloor(
matchedFillResults.right.makerAssetFilledAmount,
rightOrder.makerAssetAmount,
rightOrder.makerFee
);
matchedFillResults.right.takerFeePaid = safeGetPartialAmountFloor(
matchedFillResults.right.takerAssetFilledAmount,
rightOrder.takerAssetAmount,
rightOrder.takerFee
);
| 3,284 |
112 | // Adding unclaimed $BBONES to claimableBalance | claimableBalance[msg.sender] += getTokenUPNL(tokenId, msg.sender);
stakeHolders[msg.sender].tokenStakeBlock[tokenId] = 0;
uint tokensCount = stakeHolders[msg.sender].stakedTokens.length;
uint[] memory newStakedTokens = new uint[](tokensCount - 1);
uint j = 0;
for (uint i = 0; i < tokensCount; i++) {
| claimableBalance[msg.sender] += getTokenUPNL(tokenId, msg.sender);
stakeHolders[msg.sender].tokenStakeBlock[tokenId] = 0;
uint tokensCount = stakeHolders[msg.sender].stakedTokens.length;
uint[] memory newStakedTokens = new uint[](tokensCount - 1);
uint j = 0;
for (uint i = 0; i < tokensCount; i++) {
| 81,054 |
106 | // Add an offer to the current OfferPeriod. Excess value is saved as collateral. / | function offer(string memory uriPath, address payoutAddress) external payable whenNotPaused nonReentrant {
// Consider adding map + check that the URI is not already present
require(block.number >= offerPeriod.offerStartBlock, "Offer period hasn't begun");
require(block.number < offerPeriod.offerEndBlock, "Offer period has ended." );
require(msg.value >= minCollateral + offerFee, "Must include collateral and fee.");
offerPeriodToAddressCollateral[offerPeriod.id][msg.sender] += msg.value - offerFee;
_safeTransferETHWithFallback(koansDAO, offerFee);
Offer memory offer = Offer({
uriPath: uriPath,
payoutAddress: payoutAddress,
voteCount: 0
});
offersPerOfferPeriod[offerPeriod.id].push(offer);
emit ArtOffered(
/*offerPeriodId=*/offerPeriod.id,
/*submitter=*/msg.sender,
/*offerIndex=*/offersPerOfferPeriod[offerPeriod.id].length - 1,
/*uriPath=*/uriPath,
/*payoutAddress=*/payoutAddress);
}
| function offer(string memory uriPath, address payoutAddress) external payable whenNotPaused nonReentrant {
// Consider adding map + check that the URI is not already present
require(block.number >= offerPeriod.offerStartBlock, "Offer period hasn't begun");
require(block.number < offerPeriod.offerEndBlock, "Offer period has ended." );
require(msg.value >= minCollateral + offerFee, "Must include collateral and fee.");
offerPeriodToAddressCollateral[offerPeriod.id][msg.sender] += msg.value - offerFee;
_safeTransferETHWithFallback(koansDAO, offerFee);
Offer memory offer = Offer({
uriPath: uriPath,
payoutAddress: payoutAddress,
voteCount: 0
});
offersPerOfferPeriod[offerPeriod.id].push(offer);
emit ArtOffered(
/*offerPeriodId=*/offerPeriod.id,
/*submitter=*/msg.sender,
/*offerIndex=*/offersPerOfferPeriod[offerPeriod.id].length - 1,
/*uriPath=*/uriPath,
/*payoutAddress=*/payoutAddress);
}
| 22,371 |
9 | // validate the request: if this is a constructor call, make sure it is a known account. verify the sender has enough tokens. (since the paymaster is also the token, there is no notion of "approval")/ | function _validatePaymasterUserOp(UserOperation calldata userOp, bytes32 /*userOpHash*/, uint256 requiredPreFund)
| function _validatePaymasterUserOp(UserOperation calldata userOp, bytes32 /*userOpHash*/, uint256 requiredPreFund)
| 21,769 |
90 | // Migrate all asset and vault ownership,if any, to new strategy _beforeMigration hook can be implemented in child strategy to do extra steps. _newStrategy Address of new strategy / | function migrate(address _newStrategy) external virtual override onlyPool {
require(_newStrategy != address(0), "new-strategy-address-is-zero");
require(IStrategy(_newStrategy).pool() == pool, "not-valid-new-strategy");
_beforeMigration(_newStrategy);
IERC20(receiptToken).safeTransfer(_newStrategy, IERC20(receiptToken).balanceOf(address(this)));
collateralToken.safeTransfer(_newStrategy, collateralToken.balanceOf(address(this)));
}
| function migrate(address _newStrategy) external virtual override onlyPool {
require(_newStrategy != address(0), "new-strategy-address-is-zero");
require(IStrategy(_newStrategy).pool() == pool, "not-valid-new-strategy");
_beforeMigration(_newStrategy);
IERC20(receiptToken).safeTransfer(_newStrategy, IERC20(receiptToken).balanceOf(address(this)));
collateralToken.safeTransfer(_newStrategy, collateralToken.balanceOf(address(this)));
}
| 61,446 |
167 | // Sets the VaultLib target for the VaultProxy/_nextVaultLib The address to set as the VaultLib/This function is absolutely critical. __updateCodeAddress() validates that the/ target is a valid Proxiable contract instance./ Does not block _nextVaultLib from being the same as the current VaultLib | function setVaultLib(address _nextVaultLib) external override {
require(msg.sender == creator, "setVaultLib: Only callable by the contract creator");
address prevVaultLib = getVaultLib();
__updateCodeAddress(_nextVaultLib);
emit VaultLibSet(prevVaultLib, _nextVaultLib);
}
| function setVaultLib(address _nextVaultLib) external override {
require(msg.sender == creator, "setVaultLib: Only callable by the contract creator");
address prevVaultLib = getVaultLib();
__updateCodeAddress(_nextVaultLib);
emit VaultLibSet(prevVaultLib, _nextVaultLib);
}
| 62,420 |
38 | // Reads an address from a position in a byte array./b Byte array containing an address./index Index in byte array of address./ return address from byte array. | function readAddress(
bytes memory b,
uint256 index
)
internal
pure
returns (address result)
{
require(
b.length >= index + 20, // 20 is length of address
| function readAddress(
bytes memory b,
uint256 index
)
internal
pure
returns (address result)
{
require(
b.length >= index + 20, // 20 is length of address
| 5,755 |
81 | // Settle the current trading day. Settlement includes the following changes/ to the fund.// 1. Transfer protocol fee of the day to the fee collector./ 2. Settle all pending creations and redemptions from all primary markets./ 3. Calculate NAV of the day and trigger rebalance if necessary./ 4. Capture new interest rate for Token A. | function settle() external nonReentrant {
uint256 day = currentDay;
uint256 currentWeek = _endOfWeek(day - 1 days);
require(block.timestamp >= day, "The current trading day does not end yet");
uint256 price = twapOracle.getTwap(day);
require(price != 0, "Underlying price for settlement is not ready yet");
_collectFee();
_settlePrimaryMarkets(day, price);
// Calculate NAV
uint256 totalShares = getTotalShares();
uint256 underlying = IERC20(tokenUnderlying).balanceOf(address(this));
uint256 navA = _historicalNavs[day - 1 days][TRANCHE_A];
uint256 navM;
if (totalShares > 0) {
navM = price.mul(underlying.mul(underlyingDecimalMultiplier)).div(totalShares);
if (historicalTotalShares[day - 1 days] > 0) {
// Update NAV of Token A only when the fund is non-empty both before and after
// this settlement
uint256 newNavA =
navA.multiplyDecimal(UNIT.sub(dailyProtocolFeeRate)).multiplyDecimal(
historicalInterestRate[currentWeek].add(UNIT)
);
if (navA < newNavA) {
navA = newNavA;
}
}
} else {
// If the fund is empty, use NAV of Token M in the last day
navM = _historicalNavs[day - 1 days][TRANCHE_M];
}
uint256 navB = calculateNavB(navM, navA);
if (_shouldTriggerRebalance(navA, navB)) {
_triggerRebalance(day, navM, navA, navB);
navM = UNIT;
navA = UNIT;
navB = UNIT;
totalShares = getTotalShares();
fundActivityStartTime = day + activityDelayTimeAfterRebalance;
exchangeActivityStartTime = day + activityDelayTimeAfterRebalance;
} else {
fundActivityStartTime = day;
exchangeActivityStartTime = day + 30 minutes;
}
if (currentDay == currentWeek) {
historicalInterestRate[currentWeek + 1 weeks] = _updateInterestRate(currentWeek);
}
historicalTotalShares[day] = totalShares;
historicalUnderlying[day] = underlying;
_historicalNavs[day][TRANCHE_M] = navM;
_historicalNavs[day][TRANCHE_A] = navA;
_historicalNavs[day][TRANCHE_B] = navB;
currentDay = day + 1 days;
if (obsoletePrimaryMarkets.length > 0) {
for (uint256 i = 0; i < obsoletePrimaryMarkets.length; i++) {
_removePrimaryMarket(obsoletePrimaryMarkets[i]);
}
delete obsoletePrimaryMarkets;
}
if (newPrimaryMarkets.length > 0) {
for (uint256 i = 0; i < newPrimaryMarkets.length; i++) {
_addPrimaryMarket(newPrimaryMarkets[i]);
}
delete newPrimaryMarkets;
}
emit Settled(day, navM, navA, navB);
}
| function settle() external nonReentrant {
uint256 day = currentDay;
uint256 currentWeek = _endOfWeek(day - 1 days);
require(block.timestamp >= day, "The current trading day does not end yet");
uint256 price = twapOracle.getTwap(day);
require(price != 0, "Underlying price for settlement is not ready yet");
_collectFee();
_settlePrimaryMarkets(day, price);
// Calculate NAV
uint256 totalShares = getTotalShares();
uint256 underlying = IERC20(tokenUnderlying).balanceOf(address(this));
uint256 navA = _historicalNavs[day - 1 days][TRANCHE_A];
uint256 navM;
if (totalShares > 0) {
navM = price.mul(underlying.mul(underlyingDecimalMultiplier)).div(totalShares);
if (historicalTotalShares[day - 1 days] > 0) {
// Update NAV of Token A only when the fund is non-empty both before and after
// this settlement
uint256 newNavA =
navA.multiplyDecimal(UNIT.sub(dailyProtocolFeeRate)).multiplyDecimal(
historicalInterestRate[currentWeek].add(UNIT)
);
if (navA < newNavA) {
navA = newNavA;
}
}
} else {
// If the fund is empty, use NAV of Token M in the last day
navM = _historicalNavs[day - 1 days][TRANCHE_M];
}
uint256 navB = calculateNavB(navM, navA);
if (_shouldTriggerRebalance(navA, navB)) {
_triggerRebalance(day, navM, navA, navB);
navM = UNIT;
navA = UNIT;
navB = UNIT;
totalShares = getTotalShares();
fundActivityStartTime = day + activityDelayTimeAfterRebalance;
exchangeActivityStartTime = day + activityDelayTimeAfterRebalance;
} else {
fundActivityStartTime = day;
exchangeActivityStartTime = day + 30 minutes;
}
if (currentDay == currentWeek) {
historicalInterestRate[currentWeek + 1 weeks] = _updateInterestRate(currentWeek);
}
historicalTotalShares[day] = totalShares;
historicalUnderlying[day] = underlying;
_historicalNavs[day][TRANCHE_M] = navM;
_historicalNavs[day][TRANCHE_A] = navA;
_historicalNavs[day][TRANCHE_B] = navB;
currentDay = day + 1 days;
if (obsoletePrimaryMarkets.length > 0) {
for (uint256 i = 0; i < obsoletePrimaryMarkets.length; i++) {
_removePrimaryMarket(obsoletePrimaryMarkets[i]);
}
delete obsoletePrimaryMarkets;
}
if (newPrimaryMarkets.length > 0) {
for (uint256 i = 0; i < newPrimaryMarkets.length; i++) {
_addPrimaryMarket(newPrimaryMarkets[i]);
}
delete newPrimaryMarkets;
}
emit Settled(day, navM, navA, navB);
}
| 24,515 |
156 | // Returns the number of decimals the token uses for value. / | function valueDecimals() public view virtual override returns (uint8) {
return _decimals;
}
| function valueDecimals() public view virtual override returns (uint8) {
return _decimals;
}
| 43,176 |
20 | // The maximum withdrawable _underlyingToken in the market. _underlyingToken Token to get liquidity. / | function getRealLiquidity(address _underlyingToken)
public
view
returns (uint256)
| function getRealLiquidity(address _underlyingToken)
public
view
returns (uint256)
| 37,653 |
59 | // Currently used reward in cycle - used to calculate remaining reward at the reward notification | uint256 public usedReward;
| uint256 public usedReward;
| 7,258 |
13 | // This contract implements lottery logic. / | contract Lottery is AccessControl {
using SafeMath for uint256;
using Address for address;
bytes32 public constant LOTTERY_ADMIN_ROLE = keccak256("LOTTERY_ADMIN_ROLE");
bytes32 public constant EXECUTOR_ROLE = keccak256("EXECUTOR_ROLE");
mapping(uint256 => uint256[]) private _results;
/**
* @dev Modifier to make a function callable only by a certain role.
*/
modifier onlyRole(bytes32 role) {
require(hasRole(role, _msgSender()) || hasRole(role, address(0)), "Lottery: sender requires permission");
_;
}
/**
* @dev Emitted when lottery drew.
*/
event LotteryDrew(uint256 indexed drawings, address indexed executor);
/**
* @dev Emitted when drew numbers.
*/
event LotteryNumbers(uint256 indexed drawings, uint256 number1, uint256 number2, uint256 number3, uint256 number4);
/**
* @dev Sets the values for {executors}.
*/
constructor (address[] memory executors) {
_setRoleAdmin(LOTTERY_ADMIN_ROLE, LOTTERY_ADMIN_ROLE);
_setRoleAdmin(EXECUTOR_ROLE, EXECUTOR_ROLE);
// deployer + self administration
_setupRole(LOTTERY_ADMIN_ROLE, _msgSender());
_setupRole(LOTTERY_ADMIN_ROLE, address(this));
// register executors
for (uint256 i = 0; i < executors.length; ++i) {
_setupRole(EXECUTOR_ROLE, executors[i]);
}
}
/**
* @dev Draw numbers.
*/
function draw(uint256 drawings) public virtual {
require(_results[drawings].length <= 4, "Already drew 4 times");
// simply request each numnber here
_requestRandomness(drawings);
emit LotteryDrew(drawings, _msgSender());
}
/**
* @dev Returns whether user is winner.
*/
function isWinner(uint256 drawings, uint256[] memory numbers) public view virtual returns (bool) {
require(_results[drawings].length == 4, "Not yet draw");
uint256 matches = 0;
for (uint256 i = 0; i < _results[drawings].length; i++) {
if (_results[drawings][i] == numbers[i]) {
matches = matches + 1;
}
}
return (matches >= 3);
}
/**
* @dev Returns whether user is winner.
*/
function drawingNumbers(uint256 drawings) public view virtual returns (uint256[] memory) {
require(_results[drawings].length == 4, "Not yet draw");
return _results[drawings];
}
/**
* @dev Draw numbers.
* HK mark six max number: 49
*/
function _fulfillRandomness(uint256 drawings, uint256 randomness) internal {
uint256 number = randomness.mod(49).add(1);
_results[drawings].push(number);
if (_results[drawings].length == 4) {
emit LotteryNumbers(drawings, _results[drawings][0], _results[drawings][1], _results[drawings][2], _results[drawings][3]);
}
}
/**
* @dev Request random numbers.
* Call via oracle, but not implement here.
*/
function _requestRandomness(uint256 drawings) internal {
_fulfillRandomness(drawings, block.timestamp);
}
}
| contract Lottery is AccessControl {
using SafeMath for uint256;
using Address for address;
bytes32 public constant LOTTERY_ADMIN_ROLE = keccak256("LOTTERY_ADMIN_ROLE");
bytes32 public constant EXECUTOR_ROLE = keccak256("EXECUTOR_ROLE");
mapping(uint256 => uint256[]) private _results;
/**
* @dev Modifier to make a function callable only by a certain role.
*/
modifier onlyRole(bytes32 role) {
require(hasRole(role, _msgSender()) || hasRole(role, address(0)), "Lottery: sender requires permission");
_;
}
/**
* @dev Emitted when lottery drew.
*/
event LotteryDrew(uint256 indexed drawings, address indexed executor);
/**
* @dev Emitted when drew numbers.
*/
event LotteryNumbers(uint256 indexed drawings, uint256 number1, uint256 number2, uint256 number3, uint256 number4);
/**
* @dev Sets the values for {executors}.
*/
constructor (address[] memory executors) {
_setRoleAdmin(LOTTERY_ADMIN_ROLE, LOTTERY_ADMIN_ROLE);
_setRoleAdmin(EXECUTOR_ROLE, EXECUTOR_ROLE);
// deployer + self administration
_setupRole(LOTTERY_ADMIN_ROLE, _msgSender());
_setupRole(LOTTERY_ADMIN_ROLE, address(this));
// register executors
for (uint256 i = 0; i < executors.length; ++i) {
_setupRole(EXECUTOR_ROLE, executors[i]);
}
}
/**
* @dev Draw numbers.
*/
function draw(uint256 drawings) public virtual {
require(_results[drawings].length <= 4, "Already drew 4 times");
// simply request each numnber here
_requestRandomness(drawings);
emit LotteryDrew(drawings, _msgSender());
}
/**
* @dev Returns whether user is winner.
*/
function isWinner(uint256 drawings, uint256[] memory numbers) public view virtual returns (bool) {
require(_results[drawings].length == 4, "Not yet draw");
uint256 matches = 0;
for (uint256 i = 0; i < _results[drawings].length; i++) {
if (_results[drawings][i] == numbers[i]) {
matches = matches + 1;
}
}
return (matches >= 3);
}
/**
* @dev Returns whether user is winner.
*/
function drawingNumbers(uint256 drawings) public view virtual returns (uint256[] memory) {
require(_results[drawings].length == 4, "Not yet draw");
return _results[drawings];
}
/**
* @dev Draw numbers.
* HK mark six max number: 49
*/
function _fulfillRandomness(uint256 drawings, uint256 randomness) internal {
uint256 number = randomness.mod(49).add(1);
_results[drawings].push(number);
if (_results[drawings].length == 4) {
emit LotteryNumbers(drawings, _results[drawings][0], _results[drawings][1], _results[drawings][2], _results[drawings][3]);
}
}
/**
* @dev Request random numbers.
* Call via oracle, but not implement here.
*/
function _requestRandomness(uint256 drawings) internal {
_fulfillRandomness(drawings, block.timestamp);
}
}
| 30,722 |
36 | // sets the referenced backup oracle/newBackupOracle the new backup oracle to reference | function setBackupOracle(address newBackupOracle) external override onlyGovernorOrAdmin {
_setBackupOracle(newBackupOracle);
}
| function setBackupOracle(address newBackupOracle) external override onlyGovernorOrAdmin {
_setBackupOracle(newBackupOracle);
}
| 44,188 |
1 | // keccak256(setThreshold(bytes32,uint256)) | bytes32 public constant SET_THRESHOLD_THRESHOLD = bytes32(uint256(0xa4db7b4d));
uint256 public constant DECIMALS = 10**6;
| bytes32 public constant SET_THRESHOLD_THRESHOLD = bytes32(uint256(0xa4db7b4d));
uint256 public constant DECIMALS = 10**6;
| 11,734 |
5 | // Withdraws asset from the converter. Only owner can withdraw. / | function withdraw(address _token, uint256 _amount) external onlyOwner {
IERC20Upgradeable(_token).safeTransfer(msg.sender, _amount);
}
| function withdraw(address _token, uint256 _amount) external onlyOwner {
IERC20Upgradeable(_token).safeTransfer(msg.sender, _amount);
}
| 46,178 |
45 | // Constant overhead | RELAY_CONSTANT_OVERHEAD
| RELAY_CONSTANT_OVERHEAD
| 27,739 |
1 | // setConfig _key config key _value cofig data / | function setConfigData(string memory _key, bytes32 _value) public onlyAdmin {
getDataStore().addConfigData(_key, _value);
}
| function setConfigData(string memory _key, bytes32 _value) public onlyAdmin {
getDataStore().addConfigData(_key, _value);
}
| 4,930 |
12 | // stableswap contract interface.Only the functions required for CurveAdapter contract are added.The stableswap contract is available heregithub.com/curvefi/curve-contract/blob/compounded/vyper/stableswap.vy. / solhint-disable-next-line contract-name-camelcase | interface stableswap {
function coins(int128) external view returns (address);
function balances(int128) external view returns (uint256);
}
| interface stableswap {
function coins(int128) external view returns (address);
function balances(int128) external view returns (uint256);
}
| 3,467 |
9 | // Address of the ERC721 bridge on this network. / | function BRIDGE() external view returns (address);
| function BRIDGE() external view returns (address);
| 17,691 |
18 | // overflow when length == 2224 > 2size(priceIndex)_MAX_ORDER, absolutely never happening | unchecked {
totalBounty += mOrder.claimBounty;
}
| unchecked {
totalBounty += mOrder.claimBounty;
}
| 39,746 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.