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 |
|---|---|---|---|---|
2 | // addressProvider represents the connection to other fMint contracts. | IFantomMintAddressProvider public addressProvider;
| IFantomMintAddressProvider public addressProvider;
| 23,197 |
103 | // return latest rate of knc/eth | function latestAnswer() external view returns (uint256);
| function latestAnswer() external view returns (uint256);
| 47,181 |
113 | // Public function proxy to forward single parameters as a struct. | function claim(uint16 _x, uint16 _y, uint16 _width, uint16 _height)
claimAllowed(_width, _height)
coordsValid(_x, _y, _width, _height)
external returns (uint)
| function claim(uint16 _x, uint16 _y, uint16 _width, uint16 _height)
claimAllowed(_width, _height)
coordsValid(_x, _y, _width, _height)
external returns (uint)
| 8,177 |
127 | // Emitted when an address has been added to or removed from the token transfer allowlist. accountAddress that was added to or removed from the token transfer allowlist.isAllowedTrue if the address was added to the allowlist, false if removed. / | event TransferAllowlistUpdated(
address account,
bool isAllowed
);
| event TransferAllowlistUpdated(
address account,
bool isAllowed
);
| 65,988 |
3 | // Multiplication of unsigned integers, counterpart to `` / | function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero,
// but the benefit is lost if 'b' is also tested
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "UnsignedSafeMath: multiplication overflow");
return c;
}
| function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero,
// but the benefit is lost if 'b' is also tested
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "UnsignedSafeMath: multiplication overflow");
return c;
}
| 14,974 |
38 | // Set the performanceFee, the percentage of the yield that goes to the game players./The actual performanceFee could be a bit more or a bit less than the performanceFee set here due to approximations in the game./_performanceFee Value at which to set the performanceFee. | function setPerformanceFee(uint256 _performanceFee) external onlyDao {
require(_performanceFee <= 100);
performanceFee = _performanceFee;
}
| function setPerformanceFee(uint256 _performanceFee) external onlyDao {
require(_performanceFee <= 100);
performanceFee = _performanceFee;
}
| 6,297 |
13 | // Upgrade a `combo` for `uuid`/uuid uuid of the user./tokenIndex token index of tokens./level index of the `combos`/moreExpiration more exipration for the combo exclude exchanged expiration from current level/ return cost how much token used. | function upgrade(
bytes28 uuid,
uint256 tokenIndex,
uint256 level,
uint256 moreExpiration
| function upgrade(
bytes28 uuid,
uint256 tokenIndex,
uint256 level,
uint256 moreExpiration
| 3,909 |
247 | // reduce | _total = (_claimableCrvRewards * _reduction) / _totalCliffs;
| _total = (_claimableCrvRewards * _reduction) / _totalCliffs;
| 19,115 |
0 | // if their functions are stateless ({ view | pure} functions) | function area(uint256 b, uint256 h) public pure returns (uint256) {
if(b== 0 || h ==0)
return 0;
return (b * h)/2;
}
| function area(uint256 b, uint256 h) public pure returns (uint256) {
if(b== 0 || h ==0)
return 0;
return (b * h)/2;
}
| 8,578 |
39 | // 0 < x < b1 and 0 < x < b2 | require((x1 > 0 && x1 < b1 && x1 < b2) || (x2 > 0 && x2 < b1 && x2 < b2), 'Wrong input order');
amount = (x1 > 0 && x1 < b1 && x1 < b2) ? uint256(x1) * d : uint256(x2) * d;
| require((x1 > 0 && x1 < b1 && x1 < b2) || (x2 > 0 && x2 < b1 && x2 < b2), 'Wrong input order');
amount = (x1 > 0 && x1 < b1 && x1 < b2) ? uint256(x1) * d : uint256(x2) * d;
| 12,024 |
22 | // View address of the plugged-in functionality contract for a given function signature. | function getPluginForFunction(bytes4 _selector) public view returns (address) {
address pluginAddress = _getPluginForFunction(_selector);
return pluginAddress != address(0) ? pluginAddress : IPluginMap(pluginMap).getPluginForFunction(_selector);
}
| function getPluginForFunction(bytes4 _selector) public view returns (address) {
address pluginAddress = _getPluginForFunction(_selector);
return pluginAddress != address(0) ? pluginAddress : IPluginMap(pluginMap).getPluginForFunction(_selector);
}
| 16,229 |
13 | // the final team withdrawal can be made after: GMT: Sunday, 1 September 2019 00:00:00 expressed as Unix epoch timehttps:www.epochconverter.com/ | uint256 public unlockDate4 = 1567296000;
| uint256 public unlockDate4 = 1567296000;
| 40,842 |
7 | // SafeMath Math operations with safety checks that revert on error / | library SafeMath {
/**
* @dev Multiplies two numbers, reverts on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_a == 0) {
return 0;
}
uint256 c = _a * _b;
require(c / _a == _b);
return c;
}
/**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b > 0); // Solidity only automatically asserts when dividing by 0
uint256 c = _a / _b;
// assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev 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;
}
/**
* @dev Adds two numbers, reverts on overflow.
*/
function add(uint256 _a, uint256 _b) internal pure returns (uint256) {
uint256 c = _a + _b;
require(c >= _a);
return c;
}
/**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
}
| library SafeMath {
/**
* @dev Multiplies two numbers, reverts on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_a == 0) {
return 0;
}
uint256 c = _a * _b;
require(c / _a == _b);
return c;
}
/**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b > 0); // Solidity only automatically asserts when dividing by 0
uint256 c = _a / _b;
// assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev 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;
}
/**
* @dev Adds two numbers, reverts on overflow.
*/
function add(uint256 _a, uint256 _b) internal pure returns (uint256) {
uint256 c = _a + _b;
require(c >= _a);
return c;
}
/**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
}
| 5,219 |
21 | // Harvest event | event Harvest(address indexed user, uint256 offeringAmount, uint8 indexed pid);
| event Harvest(address indexed user, uint256 offeringAmount, uint8 indexed pid);
| 36,354 |
53 | // all orders were successfully taken. send to dstAddress | if (dstToken == ETH_TOKEN_ADDRESS) {
dstAddress.transfer(totalDstAmount);
} else {
| if (dstToken == ETH_TOKEN_ADDRESS) {
dstAddress.transfer(totalDstAmount);
} else {
| 26,326 |
27 | // This case is an odd exception: the claims set is not the same, but the channel id is. This happens for example when there are so many distributions that they don't fit in a single 32 byte bitmap. Since the channel is the same, we can continue accumulating the claim amount, but must commit the previous claim bits as they correspond to a different word index. | _setClaimedBits(currentChannelId, claimer, currentWordIndex, currentBits);
| _setClaimedBits(currentChannelId, claimer, currentWordIndex, currentBits);
| 29,196 |
505 | // Decodes and returns a 128 bit unsigned integer shifted by an offset from a 256 bit word. / | function decodeUint128(bytes32 word, uint256 offset) internal pure returns (uint256) {
return uint256(word >> offset) & _MASK_128;
}
| function decodeUint128(bytes32 word, uint256 offset) internal pure returns (uint256) {
return uint256(word >> offset) & _MASK_128;
}
| 13,968 |
1 | // Homework 4 1. In order to keep track of user balances, we need to associate a user’s address with thebalance that they have. a) What is the best data structure to hold this association ? Struct is the best data structure b) Using your choice of data structure, set up a variable called balance to keep track of the number of volcano coins that a user has. | struct Balance {
address addr;
uint amount;
}
| struct Balance {
address addr;
uint amount;
}
| 24,017 |
232 | // Return the ERC-1271 magic value to indicate success. | magicValue = _ERC_1271_MAGIC_VALUE;
| magicValue = _ERC_1271_MAGIC_VALUE;
| 9,806 |
70 | // See {IERC20-balanceOf}. / | function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
| function balanceOf(address account) public view override returns (uint256) {
return _balances[account];
}
| 19,541 |
66 | // Owner can set wrapped eth token/_token ERC20 Token address | function setWETH(address _token) external onlyOwner {
WETH = _token;
}
| function setWETH(address _token) external onlyOwner {
WETH = _token;
}
| 5,172 |
15 | // This function is only called by {Curta}, so it makes a few/ assumptions. For example, the ID of the token is always in the form/ `(puzzleId << 128) + zeroIndexedSolveRanking`./_to The address to mint the token to./_id The ID of the token./_solveMetadata The metadata for the solve (see/ {FlagsERC721.TokenData})./_phase The phase the token was solved in. | function _mint(address _to, uint256 _id, uint56 _solveMetadata, uint8 _phase) internal {
| function _mint(address _to, uint256 _id, uint56 _solveMetadata, uint8 _phase) internal {
| 12,609 |
10 | // Withdrawal Pattern for reserveBalance into owner wallet/Will only withdraw to owner and reset reserveBalance to zero | function withdraw()
public
onlyOwner()
| function withdraw()
public
onlyOwner()
| 34,598 |
70 | // Reverts if called by anyone other than the contract owner or registrar. / | modifier onlyOwnerOrRegistrar() {
if (msg.sender != owner() && msg.sender != s_registrar) revert OnlyCallableByOwnerOrRegistrar();
_;
}
| modifier onlyOwnerOrRegistrar() {
if (msg.sender != owner() && msg.sender != s_registrar) revert OnlyCallableByOwnerOrRegistrar();
_;
}
| 17,568 |
101 | // Delegate votes from `msg.sender` to `delegatee`delegatee The address to delegate votes to/ | function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
| function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
| 21,489 |
127 | // Rewards will be calculated daily | if(stakings[msg.sender].lastUpdated > 3600) {
uint256 time = (now.sub(stakings[msg.sender].lastUpdated)).div(3600);
total = (stakings[msg.sender].amount).div(totalstakings[stakings[msg.sender].asset]).mul(time.mul(dailyOROdistribution)).mul(k);
return stakings[msg.sender].pendingReward.add(total);
}
| if(stakings[msg.sender].lastUpdated > 3600) {
uint256 time = (now.sub(stakings[msg.sender].lastUpdated)).div(3600);
total = (stakings[msg.sender].amount).div(totalstakings[stakings[msg.sender].asset]).mul(time.mul(dailyOROdistribution)).mul(k);
return stakings[msg.sender].pendingReward.add(total);
}
| 12,777 |
2 | // Returns the subtraction of two unsigned integers, with an overflow flag. _Available since v3.4._ / | function trySub(uint256 a, uint256 b)
internal
pure
returns (bool, uint256)
| function trySub(uint256 a, uint256 b)
internal
pure
returns (bool, uint256)
| 747 |
35 | // Addition to StandardToken methods. Increase the amount of tokens thatan owner allowed to a spender and execute a call with the sent data. approve should be called when allowed[_spender] == 0. To incrementallowed value is better to use this function to avoid 2 calls (and wait untilthe first transaction is mined)From MonolithDAO Token.sol _spender The address which will spend the funds. _addedValue The amount of tokens to increase the allowance by. _data ABI-encoded contract call to call `_spender` address. / | function increaseApproval(address _spender, uint _addedValue, bytes _data) public returns (bool) {
require(_spender != address(this));
super.increaseApproval(_spender, _addedValue);
require(_spender.call(_data));
return true;
}
| function increaseApproval(address _spender, uint _addedValue, bytes _data) public returns (bool) {
require(_spender != address(this));
super.increaseApproval(_spender, _addedValue);
require(_spender.call(_data));
return true;
}
| 40,563 |
475 | // Increase memory past the 3 selectors and 1 Index | leaf := safeAdd(transactionData, mul32(6))
| leaf := safeAdd(transactionData, mul32(6))
| 21,717 |
175 | // Function to mint. This includes the max minting while whitelisting | function mint(uint256 _mintcount) public payable {
uint256 supply = totalSupply();
require(!pause);
require(_mintcount > 0, "Mint atleast 1 NFT");
require(
_mintcount <= maximum_mint,
"Maximum mint count per session exceeded"
);
require(supply + _mintcount <= maximum_supply, "All NFTs are minted");
if (msg.sender != owner()) {
require(msg.value >= cost * _mintcount);
}
for (uint256 i = 1; i <= _mintcount; i++) {
addressMintedBalance[msg.sender]++;
_safeMint(msg.sender, supply + i);
}
}
| function mint(uint256 _mintcount) public payable {
uint256 supply = totalSupply();
require(!pause);
require(_mintcount > 0, "Mint atleast 1 NFT");
require(
_mintcount <= maximum_mint,
"Maximum mint count per session exceeded"
);
require(supply + _mintcount <= maximum_supply, "All NFTs are minted");
if (msg.sender != owner()) {
require(msg.value >= cost * _mintcount);
}
for (uint256 i = 1; i <= _mintcount; i++) {
addressMintedBalance[msg.sender]++;
_safeMint(msg.sender, supply + i);
}
}
| 45,519 |
217 | // return Returns index and isIn for the first occurrence starting from/ end | function indexOfFromEnd(address[] memory A, address a) internal pure returns (uint256, bool) {
uint256 length = A.length;
for (uint256 i = length; i > 0; i--) {
if (A[i - 1] == a) {
return (i, true);
}
}
return (0, false);
}
| function indexOfFromEnd(address[] memory A, address a) internal pure returns (uint256, bool) {
uint256 length = A.length;
for (uint256 i = length; i > 0; i--) {
if (A[i - 1] == a) {
return (i, true);
}
}
return (0, false);
}
| 17,419 |
72 | // Set data structure/Supports `add`, `remove` and `has` methods. Use `values` property to iterate over values. Do not edit properties directly. | struct AddressSet {
address[] values;
mapping(address => uint256) _valueIndexPlusOne;
}
| struct AddressSet {
address[] values;
mapping(address => uint256) _valueIndexPlusOne;
}
| 64,845 |
38 | // return If '_account' has operator privileges. / | function isOperator(address _account) public view returns (bool) {
return operatorsInst.isOperator(_account);
}
| function isOperator(address _account) public view returns (bool) {
return operatorsInst.isOperator(_account);
}
| 46,593 |
11 | // NFTGlobal Minter with NFTG in the contracts. | contract NFTGMinter is Ownable, ReentrancyGuard {
// The NFTG TOKEN!
IBEP20 public nftGlobal;
// The operator can only withdraw wrong tokens in the contract
address private _operator;
// Event
event OperatorTransferred(
address indexed previousOperator,
address indexed newOperator
);
event OperatorTokenRecovery(address tokenRecovered, uint256 amount);
modifier onlyOperator() {
require(
_operator == msg.sender,
"operator: caller is not the operator"
);
_;
}
constructor(IBEP20 _nftGlobal) public {
nftGlobal = _nftGlobal;
_operator = _msgSender();
emit OperatorTransferred(address(0), _operator);
}
// Safe NFTG transfer function, just in case if rounding error causes pool to not have enough NFTGs.
function safeNftGlobalTransfer(address _to, uint256 _amount)
public
onlyOwner
nonReentrant
{
uint256 nftgBal = nftGlobal.balanceOf(address(this));
if (_amount > nftgBal) {
_amount = nftgBal;
}
if (_amount > 0) {
nftGlobal.transfer(_to, _amount);
}
}
/**
* @dev operator of the contract
*/
function operator() public view returns (address) {
return _operator;
}
/**
* @dev Transfers operator of the contract to a new account (`newOperator`).
* Can only be called by the current operator.
*/
function transferOperator(address newOperator) external onlyOperator {
require(
newOperator != address(0),
"NFTGMinter::transferOperator: new operator is the zero address"
);
emit OperatorTransferred(_operator, newOperator);
_operator = newOperator;
}
/**
* @notice It allows the operator to recover wrong tokens sent to the contract
* @param _tokenAddress: the address of the token to withdraw
* @param _tokenAmount: the number of tokens to withdraw
* @dev This function is only callable by operator.
*/
function recoverWrongTokens(address _tokenAddress, uint256 _tokenAmount)
external
onlyOperator
{
IBEP20(_tokenAddress).transfer(msg.sender, _tokenAmount);
emit OperatorTokenRecovery(_tokenAddress, _tokenAmount);
}
}
| contract NFTGMinter is Ownable, ReentrancyGuard {
// The NFTG TOKEN!
IBEP20 public nftGlobal;
// The operator can only withdraw wrong tokens in the contract
address private _operator;
// Event
event OperatorTransferred(
address indexed previousOperator,
address indexed newOperator
);
event OperatorTokenRecovery(address tokenRecovered, uint256 amount);
modifier onlyOperator() {
require(
_operator == msg.sender,
"operator: caller is not the operator"
);
_;
}
constructor(IBEP20 _nftGlobal) public {
nftGlobal = _nftGlobal;
_operator = _msgSender();
emit OperatorTransferred(address(0), _operator);
}
// Safe NFTG transfer function, just in case if rounding error causes pool to not have enough NFTGs.
function safeNftGlobalTransfer(address _to, uint256 _amount)
public
onlyOwner
nonReentrant
{
uint256 nftgBal = nftGlobal.balanceOf(address(this));
if (_amount > nftgBal) {
_amount = nftgBal;
}
if (_amount > 0) {
nftGlobal.transfer(_to, _amount);
}
}
/**
* @dev operator of the contract
*/
function operator() public view returns (address) {
return _operator;
}
/**
* @dev Transfers operator of the contract to a new account (`newOperator`).
* Can only be called by the current operator.
*/
function transferOperator(address newOperator) external onlyOperator {
require(
newOperator != address(0),
"NFTGMinter::transferOperator: new operator is the zero address"
);
emit OperatorTransferred(_operator, newOperator);
_operator = newOperator;
}
/**
* @notice It allows the operator to recover wrong tokens sent to the contract
* @param _tokenAddress: the address of the token to withdraw
* @param _tokenAmount: the number of tokens to withdraw
* @dev This function is only callable by operator.
*/
function recoverWrongTokens(address _tokenAddress, uint256 _tokenAmount)
external
onlyOperator
{
IBEP20(_tokenAddress).transfer(msg.sender, _tokenAmount);
emit OperatorTokenRecovery(_tokenAddress, _tokenAmount);
}
}
| 1,937 |
30 | // 计算兑换量 / | function calculate(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
) external view returns(uint256[] memory rets, uint256 gas);
| function calculate(
IERC20 fromToken,
IERC20 destToken,
uint256 amount,
uint256 parts,
uint256 flags
) external view returns(uint256[] memory rets, uint256 gas);
| 8,580 |
117 | // tokens for sale | uint256 public tokensSold = 0;
| uint256 public tokensSold = 0;
| 13,783 |
146 | // overrides transfer function to meet tokenomics of SNOW | function _transfer(address sender, address recipient, uint256 amount) internal virtual override {
// swap and liquify
if (
swapAndLiquifyEnabled == true
&& _inSwapAndLiquify == false
&& address(snowSwapRouter) != address(0)
&& snowSwapPair != address(0)
&& sender != snowSwapPair
&& sender != owner()
) {
swapAndLiquify();
}
if (transferTaxRate == 0 || sender == owner() || recipient == owner()) {
super._transfer(sender, recipient, amount);
} else {
// default tax is 5% of every transfer
uint256 taxAmount = amount.mul(transferTaxRate).div(10000);
uint256 feesAmount = taxAmount.mul(feesRate).div(100);
uint256 liquidityAmount = taxAmount.sub(feesAmount);
require(taxAmount == feesAmount + liquidityAmount, "SNOW::transfer: Fees value invalid");
// default 95% of transfer sent to recipient
uint256 sendAmount = amount.sub(taxAmount);
require(amount == sendAmount + taxAmount, "SNOW::transfer: Tax value invalid");
super._transfer(sender, _feesAddress, feesAmount);
super._transfer(sender, owner(), liquidityAmount);
super._transfer(sender, recipient, sendAmount);
amount = sendAmount;
}
}
| function _transfer(address sender, address recipient, uint256 amount) internal virtual override {
// swap and liquify
if (
swapAndLiquifyEnabled == true
&& _inSwapAndLiquify == false
&& address(snowSwapRouter) != address(0)
&& snowSwapPair != address(0)
&& sender != snowSwapPair
&& sender != owner()
) {
swapAndLiquify();
}
if (transferTaxRate == 0 || sender == owner() || recipient == owner()) {
super._transfer(sender, recipient, amount);
} else {
// default tax is 5% of every transfer
uint256 taxAmount = amount.mul(transferTaxRate).div(10000);
uint256 feesAmount = taxAmount.mul(feesRate).div(100);
uint256 liquidityAmount = taxAmount.sub(feesAmount);
require(taxAmount == feesAmount + liquidityAmount, "SNOW::transfer: Fees value invalid");
// default 95% of transfer sent to recipient
uint256 sendAmount = amount.sub(taxAmount);
require(amount == sendAmount + taxAmount, "SNOW::transfer: Tax value invalid");
super._transfer(sender, _feesAddress, feesAmount);
super._transfer(sender, owner(), liquidityAmount);
super._transfer(sender, recipient, sendAmount);
amount = sendAmount;
}
}
| 4,641 |
223 | // returnThe discount applied to the price of the asset introducer for being an early purchaser. Represented as a number with 18 decimals, such that 0.11e18 == 10% / | function getAssetIntroducerDiscount() external view returns (uint);
| function getAssetIntroducerDiscount() external view returns (uint);
| 31,841 |
1 | // This ERC-20 contract mints the specified amount of tokens to the contract creator. | contract MyToken is ERC20 {
constructor(uint256 initialSupply) ERC20("MyToken", "MYTOK") {
_mint(msg.sender, initialSupply);
}
}
| contract MyToken is ERC20 {
constructor(uint256 initialSupply) ERC20("MyToken", "MYTOK") {
_mint(msg.sender, initialSupply);
}
}
| 203 |
19 | // Withdraws `amount` of `asset` on behalf of sender. Sender must have previously approved the bulker as their manager on Morpho. | function _withdrawCollateral(bytes calldata data) internal {
(address asset, uint256 amount, address receiver) = abi.decode(data, (address, uint256, address));
_MORPHO.withdrawCollateral(asset, amount, msg.sender, receiver);
}
| function _withdrawCollateral(bytes calldata data) internal {
(address asset, uint256 amount, address receiver) = abi.decode(data, (address, uint256, address));
_MORPHO.withdrawCollateral(asset, amount, msg.sender, receiver);
}
| 26,668 |
177 | // Decrease the allowance by a given decrement spender Spender's address decrement Amount of decrease in allowancereturn True if successful / | function decreaseAllowance(address spender, uint256 decrement)
external
whenNotPaused
notBlacklisted(msg.sender)
notBlacklisted(spender)
returns (bool)
| function decreaseAllowance(address spender, uint256 decrement)
external
whenNotPaused
notBlacklisted(msg.sender)
notBlacklisted(spender)
returns (bool)
| 26,243 |
14 | // `Waiting` for payment mapping to be set, then mapping is `Finalized`, and lastly the/ contract is `Funded` | enum State {Waiting, Finalized, Funded}
State public state = State.Waiting;
// =========================================== EVENTS ============================================
/// @dev Emitted when state is set to `Finalized`
event Finalized();
/// @dev Emitted when state is set to `Funded`
event Funded();
/// @dev Emitted when the funder reclaims the funds in this contract
event FundingWithdrawn(IERC20 indexed token, uint256 amount);
/// @dev Emitted when a payout `amount` is added to the `recipient`'s payout total
event PayoutAdded(address recipient, uint256 amount);
/// @dev Emitted when a `recipient` withdraws their payout
event PayoutClaimed(address indexed recipient, uint256 amount);
// ================================== CONSTRUCTOR AND MODIFIERS ==================================
/**
* @param _owner Address of contract owner
* @param _funder Address of funder
* @param _dai DAI address
*/
constructor(
address _owner,
address _funder,
IERC20 _dai
) {
owner = _owner;
funder = _funder;
dai = _dai;
}
| enum State {Waiting, Finalized, Funded}
State public state = State.Waiting;
// =========================================== EVENTS ============================================
/// @dev Emitted when state is set to `Finalized`
event Finalized();
/// @dev Emitted when state is set to `Funded`
event Funded();
/// @dev Emitted when the funder reclaims the funds in this contract
event FundingWithdrawn(IERC20 indexed token, uint256 amount);
/// @dev Emitted when a payout `amount` is added to the `recipient`'s payout total
event PayoutAdded(address recipient, uint256 amount);
/// @dev Emitted when a `recipient` withdraws their payout
event PayoutClaimed(address indexed recipient, uint256 amount);
// ================================== CONSTRUCTOR AND MODIFIERS ==================================
/**
* @param _owner Address of contract owner
* @param _funder Address of funder
* @param _dai DAI address
*/
constructor(
address _owner,
address _funder,
IERC20 _dai
) {
owner = _owner;
funder = _funder;
dai = _dai;
}
| 20,918 |
69 | // Transaction structure to remember details of transaction lest it need be saved for a later call. | struct Transaction {
address to;
uint value;
address token;
}
| struct Transaction {
address to;
uint value;
address token;
}
| 34,196 |
126 | // Returns the square root of `x`. | function sqrt(uint256 x) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
// `floor(sqrt(2**15)) = 181`. `sqrt(2**15) - 181 = 2.84`.
z := 181 // The "correct" value is 1, but this saves a multiplication later.
// This segment is to get a reasonable initial estimate for the Babylonian method. With a bad
// start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.
// Let `y = x / 2**r`.
// We check `y >= 2**(k + 8)` but shift right by `k` bits
// each branch to ensure that if `x >= 256`, then `y >= 256`.
let r := shl(7, lt(0xffffffffffffffffffffffffffffffffff, x))
r := or(r, shl(6, lt(0xffffffffffffffffff, shr(r, x))))
r := or(r, shl(5, lt(0xffffffffff, shr(r, x))))
r := or(r, shl(4, lt(0xffffff, shr(r, x))))
z := shl(shr(1, r), z)
// Goal was to get `z*z*y` within a small factor of `x`. More iterations could
// get y in a tighter range. Currently, we will have y in `[256, 256*(2**16))`.
// We ensured `y >= 256` so that the relative difference between `y` and `y+1` is small.
// That's not possible if `x < 256` but we can just verify those cases exhaustively.
// Now, `z*z*y <= x < z*z*(y+1)`, and `y <= 2**(16+8)`, and either `y >= 256`, or `x < 256`.
// Correctness can be checked exhaustively for `x < 256`, so we assume `y >= 256`.
// Then `z*sqrt(y)` is within `sqrt(257)/sqrt(256)` of `sqrt(x)`, or about 20bps.
// For `s` in the range `[1/256, 256]`, the estimate `f(s) = (181/1024) * (s+1)`
// is in the range `(1/2.84 * sqrt(s), 2.84 * sqrt(s))`,
// with largest error when `s = 1` and when `s = 256` or `1/256`.
// Since `y` is in `[256, 256*(2**16))`, let `a = y/65536`, so that `a` is in `[1/256, 256)`.
// Then we can estimate `sqrt(y)` using
// `sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2**18`.
// There is no overflow risk here since `y < 2**136` after the first branch above.
z := shr(18, mul(z, add(shr(r, x), 65536))) // A `mul()` is saved from starting `z` at 181.
// Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
// If `x+1` is a perfect square, the Babylonian method cycles between
// `floor(sqrt(x))` and `ceil(sqrt(x))`. This statement ensures we return floor.
// See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division
// Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.
// If you don't care whether the floor or ceil square root is returned, you can remove this statement.
z := sub(z, lt(div(x, z), z))
}
}
| function sqrt(uint256 x) internal pure returns (uint256 z) {
/// @solidity memory-safe-assembly
assembly {
// `floor(sqrt(2**15)) = 181`. `sqrt(2**15) - 181 = 2.84`.
z := 181 // The "correct" value is 1, but this saves a multiplication later.
// This segment is to get a reasonable initial estimate for the Babylonian method. With a bad
// start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.
// Let `y = x / 2**r`.
// We check `y >= 2**(k + 8)` but shift right by `k` bits
// each branch to ensure that if `x >= 256`, then `y >= 256`.
let r := shl(7, lt(0xffffffffffffffffffffffffffffffffff, x))
r := or(r, shl(6, lt(0xffffffffffffffffff, shr(r, x))))
r := or(r, shl(5, lt(0xffffffffff, shr(r, x))))
r := or(r, shl(4, lt(0xffffff, shr(r, x))))
z := shl(shr(1, r), z)
// Goal was to get `z*z*y` within a small factor of `x`. More iterations could
// get y in a tighter range. Currently, we will have y in `[256, 256*(2**16))`.
// We ensured `y >= 256` so that the relative difference between `y` and `y+1` is small.
// That's not possible if `x < 256` but we can just verify those cases exhaustively.
// Now, `z*z*y <= x < z*z*(y+1)`, and `y <= 2**(16+8)`, and either `y >= 256`, or `x < 256`.
// Correctness can be checked exhaustively for `x < 256`, so we assume `y >= 256`.
// Then `z*sqrt(y)` is within `sqrt(257)/sqrt(256)` of `sqrt(x)`, or about 20bps.
// For `s` in the range `[1/256, 256]`, the estimate `f(s) = (181/1024) * (s+1)`
// is in the range `(1/2.84 * sqrt(s), 2.84 * sqrt(s))`,
// with largest error when `s = 1` and when `s = 256` or `1/256`.
// Since `y` is in `[256, 256*(2**16))`, let `a = y/65536`, so that `a` is in `[1/256, 256)`.
// Then we can estimate `sqrt(y)` using
// `sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2**18`.
// There is no overflow risk here since `y < 2**136` after the first branch above.
z := shr(18, mul(z, add(shr(r, x), 65536))) // A `mul()` is saved from starting `z` at 181.
// Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
z := shr(1, add(z, div(x, z)))
// If `x+1` is a perfect square, the Babylonian method cycles between
// `floor(sqrt(x))` and `ceil(sqrt(x))`. This statement ensures we return floor.
// See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division
// Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.
// If you don't care whether the floor or ceil square root is returned, you can remove this statement.
z := sub(z, lt(div(x, z), z))
}
}
| 27,430 |
22 | // 8. Contract has method tokenWithdrawParticipant can withdraw reservation payment in tokens deposited with tokenDeposit function (7.).This method can be executed at anytime. / | function tokenWithdraw(address tokenWallet) public {
/* Contract checks whether balance of the sender in `tokenDeposits` mapping is a non-zero value */
require(tokenDeposits[tokenWallet][msg.sender] > 0);
uint256 balance = tokenDeposits[tokenWallet][msg.sender];
/* Contract sets sender token balance in `tokenDeposits` to zero */
tokenDeposits[tokenWallet][msg.sender] = 0;
tokenRaised[tokenWallet] = tokenRaised[tokenWallet].sub(balance);
/* Contract transfers tokens to the sender from contract balance */
ERC20Interface ERC20Token = ERC20Interface(tokenWallet);
require(ERC20Token.transfer(msg.sender, balance));
TokenWithdrawal(tokenWallet, msg.sender);
}
| function tokenWithdraw(address tokenWallet) public {
/* Contract checks whether balance of the sender in `tokenDeposits` mapping is a non-zero value */
require(tokenDeposits[tokenWallet][msg.sender] > 0);
uint256 balance = tokenDeposits[tokenWallet][msg.sender];
/* Contract sets sender token balance in `tokenDeposits` to zero */
tokenDeposits[tokenWallet][msg.sender] = 0;
tokenRaised[tokenWallet] = tokenRaised[tokenWallet].sub(balance);
/* Contract transfers tokens to the sender from contract balance */
ERC20Interface ERC20Token = ERC20Interface(tokenWallet);
require(ERC20Token.transfer(msg.sender, balance));
TokenWithdrawal(tokenWallet, msg.sender);
}
| 51,054 |
24 | // Verify market's block number equals current block number // EFFECTS & INTERACTIONS (No safe failures beyond this point) | address minter = msg.sender;
vars.actualMintAmount = doTransferIn(minter, amount);
| address minter = msg.sender;
vars.actualMintAmount = doTransferIn(minter, amount);
| 43,834 |
142 | // require that bits(16..128) are all zero for every match | require((_values[i] & mask128) >> 16 == uint256(0), "Invalid match data");
uint256 takeAmount = _values[i] >> 128;
require(takeAmount > 0, "Invalid match.takeAmount");
uint256 offerDataB = _values[2 + offerIndex * 2];
| require((_values[i] & mask128) >> 16 == uint256(0), "Invalid match data");
uint256 takeAmount = _values[i] >> 128;
require(takeAmount > 0, "Invalid match.takeAmount");
uint256 offerDataB = _values[2 + offerIndex * 2];
| 18,377 |
42 | // Because of https:github.com/ethereum/EIPs/blob/master/EIPS/eip-20.mdtransfer-1 | emit Transfer(address(0), owner, amount);
| emit Transfer(address(0), owner, amount);
| 11,424 |
244 | // Proceeds from LQTY are not subject to minExpectedSwapPercentage so they could get sandwiched if we end up in an uncle block | router.exactInput(
ISwapRouter.ExactInputParams(
path,
address(this),
now,
LQTY.balanceOf(address(this)),
0
)
);
| router.exactInput(
ISwapRouter.ExactInputParams(
path,
address(this),
now,
LQTY.balanceOf(address(this)),
0
)
);
| 48,479 |
23 | // Update stakingWallet address by the owner. | function setStakingWalletAddress(address _stakingWallet) public onlyOwner {
stakingWallet = _stakingWallet;
emit SetStakingWallet(msg.sender, _stakingWallet);
}
| function setStakingWalletAddress(address _stakingWallet) public onlyOwner {
stakingWallet = _stakingWallet;
emit SetStakingWallet(msg.sender, _stakingWallet);
}
| 41,256 |
82 | // There is a vulnerability SWC-106 which implicitly caused by delegation to self-destruct call which will results inanyone could destruct the real-contract. / | contract StarNFTProxy is TransparentUpgradeableProxy {
constructor(address _implement, address _owner, bytes memory _data) TransparentUpgradeableProxy(_implement, _owner, _data) {}
function proxyImplementation() external view returns (address) {
return _implementation();
}
function proxyAdmin() external view returns (address) {
return _admin();
}
}
| contract StarNFTProxy is TransparentUpgradeableProxy {
constructor(address _implement, address _owner, bytes memory _data) TransparentUpgradeableProxy(_implement, _owner, _data) {}
function proxyImplementation() external view returns (address) {
return _implementation();
}
function proxyAdmin() external view returns (address) {
return _admin();
}
}
| 59,241 |
12 | // Get your money back before the raffle occurs | function getRefund() public {
uint refund = 0;
for (uint i = 0; i < totalTickets; i++) {
if (msg.sender == contestants[i].addr && raffleId == contestants[i].raffleId) {
refund += pricePerTicket;
contestants[i] = Contestant(address(0), 0);
gaps.push(i);
TicketRefund(raffleId, msg.sender, i);
}
}
if (refund > 0) {
msg.sender.transfer(refund);
}
}
| function getRefund() public {
uint refund = 0;
for (uint i = 0; i < totalTickets; i++) {
if (msg.sender == contestants[i].addr && raffleId == contestants[i].raffleId) {
refund += pricePerTicket;
contestants[i] = Contestant(address(0), 0);
gaps.push(i);
TicketRefund(raffleId, msg.sender, i);
}
}
if (refund > 0) {
msg.sender.transfer(refund);
}
}
| 49,393 |
252 | // Allows platform to change the percentage that artists receive on secondary sales | function updateArtistSecondSalePercentage(
uint256 _artistSecondSalePercentage
| function updateArtistSecondSalePercentage(
uint256 _artistSecondSalePercentage
| 15,287 |
85 | // Number of token user purchased | mapping(address => uint256) public userPurchased;
| mapping(address => uint256) public userPurchased;
| 25,649 |
43 | // called by the owner on emergency, triggers stopped state | function halt() external onlyOwner {
halted = true;
}
| function halt() external onlyOwner {
halted = true;
}
| 4,461 |
10 | // ============================================================= Pricing ============================================================= | function _setMembershipPrice(uint256 newPrice) public {
if (newPrice < 0) revert Membership__InvalidPrice();
MembershipStorage.Layout storage ds = MembershipStorage.layout();
// verify currency is set as well
if (ds.membershipCurrency == address(0))
revert Membership__InvalidCurrency();
uint256 protocolFee = IPlatformRequirements(ds.townFactory)
.getMembershipFee();
if (newPrice < protocolFee) revert Membership__PriceTooLow();
ds.membershipPrice = newPrice;
}
| function _setMembershipPrice(uint256 newPrice) public {
if (newPrice < 0) revert Membership__InvalidPrice();
MembershipStorage.Layout storage ds = MembershipStorage.layout();
// verify currency is set as well
if (ds.membershipCurrency == address(0))
revert Membership__InvalidCurrency();
uint256 protocolFee = IPlatformRequirements(ds.townFactory)
.getMembershipFee();
if (newPrice < protocolFee) revert Membership__PriceTooLow();
ds.membershipPrice = newPrice;
}
| 11,010 |
9 | // amount Check whether number of tokens are still available/Check whether tokens are still available | modifier ensureAvailabilityFor(uint256 amount) {
require(availableTokenCount() >= amount, "Requested number of tokens not available");
_;
}
| modifier ensureAvailabilityFor(uint256 amount) {
require(availableTokenCount() >= amount, "Requested number of tokens not available");
_;
}
| 3,148 |
295 | // == Public Functions ==/Updates the global exchange settings./This function can only be called by the owner of this contract.//Warning: these new values will be used by existing and/new Loopring exchanges. | function updateSettings(
address payable _protocolFeeVault, // address(0) not allowed
address _blockVerifierAddress, // address(0) not allowed
uint _forcedWithdrawalFee
)
external
virtual;
| function updateSettings(
address payable _protocolFeeVault, // address(0) not allowed
address _blockVerifierAddress, // address(0) not allowed
uint _forcedWithdrawalFee
)
external
virtual;
| 29,126 |
44 | // This generates a public event on the blockchain that will notify clients / | function checkMaxAllowed(address target) public constant returns (uint) {
var maxAmount = balances[target];
if(target == bbFounderCoreStaffWallet){
maxAmount = 10000000 * 1e18;
}
if(target == bbAdvisorWallet){
maxAmount = 10000000 * 1e18;
}
if(target == bbAirdropWallet){
maxAmount = 40000000 * 1e18;
}
if(target == bbNetworkGrowthWallet){
maxAmount = 20000000 * 1e18;
}
if(target == bbReserveWallet){
maxAmount = 6350000 * 1e18;
}
return maxAmount;
}
| function checkMaxAllowed(address target) public constant returns (uint) {
var maxAmount = balances[target];
if(target == bbFounderCoreStaffWallet){
maxAmount = 10000000 * 1e18;
}
if(target == bbAdvisorWallet){
maxAmount = 10000000 * 1e18;
}
if(target == bbAirdropWallet){
maxAmount = 40000000 * 1e18;
}
if(target == bbNetworkGrowthWallet){
maxAmount = 20000000 * 1e18;
}
if(target == bbReserveWallet){
maxAmount = 6350000 * 1e18;
}
return maxAmount;
}
| 25,077 |
35 | // Commit ETH to buy tokens on sale | function commitEth (address payable _from) public payable lock {
//require(address(paymentCurrency) == ETH_ADDRESS);
require(block.timestamp >= startDate && block.timestamp <= endDate);
uint256 tokensToPurchase = msg.value.mul(TENPOW18).div(priceFunction());
// Get ETH able to be committed
uint256 tokensPurchased = calculatePurchasable(tokensToPurchase);
tokenSold = tokenSold.add(tokensPurchased);
// Accept ETH Payments
uint256 ethToTransfer = tokensPurchased < tokensToPurchase ? msg.value.mul(tokensPurchased).div(tokensToPurchase) : msg.value;
uint256 ethToRefund = msg.value.sub(ethToTransfer);
if (ethToTransfer > 0) {
addCommitment(_from, ethToTransfer);
}
// Return any ETH to be refunded
if (ethToRefund > 0) {
_from.transfer(ethToRefund);
}
}
| function commitEth (address payable _from) public payable lock {
//require(address(paymentCurrency) == ETH_ADDRESS);
require(block.timestamp >= startDate && block.timestamp <= endDate);
uint256 tokensToPurchase = msg.value.mul(TENPOW18).div(priceFunction());
// Get ETH able to be committed
uint256 tokensPurchased = calculatePurchasable(tokensToPurchase);
tokenSold = tokenSold.add(tokensPurchased);
// Accept ETH Payments
uint256 ethToTransfer = tokensPurchased < tokensToPurchase ? msg.value.mul(tokensPurchased).div(tokensToPurchase) : msg.value;
uint256 ethToRefund = msg.value.sub(ethToTransfer);
if (ethToTransfer > 0) {
addCommitment(_from, ethToTransfer);
}
// Return any ETH to be refunded
if (ethToRefund > 0) {
_from.transfer(ethToRefund);
}
}
| 13,539 |
7 | // Add a consumer to a VRF subscription. subId - ID of the subscription consumer - New consumer which can use the subscription / | function addConsumer(uint64 subId, address consumer) external;
| function addConsumer(uint64 subId, address consumer) external;
| 10,850 |
113 | // Returns the value stored at position `index` in the set. O(1). Note that there are no guarantees on the ordering of values inside thearray, and it may change when more values are added or removed. Requirements: | * - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
| * - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
return set._values[index];
}
| 1,942 |
34 | // Distrbutes rewards between receivers according to their basis points | function distribute() public onlyEOA() {
uint256 balance = IERC20(rewardsToken).balanceOf(address(this));
if (balance < minRewardsToDistribute) return;
if (receivers.length == 0) return;
for (uint256 i = 0; i < receivers.length; i++) {
address receiver = receivers[i];
uint256 points = basisPoints[i];
if (points == 0 || receiver == address(0)) continue;
uint256 amountForRecipient = balance * points / totalBasisPoints;
IERC20(rewardsToken).safeTransfer(receiver, amountForRecipient);
}
emit Distribute(msg.sender, balance);
}
| function distribute() public onlyEOA() {
uint256 balance = IERC20(rewardsToken).balanceOf(address(this));
if (balance < minRewardsToDistribute) return;
if (receivers.length == 0) return;
for (uint256 i = 0; i < receivers.length; i++) {
address receiver = receivers[i];
uint256 points = basisPoints[i];
if (points == 0 || receiver == address(0)) continue;
uint256 amountForRecipient = balance * points / totalBasisPoints;
IERC20(rewardsToken).safeTransfer(receiver, amountForRecipient);
}
emit Distribute(msg.sender, balance);
}
| 34,102 |
103 | // Emitted when liquidity is decreased for a position NFT/tokenId The ID of the token for which liquidity was decreased/liquidity The amount by which liquidity for the NFT position was decreased/amount0 The amount of token0 that was accounted for the decrease in liquidity/amount1 The amount of token1 that was accounted for the decrease in liquidity | event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
| event DecreaseLiquidity(uint256 indexed tokenId, uint128 liquidity, uint256 amount0, uint256 amount1);
| 24,349 |
352 | // The creator of the contract is the initial CEO | ceoAddress = msg.sender;
| ceoAddress = msg.sender;
| 17,456 |
2 | // function decodeAndVerifyEvent(uint256, bytes32 , bytes calldata, bytes calldata) | // external view override {
//
// }
| // external view override {
//
// }
| 22,335 |
4 | // to support backward compatible contract name -- so function signature remains same | abstract contract ERC20 is IERC20 {
}
| abstract contract ERC20 is IERC20 {
}
| 30,304 |
19 | // Ensure sender. | require(_to == _msgSender(), "Can only mint for self");
| require(_to == _msgSender(), "Can only mint for self");
| 40,754 |
124 | // Call dest contract | uint256 success;
bytes32 result;
| uint256 success;
bytes32 result;
| 18,303 |
156 | // This function is an owner only function, it can change placeholder baseURI. / | function setPlaceholderBaseURI(string memory uri) public onlyOwner {
_placeholderBaseURI_ = uri;
}
| function setPlaceholderBaseURI(string memory uri) public onlyOwner {
_placeholderBaseURI_ = uri;
}
| 38,264 |
22 | // Decrease the amount of tokens that an owner allowed to a spender.approve should be called when _allowed[msg.sender][spender] == 0. To decrementallowed value is better to use this function to avoid 2 calls (and wait untilthe first transaction is mined)From MonolithDAO Token.solEmits an Approval event. spender The address which will spend the funds. subtractedValue The amount of tokens to decrease the allowance by. / | function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
_approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue));
return true;
}
| function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
_approve(msg.sender, spender, _allowed[msg.sender][spender].sub(subtractedValue));
return true;
}
| 37,192 |
27 | // Revert and pass along revert message if call to upgrade beacon reverts. | require(_ok, string(_returnData));
| require(_ok, string(_returnData));
| 206 |
32 | // Set the token seeder. Only callable by the owner when not locked. / | function setSeeder(INounsSeeder _seeder) external override onlyOwner whenSeederNotLocked {
seeder = _seeder;
emit SeederUpdated(_seeder);
}
| function setSeeder(INounsSeeder _seeder) external override onlyOwner whenSeederNotLocked {
seeder = _seeder;
emit SeederUpdated(_seeder);
}
| 30,432 |
10 | // Provide liquidity to Vault. amount The amount of liquidity to be deposited. / | function provideLiquidity(uint256 amount) external onlyNotPaused nonReentrant {
require(amount > 0, 'CANNOT_STAKE_ZERO_TOKENS');
require(amount + totalAmountDeposited <= maxCapacity, 'AMOUNT_IS_BIGGER_THAN_CAPACITY');
uint256 receivedETokens = getNrOfETokensToMint(amount);
totalAmountDeposited = amount + totalAmountDeposited;
_mint(msg.sender, receivedETokens);
require(
stakedToken.transferFrom(msg.sender, address(this), amount),
'TRANSFER_STAKED_FAIL'
);
emit Deposit(msg.sender, amount, receivedETokens, lastDepositBlockNr[msg.sender]);
lastDepositBlockNr[msg.sender] = block.number;
}
| function provideLiquidity(uint256 amount) external onlyNotPaused nonReentrant {
require(amount > 0, 'CANNOT_STAKE_ZERO_TOKENS');
require(amount + totalAmountDeposited <= maxCapacity, 'AMOUNT_IS_BIGGER_THAN_CAPACITY');
uint256 receivedETokens = getNrOfETokensToMint(amount);
totalAmountDeposited = amount + totalAmountDeposited;
_mint(msg.sender, receivedETokens);
require(
stakedToken.transferFrom(msg.sender, address(this), amount),
'TRANSFER_STAKED_FAIL'
);
emit Deposit(msg.sender, amount, receivedETokens, lastDepositBlockNr[msg.sender]);
lastDepositBlockNr[msg.sender] = block.number;
}
| 8,776 |
148 | // project's owner withdraws ETH funds to the funding address upon successful crowdsale | function withdraw(
uint256 _amount // can be done partially
)
public
onlyOwner() // project's owner
hasntStopped() // crowdsale wasn't cancelled
whenCrowdsaleSuccessful() // crowdsale completed successfully
| function withdraw(
uint256 _amount // can be done partially
)
public
onlyOwner() // project's owner
hasntStopped() // crowdsale wasn't cancelled
whenCrowdsaleSuccessful() // crowdsale completed successfully
| 32,033 |
99 | // =========================================== Internal Functions =========================================== | function _getHashKey(address _contract, uint _tokenId) internal pure returns(bytes32 key) {
key = keccak256(abi.encodePacked(_contract, _tokenId));
}
| function _getHashKey(address _contract, uint _tokenId) internal pure returns(bytes32 key) {
key = keccak256(abi.encodePacked(_contract, _tokenId));
}
| 14,297 |
94 | // See {IERC721-ownerOf}./ | function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
| function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
| 58,344 |
85 | // Send the assets to the Strategy and call skim to invest them | function skim(uint256 amount) external;
| function skim(uint256 amount) external;
| 7,296 |
85 | // Used for authentication | address public monetaryPolicy;
| address public monetaryPolicy;
| 8,270 |
51 | // During Migration | function pauseDuringMigration() public onlyPauser {
pauseTransfer();
pauseBurn();
unpauseMigrate();
}
| function pauseDuringMigration() public onlyPauser {
pauseTransfer();
pauseBurn();
unpauseMigrate();
}
| 13,330 |
26 | // transfer the tokens from caller to staking contract | vanilla.transferFrom(msg.sender, address(this), _amount);
| vanilla.transferFrom(msg.sender, address(this), _amount);
| 24,355 |
69 | // Iterate over remaining offer components. prettier-ignore | for {} lt(fulfillmentHeadPtr, endPtr) {} {
| for {} lt(fulfillmentHeadPtr, endPtr) {} {
| 14,340 |
2 | // Staked tokens are not up for grabs | require(
balanceOf(address(this)) - totalStaked >= _amount,
NO_TOKEN_TO_RECLAIM
);
| require(
balanceOf(address(this)) - totalStaked >= _amount,
NO_TOKEN_TO_RECLAIM
);
| 45,316 |
41 | // ------------------------------------------------------------------------ 2y locked balances for an account ------------------------------------------------------------------------ | function balanceOfLocked2Y(address account) constant returns (uint balance) {
return balancesLocked2Y[account];
}
| function balanceOfLocked2Y(address account) constant returns (uint balance) {
return balancesLocked2Y[account];
}
| 8,327 |
2 | // scale rate proportionally up to 100% | uint256 thisMaxRange = WEI_PERCENT_PRECISION - thisKinkLevel; // will not overflow
utilRate -= thisKinkLevel;
if (utilRate > thisMaxRange)
utilRate = thisMaxRange;
thisMaxRate = thisRateMultiplier
.add(thisBaseRate)
.mul(thisKinkLevel)
.div(WEI_PERCENT_PRECISION);
| uint256 thisMaxRange = WEI_PERCENT_PRECISION - thisKinkLevel; // will not overflow
utilRate -= thisKinkLevel;
if (utilRate > thisMaxRange)
utilRate = thisMaxRange;
thisMaxRate = thisRateMultiplier
.add(thisBaseRate)
.mul(thisKinkLevel)
.div(WEI_PERCENT_PRECISION);
| 8,457 |
22 | // Recovers address who signed the message/messageHash operation ethereum signed message hash/messageSignature message `txHash` signature/pos which signature to read | function recoverKey (
bytes32 messageHash,
bytes memory messageSignature,
uint256 pos
)
internal
pure
returns (address)
| function recoverKey (
bytes32 messageHash,
bytes memory messageSignature,
uint256 pos
)
internal
pure
returns (address)
| 82,678 |
53 | // Converts a given date to timestamp./ | function toTimestamp(uint256 _year, uint256 _month, uint256 _day) internal pure returns (uint256 ts) {
//January and February are counted as months 13 and 14 of the previous year
if (_month <= 2) {
_month += 12;
_year -= 1;
}
// Convert years to days
ts = (365 * _year) + (_year / 4) - (_year / 100) + (_year / 400);
//Convert months to days
ts += (30 * _month) + (3 * (_month + 1) / 5) + _day;
//Unix time starts on January 1st, 1970
ts -= 719561;
//Convert days to seconds
ts *= 86400;
}
| function toTimestamp(uint256 _year, uint256 _month, uint256 _day) internal pure returns (uint256 ts) {
//January and February are counted as months 13 and 14 of the previous year
if (_month <= 2) {
_month += 12;
_year -= 1;
}
// Convert years to days
ts = (365 * _year) + (_year / 4) - (_year / 100) + (_year / 400);
//Convert months to days
ts += (30 * _month) + (3 * (_month + 1) / 5) + _day;
//Unix time starts on January 1st, 1970
ts -= 719561;
//Convert days to seconds
ts *= 86400;
}
| 11,944 |
4 | // Get MKR from the user's wallet and transfer to Migration contract | require(tub.gov().transferFrom(msg.sender, address(scdMcdMigration), govFee), "transfer-failed");
| require(tub.gov().transferFrom(msg.sender, address(scdMcdMigration), govFee), "transfer-failed");
| 33,881 |
40 | // Withdraw ETH/ERC20_Token Collateral. vault Vault ID. amt token amount to withdraw./ | function withdraw(
uint vault,
uint amt
| function withdraw(
uint vault,
uint amt
| 39,877 |
47 | // check if the bet amount is greater than the minimum amount | require(
msg.value >= minBetAmount,
"Bet amount less than minimum amount"
);
require(
getTakerBetAmount(
bets[fillerId].odds,
direction,
bets[fillerId].betAmount
) == msg.value,
| require(
msg.value >= minBetAmount,
"Bet amount less than minimum amount"
);
require(
getTakerBetAmount(
bets[fillerId].odds,
direction,
bets[fillerId].betAmount
) == msg.value,
| 23,623 |
21 | // Exposes the public data point in an ERC2362 compliant way.Returns error `400` if queried for an unknown data point, and `404` if `completeUpdate` has never been called successfully before./ | function valueFor(bytes32 _id) external view override returns(int256, uint256, uint256) {
// Unsupported data point ID
if(_id != XAUEUR3ID) return(0, 0, 400);
// No value is yet available for the queried data point ID
if (timestamp == 0) return(0, 0, 404);
int256 value = int256(uint256(lastPrice));
return(value, timestamp, 200);
}
| function valueFor(bytes32 _id) external view override returns(int256, uint256, uint256) {
// Unsupported data point ID
if(_id != XAUEUR3ID) return(0, 0, 400);
// No value is yet available for the queried data point ID
if (timestamp == 0) return(0, 0, 404);
int256 value = int256(uint256(lastPrice));
return(value, timestamp, 200);
}
| 38,700 |
605 | // Determine if a claim is pending for this service provider _sp - address of service providerreturn boolean indicating whether a claim is pending / | function _claimPending(address _sp) internal view returns (bool) {
ClaimsManager claimsManager = ClaimsManager(claimsManagerAddress);
return claimsManager.claimPending(_sp);
}
| function _claimPending(address _sp) internal view returns (bool) {
ClaimsManager claimsManager = ClaimsManager(claimsManagerAddress);
return claimsManager.claimPending(_sp);
}
| 38,626 |
22 | // Decrease offer creator Stake reserved | profileStorage.setStakeReserved(litigatorIdentity, profileStorage.getStakeReserved(litigatorIdentity).sub(amountToTransfer));
| profileStorage.setStakeReserved(litigatorIdentity, profileStorage.getStakeReserved(litigatorIdentity).sub(amountToTransfer));
| 23,578 |
36 | // Collateral token intra-issuance transfer: Custodian --> Maker | transfers.actions[0] = _createIntraIssuanceTransfer(
Constants.getCustodianAddress(),
_makerAddress,
_collateralTokenAddress,
_collateralAmount,
"Custodian out"
);
| transfers.actions[0] = _createIntraIssuanceTransfer(
Constants.getCustodianAddress(),
_makerAddress,
_collateralTokenAddress,
_collateralAmount,
"Custodian out"
);
| 20,124 |
405 | // res += val(coefficients[158] + coefficients[159]adjustments[11]). | res := addmod(res,
mulmod(val,
add(/*coefficients[158]*/ mload(0x1800),
mulmod(/*coefficients[159]*/ mload(0x1820),
| res := addmod(res,
mulmod(val,
add(/*coefficients[158]*/ mload(0x1800),
mulmod(/*coefficients[159]*/ mload(0x1820),
| 31,488 |
78 | // uint256 initialTokenLiquidity = bitBaseInitialLiq; uint256 initialTokenLiquiditySplit = initialTokenLiquidity.div(2); |
uint256 bitbaseDevETHFee = totalETHContributed.div(100).mul(4);
uint256 deflctDevETHFee = totalETHContributed.div(100).mul(6);
uint256 ETHRemaining = address(this).balance.sub(bitbaseDevETHFee).sub(deflctDevETHFee);
|
uint256 bitbaseDevETHFee = totalETHContributed.div(100).mul(4);
uint256 deflctDevETHFee = totalETHContributed.div(100).mul(6);
uint256 ETHRemaining = address(this).balance.sub(bitbaseDevETHFee).sub(deflctDevETHFee);
| 37,673 |
194 | // Ajoute une personne aux giveaaysarray of address wallet - Adresse du wallet | function setGiveaway(address[] memory wallets) public onlyOwner
| function setGiveaway(address[] memory wallets) public onlyOwner
| 24,800 |
143 | // for redelegate we must split amount into stake-able and dust | amountToStake = (claimableRewards / BALANCE_COMPACT_PRECISION) * BALANCE_COMPACT_PRECISION;
| amountToStake = (claimableRewards / BALANCE_COMPACT_PRECISION) * BALANCE_COMPACT_PRECISION;
| 5,466 |
18 | // Returns to normal state. / | function unpause() public whenPaused onlyOwner {
paused = false;
emit Unpaused(msg.sender);
}
| function unpause() public whenPaused onlyOwner {
paused = false;
emit Unpaused(msg.sender);
}
| 32,831 |
8 | // No.of tokens to send when requested | uint256 faucetDripAmount = 1;
| uint256 faucetDripAmount = 1;
| 19,360 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.