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 |
|---|---|---|---|---|
65 | // Transfers the same amount of tokens to up to 200 specified addresses. If the sender runs out of balance then the entire transaction fails._to The addresses to transfer to._value The amount to be transferred to each address./ | function airdrop(address[] memory _to, uint256 _value) public whenNotLocked(msg.sender)
| function airdrop(address[] memory _to, uint256 _value) public whenNotLocked(msg.sender)
| 20,153 |
9 | // called from service | function createSubscriptionPlan(
uint32 serviceNonce,
uint32 subscriptionPlanNonce,
address owner,
address service,
SubscriptionPlanData data,
mapping(address /*root*/ => uint128 /*price*/) prices
| function createSubscriptionPlan(
uint32 serviceNonce,
uint32 subscriptionPlanNonce,
address owner,
address service,
SubscriptionPlanData data,
mapping(address /*root*/ => uint128 /*price*/) prices
| 52,858 |
222 | // Obtain the quantity which the next schedule entry will vest for a given user. / | function getNextVestingQuantity(address account) external view returns (uint) {
return getNextVestingEntry(account)[QUANTITY_INDEX];
}
| function getNextVestingQuantity(address account) external view returns (uint) {
return getNextVestingEntry(account)[QUANTITY_INDEX];
}
| 37,373 |
407 | // Auto-generated via 'PrintLn2ScalingFactors.py' | uint256 private constant LN2_NUMERATOR = 0x3f80fe03f80fe03f80fe03f80fe03f8;
uint256 private constant LN2_DENOMINATOR = 0x5b9de1d10bf4103d647b0955897ba80;
| uint256 private constant LN2_NUMERATOR = 0x3f80fe03f80fe03f80fe03f80fe03f8;
uint256 private constant LN2_DENOMINATOR = 0x5b9de1d10bf4103d647b0955897ba80;
| 33,206 |
7 | // Returns a list of prices from a list of assets addresses assets The list of assets addressesreturn The prices of the given assets / | function getAssetsPrices(address[] calldata assets) external view returns (uint256[] memory);
| function getAssetsPrices(address[] calldata assets) external view returns (uint256[] memory);
| 17,007 |
109 | // case 3: Error(string), selector 0x08c379a0 (Defined at least since 0.7.0) based on https:ethereum.stackexchange.com/a/83577 | assembly {
returnedData_ := add(returnedData_, 0x04)
}
| assembly {
returnedData_ := add(returnedData_, 0x04)
}
| 5,236 |
1 | // / solhint-disable-next-line func-name-mixedcase | function __initialize__(
address owner,
string calldata name,
string calldata symbol,
GoldfinchConfig _config
| function __initialize__(
address owner,
string calldata name,
string calldata symbol,
GoldfinchConfig _config
| 31,953 |
26 | // Read list from the lastUpdatedIndex back the passed amount of data points. _selfLinkedList to operate on_dataPointsNumber of data points to return / | function readList(
LinkedList storage _self,
uint256 _dataPoints
)
internal
view
returns (uint256[] memory)
| function readList(
LinkedList storage _self,
uint256 _dataPoints
)
internal
view
returns (uint256[] memory)
| 17,965 |
62 | // The start timestamp of token release period. Before this time, the beneficiary can NOT withdraw any token from this contract. | uint256 private immutable _releaseStartTime;
| uint256 private immutable _releaseStartTime;
| 55,997 |
49 | // Ignore isDynamic[] and actualPrices[], and all users are charged bandwidthPrice Proportionally allocate the bandwidth according to desired bandwidth | for(uint i = 0; i < numUsers; i++) {
if(isActive[i]) {
actualPrices[i] = bandwidthPrice;
allocatedBandwidth[i] = users[i + 1].desiredBandwidth * totalBandwidth * bandwidthScalingFactor / totalDesiredBandwidth;
users[i + 1].receivedBandwidth = allocatedBandwidth[i];
}
| for(uint i = 0; i < numUsers; i++) {
if(isActive[i]) {
actualPrices[i] = bandwidthPrice;
allocatedBandwidth[i] = users[i + 1].desiredBandwidth * totalBandwidth * bandwidthScalingFactor / totalDesiredBandwidth;
users[i + 1].receivedBandwidth = allocatedBandwidth[i];
}
| 48,040 |
22 | // wtg10 - can be called only from this contract as one "external" call (to revert all this function state changes if it is needed) |
uint16 lpTokenId = tokenIds[address(_token)];
uint256 balance_before = _token.balanceOf(address(this));
if (lpTokenId > 0) {
validatePairTokenAddress(address(_token));
pairmanager.mint(address(_token), _to, _amount);
} else {
|
uint16 lpTokenId = tokenIds[address(_token)];
uint256 balance_before = _token.balanceOf(address(this));
if (lpTokenId > 0) {
validatePairTokenAddress(address(_token));
pairmanager.mint(address(_token), _to, _amount);
} else {
| 39,130 |
78 | // Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. _Available since v4.2._/ | function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
| function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
| 11,028 |
11 | // Initializes default variables | firstSegmentStart = block.timestamp; //gets current time
lastSegment = _segmentCount;
segmentLength = _segmentLength;
segmentPayment = _segmentPayment;
earlyWithdrawalFee = _earlyWithdrawalFee;
customFee = _customFee;
daiToken = _inboundCurrency;
lendingPoolAddressProvider = _lendingPoolAddressProvider;
AaveProtocolDataProvider dataProvider = AaveProtocolDataProvider(
_dataProvider
| firstSegmentStart = block.timestamp; //gets current time
lastSegment = _segmentCount;
segmentLength = _segmentLength;
segmentPayment = _segmentPayment;
earlyWithdrawalFee = _earlyWithdrawalFee;
customFee = _customFee;
daiToken = _inboundCurrency;
lendingPoolAddressProvider = _lendingPoolAddressProvider;
AaveProtocolDataProvider dataProvider = AaveProtocolDataProvider(
_dataProvider
| 17,623 |
279 | // Computes the current state of a price request. See the State enum for more details. requester sender of the initial price request. identifier price identifier to identify the existing request. timestamp timestamp to identify the existing request. ancillaryData ancillary data of the price being requested. request price request parameters.return the State. / | function getState(
| function getState(
| 12,889 |
49 | // --------increment counter and start new epoch | reward_epoch = reward_epoch + 1; // next epoch
last_epoch_date = block.timestamp; // epoch start date
| reward_epoch = reward_epoch + 1; // next epoch
last_epoch_date = block.timestamp; // epoch start date
| 5,878 |
55 | // Called by a owner to pause, triggers stopped state. / | function pause() public onlyOwner whenNotPaused {
_paused = true;
emit Paused(msg.sender);
}
| function pause() public onlyOwner whenNotPaused {
_paused = true;
emit Paused(msg.sender);
}
| 50,449 |
2 | // The raising token | IERC20 public lpToken;
| IERC20 public lpToken;
| 25,424 |
27 | // Returns calculation of gons for amount of/amountAmount of to calculate gons for | function gonsForBalance(uint256 amount) public view override returns (uint256) {
return amount * _gonsPerFragment;
}
| function gonsForBalance(uint256 amount) public view override returns (uint256) {
return amount * _gonsPerFragment;
}
| 26,994 |
20 | // Devuelve el dinero al maximo postor | highestBidder.transfer(highestPrice);
| highestBidder.transfer(highestPrice);
| 13,576 |
13 | // Eterland presale This contract will handle first eterland presale/ | contract EterlandPresale is Presale {
/**
* @dev Represent the keys for items in the presale
*/
uint8 internal constant COMMON_KIT = 0;
uint8 internal constant RARE_KIT = 2;
uint8 internal constant UNCOMMON_KIT = 4;
uint8 internal constant UNKNOWN_DEPOSIT = 6;
uint8 internal constant LOST_MAP = 8;
uint8 internal constant GOLDEN_MAP_CHEST = 10;
uint8 internal constant WOOD_MAP_CHEST = 12;
uint8 internal constant GOLDEN_DEPOSIT_CHEST = 14;
uint8 internal constant DEPOSIT_WOOD_CHEST = 16;
struct Kit {
uint256 price;
uint256 supply;
}
/**
* @dev Stores item price and supply
*/
mapping(uint256 => Kit) public Kits;
/**
* @dev Stores owner for the items
*/
mapping(uint8 => mapping(address => uint8)) public Ownerkits;
/**
* @dev Represent max items of same type for every address
*/
uint256 public constant MAX_ITEMS_BY_USER = 5;
/**
* @dev Event fired when a item is sold
*/
event BuyKit(address kitOwner, uint8 kitId, uint8 _amount);
/**
* @dev Set team members, kit prices,supply and presale date
*/
constructor(uint256 presaleStart , uint256 presaleEnd, address ceo, address coo,address cfo,address inv1,address inv2)
Presale(presaleStart,presaleEnd,ceo,coo,cfo,inv1,inv2) {
/** only test purposes,in the mainet prices and supply may be different**/
Kits[COMMON_KIT] = Kit(100000000000000000, 30);
Kits[UNCOMMON_KIT] = Kit(165000000000000000, 30);
Kits[RARE_KIT] = Kit(250000000000000000, 30);
Kits[UNKNOWN_DEPOSIT] = Kit(2180000000000000000, 30);
Kits[LOST_MAP] = Kit(100000000000000000, 30);
Kits[GOLDEN_MAP_CHEST] = Kit(100000000000000000, 30);
Kits[GOLDEN_DEPOSIT_CHEST] = Kit(100000000000000000, 30);
Kits[WOOD_MAP_CHEST] = Kit(100000000000000000, 30);
Kits[DEPOSIT_WOOD_CHEST] = Kit(100000000000000000, 30);
}
/**
* @dev use this function to buy item from the presale
*/
function buyItem(uint8 kitId, uint8 _amount) public presaleInProgress payable {
require(Kits[kitId].supply > _amount, "the _amount must not be greater than the supply");
uint256 value = msg.value;
uint256 kitPrice = Kits[kitId].price;
require(value >= kitPrice * _amount, "no enought money sended");
uint256 itemsWithUser = Ownerkits[kitId][msg.sender];
uint256 remainingItems = MAX_ITEMS_BY_USER - itemsWithUser;
require(_amount <= remainingItems ,"not enought remaining items");
value -= kitPrice * _amount;
if (value > 0) {
payable(msg.sender).transfer(value);
}
Kits[kitId].supply -= _amount;
Ownerkits[kitId][msg.sender] += _amount;
emit BuyKit(msg.sender, kitId, _amount);
}
/**
* @dev getter for kit price
*/
function getKitPrice(uint256 kitId) external view returns (uint256) {
return Kits[kitId].price;
}
/**
* @dev getter for remaining kit supply
*/
function getSupply(uint8 kitId) external view returns (uint256 c) {
c = Kits[kitId].supply;
}
/**
* @dev get count of kits that the address owns
*/
function getOwnerkit(uint8 kitId, address user)
external
view
returns (uint256)
{
return Ownerkits[kitId][user];
}
}
| contract EterlandPresale is Presale {
/**
* @dev Represent the keys for items in the presale
*/
uint8 internal constant COMMON_KIT = 0;
uint8 internal constant RARE_KIT = 2;
uint8 internal constant UNCOMMON_KIT = 4;
uint8 internal constant UNKNOWN_DEPOSIT = 6;
uint8 internal constant LOST_MAP = 8;
uint8 internal constant GOLDEN_MAP_CHEST = 10;
uint8 internal constant WOOD_MAP_CHEST = 12;
uint8 internal constant GOLDEN_DEPOSIT_CHEST = 14;
uint8 internal constant DEPOSIT_WOOD_CHEST = 16;
struct Kit {
uint256 price;
uint256 supply;
}
/**
* @dev Stores item price and supply
*/
mapping(uint256 => Kit) public Kits;
/**
* @dev Stores owner for the items
*/
mapping(uint8 => mapping(address => uint8)) public Ownerkits;
/**
* @dev Represent max items of same type for every address
*/
uint256 public constant MAX_ITEMS_BY_USER = 5;
/**
* @dev Event fired when a item is sold
*/
event BuyKit(address kitOwner, uint8 kitId, uint8 _amount);
/**
* @dev Set team members, kit prices,supply and presale date
*/
constructor(uint256 presaleStart , uint256 presaleEnd, address ceo, address coo,address cfo,address inv1,address inv2)
Presale(presaleStart,presaleEnd,ceo,coo,cfo,inv1,inv2) {
/** only test purposes,in the mainet prices and supply may be different**/
Kits[COMMON_KIT] = Kit(100000000000000000, 30);
Kits[UNCOMMON_KIT] = Kit(165000000000000000, 30);
Kits[RARE_KIT] = Kit(250000000000000000, 30);
Kits[UNKNOWN_DEPOSIT] = Kit(2180000000000000000, 30);
Kits[LOST_MAP] = Kit(100000000000000000, 30);
Kits[GOLDEN_MAP_CHEST] = Kit(100000000000000000, 30);
Kits[GOLDEN_DEPOSIT_CHEST] = Kit(100000000000000000, 30);
Kits[WOOD_MAP_CHEST] = Kit(100000000000000000, 30);
Kits[DEPOSIT_WOOD_CHEST] = Kit(100000000000000000, 30);
}
/**
* @dev use this function to buy item from the presale
*/
function buyItem(uint8 kitId, uint8 _amount) public presaleInProgress payable {
require(Kits[kitId].supply > _amount, "the _amount must not be greater than the supply");
uint256 value = msg.value;
uint256 kitPrice = Kits[kitId].price;
require(value >= kitPrice * _amount, "no enought money sended");
uint256 itemsWithUser = Ownerkits[kitId][msg.sender];
uint256 remainingItems = MAX_ITEMS_BY_USER - itemsWithUser;
require(_amount <= remainingItems ,"not enought remaining items");
value -= kitPrice * _amount;
if (value > 0) {
payable(msg.sender).transfer(value);
}
Kits[kitId].supply -= _amount;
Ownerkits[kitId][msg.sender] += _amount;
emit BuyKit(msg.sender, kitId, _amount);
}
/**
* @dev getter for kit price
*/
function getKitPrice(uint256 kitId) external view returns (uint256) {
return Kits[kitId].price;
}
/**
* @dev getter for remaining kit supply
*/
function getSupply(uint8 kitId) external view returns (uint256 c) {
c = Kits[kitId].supply;
}
/**
* @dev get count of kits that the address owns
*/
function getOwnerkit(uint8 kitId, address user)
external
view
returns (uint256)
{
return Ownerkits[kitId][user];
}
}
| 35,582 |
120 | // If we charge a fee, account for it | uint256 prevBal = this.checkBalance(_bAsset);
stakingPools.deposit(poolId, _amount);
uint256 newBal = this.checkBalance(_bAsset);
quantityDeposited = _min(quantityDeposited, newBal - prevBal);
| uint256 prevBal = this.checkBalance(_bAsset);
stakingPools.deposit(poolId, _amount);
uint256 newBal = this.checkBalance(_bAsset);
quantityDeposited = _min(quantityDeposited, newBal - prevBal);
| 15,941 |
117 | // Calculate burn amount and charity amount | uint256 burnAmt = amount.mul(_burnFee).div(100);
uint256 charityAmt = amount.mul(_charityFee).div(100);
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, (amount.sub(burnAmt).sub(charityAmt)));
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
| uint256 burnAmt = amount.mul(_burnFee).div(100);
uint256 charityAmt = amount.mul(_charityFee).div(100);
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, (amount.sub(burnAmt).sub(charityAmt)));
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
| 56,267 |
76 | // uint256 _tTotal, | uint256 currentBalance,
uint256 currentBNBPool,
uint256 totalSupply,
| uint256 currentBalance,
uint256 currentBNBPool,
uint256 totalSupply,
| 4,511 |
0 | // Given BaseMinimalSwapInfoPool supports both of these specializations, and this Pool never registers or deregisters any tokens after construction, picking Two Token when the Pool only has two tokens is free gas savings. | tokens.length == 2 ? IVault.PoolSpecialization.TWO_TOKEN : IVault.PoolSpecialization.MINIMAL_SWAP_INFO,
name,
symbol,
tokens,
assetManagers,
swapFeePercentage,
pauseWindowDuration,
bufferPeriodDuration,
owner
)
| tokens.length == 2 ? IVault.PoolSpecialization.TWO_TOKEN : IVault.PoolSpecialization.MINIMAL_SWAP_INFO,
name,
symbol,
tokens,
assetManagers,
swapFeePercentage,
pauseWindowDuration,
bufferPeriodDuration,
owner
)
| 53,526 |
92 | // |/ A distinct Uniform Resource Identifier (URI) for a given token. URIs are defined in RFC 3986. URIs are assumed to be deterministically generated based on token ID Token IDs are assumed to be represented in their hex format in URIsreturn URI string / | function uri(uint256 _id) public view returns (string memory) {
return string(abi.encodePacked(baseMetadataURI, _uint2str(_id), ".json"));
}
| function uri(uint256 _id) public view returns (string memory) {
return string(abi.encodePacked(baseMetadataURI, _uint2str(_id), ".json"));
}
| 24,702 |
21 | // approve staking for CADT if needed | _approveToken(CADT, staking, amount);
if (toToken == gCADT) {
| _approveToken(CADT, staking, amount);
if (toToken == gCADT) {
| 56,082 |
3 | // mapping of hash to tokenId | mapping(bytes32 => uint256) public hashToToken;
| mapping(bytes32 => uint256) public hashToToken;
| 24,069 |
50 | // create pair | lpPair = IDexFactory(_dexRouter.factory()).createPair(address(this), _dexRouter.WETH());
_excludeFromMaxTransaction(address(lpPair), true);
_setAutomatedMarketMakerPair(address(lpPair), true);
uint256 totalSupply = 1 * 1e9 * 1e18;
maxBuyAmount = totalSupply * 2 / 100;
maxSellAmount = totalSupply * 2 / 100;
maxWalletAmount = totalSupply * 3 / 100;
swapTokensAtAmount = totalSupply * 1 / 1000;
| lpPair = IDexFactory(_dexRouter.factory()).createPair(address(this), _dexRouter.WETH());
_excludeFromMaxTransaction(address(lpPair), true);
_setAutomatedMarketMakerPair(address(lpPair), true);
uint256 totalSupply = 1 * 1e9 * 1e18;
maxBuyAmount = totalSupply * 2 / 100;
maxSellAmount = totalSupply * 2 / 100;
maxWalletAmount = totalSupply * 3 / 100;
swapTokensAtAmount = totalSupply * 1 / 1000;
| 2,017 |
0 | // Emitted when withdawing MYC `reward` fees for `poolAddress` / | event WithdrawnMYCFees(address indexed poolAddress, uint256 reward);
error SignatureMismatch();
error TransactionOverdue();
error DatesSort();
error IncompleteArray();
error WrongExecutor();
IMYCStakingManager internal _mycStakingManager;
IWETH internal _WETH;
| event WithdrawnMYCFees(address indexed poolAddress, uint256 reward);
error SignatureMismatch();
error TransactionOverdue();
error DatesSort();
error IncompleteArray();
error WrongExecutor();
IMYCStakingManager internal _mycStakingManager;
IWETH internal _WETH;
| 27,952 |
1 | // Asset Recoverer/Recover ether, ERC20, ERC721 and ERC1155 from a derived contract | abstract contract AssetRecoverer is TokenRecoverer {
event EtherTransferred(address indexed _recipient, uint256 _amount);
/**
* @notice transfers ether from this contract
* @dev using `address.call` is safer to transfer to other contracts
* @param _recipient address to transfer ether to
* @param _amount amount of ether to transfer
*/
function _transferEther(address _recipient, uint256 _amount) internal virtual burnDisallowed(_recipient) {
(bool success, ) = _recipient.call{value: _amount}("");
if (!success) {
revert AssetRecoverer__TransferFailed(_recipient, _amount);
}
emit EtherTransferred(_recipient, _amount);
}
}
| abstract contract AssetRecoverer is TokenRecoverer {
event EtherTransferred(address indexed _recipient, uint256 _amount);
/**
* @notice transfers ether from this contract
* @dev using `address.call` is safer to transfer to other contracts
* @param _recipient address to transfer ether to
* @param _amount amount of ether to transfer
*/
function _transferEther(address _recipient, uint256 _amount) internal virtual burnDisallowed(_recipient) {
(bool success, ) = _recipient.call{value: _amount}("");
if (!success) {
revert AssetRecoverer__TransferFailed(_recipient, _amount);
}
emit EtherTransferred(_recipient, _amount);
}
}
| 38,026 |
48 | // Wallet that are tax free as default | isExcludedFromFee[owner()] = true;
isExcludedFromFee[address(this)] = true;
isExcludedFromFee[marketingWalletAddress] = true;
isExcludedFromFee[ReceiveAddress] = true;
isMarketPair[address(uniswapPair)] = true;
_balances[ReceiveAddress] = _totalSupply;
emit Transfer(address(0), ReceiveAddress, _totalSupply);
| isExcludedFromFee[owner()] = true;
isExcludedFromFee[address(this)] = true;
isExcludedFromFee[marketingWalletAddress] = true;
isExcludedFromFee[ReceiveAddress] = true;
isMarketPair[address(uniswapPair)] = true;
_balances[ReceiveAddress] = _totalSupply;
emit Transfer(address(0), ReceiveAddress, _totalSupply);
| 32,985 |
80 | // update total contribution | contributions[_beneficiary] = contributions[_beneficiary].add(_weiAmount);
| contributions[_beneficiary] = contributions[_beneficiary].add(_weiAmount);
| 33,395 |
54 | // Send `amount` tokens to `to` from `msg.sender`/to The address of the recipient/amount The amount of tokens to be transferred/ return Whether the transfer was successful or not | function transfer(address to, uint256 amount)
public
returns (bool success);
| function transfer(address to, uint256 amount)
public
returns (bool success);
| 26,572 |
291 | // Helper to set the next `gasRelayPaymaster` variable | function __setGasRelayPaymaster(address _nextGasRelayPaymaster) private {
gasRelayPaymaster = _nextGasRelayPaymaster;
emit GasRelayPaymasterSet(_nextGasRelayPaymaster);
}
| function __setGasRelayPaymaster(address _nextGasRelayPaymaster) private {
gasRelayPaymaster = _nextGasRelayPaymaster;
emit GasRelayPaymasterSet(_nextGasRelayPaymaster);
}
| 72,927 |
259 | // Create new EPN (Ethereum Phone Number) for a owner owner The Owner wallet address itemId The itemId of the ownerreturn The EPN expiry time / | function createEPN(address owner, uint256 itemId) external returns (uint256);
| function createEPN(address owner, uint256 itemId) external returns (uint256);
| 35,619 |
394 | // high | t1 = PairingsBn254.copy(proof.wire_values_at_z[2 - i]);
t1.sub_assign(t0);
| t1 = PairingsBn254.copy(proof.wire_values_at_z[2 - i]);
t1.sub_assign(t0);
| 9,103 |
130 | // EIP-721 Metadata Update Extension | interface IERC4906 is IERC165, IERC721 {
/// @dev This event emits when the metadata of a token is changed.
/// So that the third-party platforms such as NFT market could
/// timely update the images and related attributes of the NFT.
event MetadataUpdate(uint256 _tokenId);
/// @dev This event emits when the metadata of a range of tokens is changed.
/// So that the third-party platforms such as NFT market could
/// timely update the images and related attributes of the NFTs.
event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);
}
| interface IERC4906 is IERC165, IERC721 {
/// @dev This event emits when the metadata of a token is changed.
/// So that the third-party platforms such as NFT market could
/// timely update the images and related attributes of the NFT.
event MetadataUpdate(uint256 _tokenId);
/// @dev This event emits when the metadata of a range of tokens is changed.
/// So that the third-party platforms such as NFT market could
/// timely update the images and related attributes of the NFTs.
event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);
}
| 11,666 |
58 | // Execute worker strategy. Take LP tokens + ETH. Return LP tokens + ETH./user User address/data Extra calldata information passed along to this strategy. | function execute(address user, uint256, /* debt */ bytes calldata data)
external
payable
onlyGoblin
nonReentrant
| function execute(address user, uint256, /* debt */ bytes calldata data)
external
payable
onlyGoblin
nonReentrant
| 25,660 |
108 | // Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.The call is not executed if the target address is not a contract. This is an internal detail of the `ERC721` contract and its use is deprecated. from address representing the previous owner of the given token ID to target address that will receive the tokens tokenId uint256 ID of the token to be transferred _data bytes optional data to send along with the callreturn bool whether the call correctly returned the expected magic value / | function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal returns (bool) {
if (!to.isContract()) {
return true;
}
| function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal returns (bool) {
if (!to.isContract()) {
return true;
}
| 7,559 |
37 | // Utilize assembly to efficiently check for order types. Note that these checks expect that there are no order types beyond the current set (0-4) and will need to be modified if more order types are added. | assembly {
| assembly {
| 16,839 |
4 | // Concatenate with the base URI | return string(abi.encodePacked(_baseUri, ipfsHash));
| return string(abi.encodePacked(_baseUri, ipfsHash));
| 11,861 |
133 | // The public data hash of the block (the 28 most significant bytes). | bytes28 blockDataHash;
| bytes28 blockDataHash;
| 36,707 |
208 | // Innherited from Open Zeppelin AccessControl.sol / | function getRoleAdmin(bytes32 role) external view returns (bytes32);
| function getRoleAdmin(bytes32 role) external view returns (bytes32);
| 16,745 |
8 | // 48 hours equal to 172800 seconds | uint64 deadline = uint64(block.timestamp + 172800);
_timer.setDeadline(deadline);
state = OrderState.Confirmed;
emit OrderStateChanged(_msgSender(), uint8(state), deadline);
| uint64 deadline = uint64(block.timestamp + 172800);
_timer.setDeadline(deadline);
state = OrderState.Confirmed;
emit OrderStateChanged(_msgSender(), uint8(state), deadline);
| 3,320 |
55 | // - Steps the Queue be replacing the first element with the next valid credit line's ID - Only works if the first element in the queue is null / | function stepQ() external {
ids.stepQ();
}
| function stepQ() external {
ids.stepQ();
}
| 37,657 |
357 | // Set the given borrow caps for the given cToken markets. Borrowing that brings total borrows to or above borrow cap will revert.Admin or borrowCapGuardian function to set the borrow caps. A borrow cap of 0 corresponds to unlimited borrowing.cTokens The addresses of the markets (tokens) to change the borrow caps fornewBorrowCaps The new borrow cap values in underlying to be set. A value of 0 corresponds to unlimited borrowing./ | function _setMarketBorrowCaps(CToken[] calldata cTokens, uint[] calldata newBorrowCaps) external {
require(msg.sender == admin || msg.sender == borrowCapGuardian, "only admin or borrow cap guardian can set borrow caps");
uint numMarkets = cTokens.length;
uint numBorrowCaps = newBorrowCaps.length;
require(numMarkets != 0 && numMarkets == numBorrowCaps, "invalid input");
for(uint i = 0; i < numMarkets; i++) {
borrowCaps[address(cTokens[i])] = newBorrowCaps[i];
emit NewBorrowCap(cTokens[i], newBorrowCaps[i]);
}
}
| function _setMarketBorrowCaps(CToken[] calldata cTokens, uint[] calldata newBorrowCaps) external {
require(msg.sender == admin || msg.sender == borrowCapGuardian, "only admin or borrow cap guardian can set borrow caps");
uint numMarkets = cTokens.length;
uint numBorrowCaps = newBorrowCaps.length;
require(numMarkets != 0 && numMarkets == numBorrowCaps, "invalid input");
for(uint i = 0; i < numMarkets; i++) {
borrowCaps[address(cTokens[i])] = newBorrowCaps[i];
emit NewBorrowCap(cTokens[i], newBorrowCaps[i]);
}
}
| 7,545 |
10 | // Origional Token sale contract with misallocated post ICO whitelist | address public constant REPLACES = 0x9901ed1e649C4a77C7Fff3dFd446ffE3464da747;
| address public constant REPLACES = 0x9901ed1e649C4a77C7Fff3dFd446ffE3464da747;
| 49,743 |
5 | // Retrieves the requested shop's address from its hash/shopHashed the hash of the shop name/ return shopAddress - the address of the shop | function getShopAddressByHash(bytes32 shopHashed) public view returns (address shopAddress) {
shopAddress = address(shopMapping[shopHashed]);
}
| function getShopAddressByHash(bytes32 shopHashed) public view returns (address shopAddress) {
shopAddress = address(shopMapping[shopHashed]);
}
| 3,757 |
4 | // Calculates total debt of the user in the based currency used to normalize the values of the assets This fetches the `balanceOf` of the stable and variable debt tokens for the user. For gas reasons, thevariable debt balance is calculated by fetching `scaledBalancesOf` normalized debt, which is cheaper thanfetching `balanceOf` user The address of the user reserve The data of the reserve for which the total debt of the user is being calculated assetPrice The price of the asset for which the total debt of the user is being calculated assetUnit The value representing one full unit of the asset | ) private view returns (uint256) {
// fetching variable debt
uint256 userTotalDebt = IScaledBalanceToken(reserve.variableDebtTokenAddress).scaledBalanceOf(
user
);
if (userTotalDebt != 0) {
userTotalDebt = userTotalDebt.rayMul(reserve.getNormalizedDebt());
}
userTotalDebt = userTotalDebt + IERC20(reserve.stableDebtTokenAddress).balanceOf(user);
userTotalDebt = assetPrice * userTotalDebt;
unchecked {
return userTotalDebt / assetUnit;
}
}
| ) private view returns (uint256) {
// fetching variable debt
uint256 userTotalDebt = IScaledBalanceToken(reserve.variableDebtTokenAddress).scaledBalanceOf(
user
);
if (userTotalDebt != 0) {
userTotalDebt = userTotalDebt.rayMul(reserve.getNormalizedDebt());
}
userTotalDebt = userTotalDebt + IERC20(reserve.stableDebtTokenAddress).balanceOf(user);
userTotalDebt = assetPrice * userTotalDebt;
unchecked {
return userTotalDebt / assetUnit;
}
}
| 36,491 |
3,778 | // 1891 | entry "pretiously" : ENG_ADVERB
| entry "pretiously" : ENG_ADVERB
| 22,727 |
217 | // Locked - 0 Open - 1 Ended- 2 | enum SalePhase {
WaitingToStart,
InProgress,
Finished
}
| enum SalePhase {
WaitingToStart,
InProgress,
Finished
}
| 31,956 |
33 | // FavorCurrency FavorCurrency is an ERC20 with blacklist & redemption addresses FavorCurrency is a compliant stablecoin with blacklist and redemptionaddresses. Only the owner can blacklist accounts. Redemption addressesare assigned automatically to the first 0x100000 addresses. Sendingtokens to the redemption address will trigger a burn operation. Onlythe owner can mint or blacklist accounts. This contract is owned by the FavorTokenController, which manages tokenminting & admin functionality. See FavorTokenController.sol See also: BurnableTokenWithBounds.sol ~~~~ Features ~~~~ Redemption Addresses- The first 0x100000 addresses are redemption addresses- Tokens sent to redemption addresses are burned- Redemptions are tracked off-chain- Cannot mint tokens to redemption addresses Blacklist- Owner | abstract contract FavorCurrency is BurnableTokenWithBounds {
using SafeMath for uint256;
uint256 constant CENT = 10**16;
uint256 constant REDEMPTION_ADDRESS_COUNT = 0x100000;
/**
* @dev Emitted when account blacklist status changes
*/
event Blacklisted(address indexed account, bool isBlacklisted);
/**
* @dev Emitted when `value` tokens are minted for `to`
* @param to address to mint tokens for
* @param value amount of tokens to be minted
*/
event Mint(address indexed to, uint256 value);
/**
* @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
* @param account address to mint tokens for
* @param amount amount of tokens to be minted
*
* Emits a {Mint} event
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` cannot be blacklisted.
* - `account` cannot be a redemption address.
*/
function mint(address account, uint256 amount) external onlyOwner {
require(!isBlacklisted[account], "FavorCurrency: account is blacklisted");
require(!isRedemptionAddress(account), "FavorCurrency: account is a redemption address");
_mint(account, amount);
emit Mint(account, amount);
}
/**
* @dev Set blacklisted status for the account.
* @param account address to set blacklist flag for
* @param _isBlacklisted blacklist flag value
*
* Requirements:
*
* - `msg.sender` should be owner.
*/
function setBlacklisted(address account, bool _isBlacklisted) external onlyOwner {
require(uint160(account) >= REDEMPTION_ADDRESS_COUNT, "FavorCurrency: blacklisting of redemption address is not allowed");
isBlacklisted[account] = _isBlacklisted;
emit Blacklisted(account, _isBlacklisted);
}
/**
* @dev Set canBurn status for the account.
* @param account address to set canBurn flag for
* @param _canBurn canBurn flag value
*
* Requirements:
*
* - `msg.sender` should be owner.
*/
function setCanBurn(address account, bool _canBurn) external onlyOwner {
canBurn[account] = _canBurn;
}
/**
* @dev Check if neither account is blacklisted before performing transfer
* If transfer recipient is a redemption address, burns tokens
* @notice Transfer to redemption address will burn tokens with a 1 cent precision
* @param sender address of sender
* @param recipient address of recipient
* @param amount amount of tokens to transfer
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual override {
require(!isBlacklisted[sender], "FavorCurrency: sender is blacklisted");
require(!isBlacklisted[recipient], "FavorCurrency: recipient is blacklisted");
if (isRedemptionAddress(recipient)) {
super._transfer(sender, recipient, amount.sub(amount.mod(CENT)));
_burn(recipient, amount.sub(amount.mod(CENT)));
} else {
super._transfer(sender, recipient, amount);
}
}
/**
* @dev Requere neither accounts to be blacklisted before approval
* @param owner address of owner giving approval
* @param spender address of spender to approve for
* @param amount amount of tokens to approve
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal override {
require(!isBlacklisted[owner], "FavorCurrency: tokens owner is blacklisted");
require(!isBlacklisted[spender] || amount == 0, "FavorCurrency: tokens spender is blacklisted");
super._approve(owner, spender, amount);
}
/**
* @dev Check if tokens can be burned at address before burning
* @param account account to burn tokens from
* @param amount amount of tokens to burn
*/
function _burn(address account, uint256 amount) internal override {
require(canBurn[account], "FavorCurrency: cannot burn from this address");
super._burn(account, amount);
}
/**
* @dev First 0x100000-1 addresses (0x0000000000000000000000000000000000000001 to 0x00000000000000000000000000000000000fffff)
* are the redemption addresses.
* @param account address to check is a redemption address
*
* All transfers to redemption address will trigger token burn.
*
* @notice For transfer to succeed, canBurn must be true for redemption address
*
* @return is `account` a redemption address
*/
function isRedemptionAddress(address account) internal pure returns (bool) {
return uint160(account) < uint160(REDEMPTION_ADDRESS_COUNT) && uint160(account) != 0;
}
}
| abstract contract FavorCurrency is BurnableTokenWithBounds {
using SafeMath for uint256;
uint256 constant CENT = 10**16;
uint256 constant REDEMPTION_ADDRESS_COUNT = 0x100000;
/**
* @dev Emitted when account blacklist status changes
*/
event Blacklisted(address indexed account, bool isBlacklisted);
/**
* @dev Emitted when `value` tokens are minted for `to`
* @param to address to mint tokens for
* @param value amount of tokens to be minted
*/
event Mint(address indexed to, uint256 value);
/**
* @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
* @param account address to mint tokens for
* @param amount amount of tokens to be minted
*
* Emits a {Mint} event
*
* Requirements
*
* - `account` cannot be the zero address.
* - `account` cannot be blacklisted.
* - `account` cannot be a redemption address.
*/
function mint(address account, uint256 amount) external onlyOwner {
require(!isBlacklisted[account], "FavorCurrency: account is blacklisted");
require(!isRedemptionAddress(account), "FavorCurrency: account is a redemption address");
_mint(account, amount);
emit Mint(account, amount);
}
/**
* @dev Set blacklisted status for the account.
* @param account address to set blacklist flag for
* @param _isBlacklisted blacklist flag value
*
* Requirements:
*
* - `msg.sender` should be owner.
*/
function setBlacklisted(address account, bool _isBlacklisted) external onlyOwner {
require(uint160(account) >= REDEMPTION_ADDRESS_COUNT, "FavorCurrency: blacklisting of redemption address is not allowed");
isBlacklisted[account] = _isBlacklisted;
emit Blacklisted(account, _isBlacklisted);
}
/**
* @dev Set canBurn status for the account.
* @param account address to set canBurn flag for
* @param _canBurn canBurn flag value
*
* Requirements:
*
* - `msg.sender` should be owner.
*/
function setCanBurn(address account, bool _canBurn) external onlyOwner {
canBurn[account] = _canBurn;
}
/**
* @dev Check if neither account is blacklisted before performing transfer
* If transfer recipient is a redemption address, burns tokens
* @notice Transfer to redemption address will burn tokens with a 1 cent precision
* @param sender address of sender
* @param recipient address of recipient
* @param amount amount of tokens to transfer
*/
function _transfer(
address sender,
address recipient,
uint256 amount
) internal virtual override {
require(!isBlacklisted[sender], "FavorCurrency: sender is blacklisted");
require(!isBlacklisted[recipient], "FavorCurrency: recipient is blacklisted");
if (isRedemptionAddress(recipient)) {
super._transfer(sender, recipient, amount.sub(amount.mod(CENT)));
_burn(recipient, amount.sub(amount.mod(CENT)));
} else {
super._transfer(sender, recipient, amount);
}
}
/**
* @dev Requere neither accounts to be blacklisted before approval
* @param owner address of owner giving approval
* @param spender address of spender to approve for
* @param amount amount of tokens to approve
*/
function _approve(
address owner,
address spender,
uint256 amount
) internal override {
require(!isBlacklisted[owner], "FavorCurrency: tokens owner is blacklisted");
require(!isBlacklisted[spender] || amount == 0, "FavorCurrency: tokens spender is blacklisted");
super._approve(owner, spender, amount);
}
/**
* @dev Check if tokens can be burned at address before burning
* @param account account to burn tokens from
* @param amount amount of tokens to burn
*/
function _burn(address account, uint256 amount) internal override {
require(canBurn[account], "FavorCurrency: cannot burn from this address");
super._burn(account, amount);
}
/**
* @dev First 0x100000-1 addresses (0x0000000000000000000000000000000000000001 to 0x00000000000000000000000000000000000fffff)
* are the redemption addresses.
* @param account address to check is a redemption address
*
* All transfers to redemption address will trigger token burn.
*
* @notice For transfer to succeed, canBurn must be true for redemption address
*
* @return is `account` a redemption address
*/
function isRedemptionAddress(address account) internal pure returns (bool) {
return uint160(account) < uint160(REDEMPTION_ADDRESS_COUNT) && uint160(account) != 0;
}
}
| 31,495 |
2 | // Pool parameters/@invariants: assets supported are BNB, Ether and Cryptonite //@invariants: assets supported are BNB, Ether and Cryptonite/ | Pool_Utils.CryptoAsset public stakingAsset;
uint maxNoOfMembers = 1; // Maximum number of contributors.
uint minNoOfMembers = 1; // Minimum number of contributors.
uint numberOfCycles = 1; // Total number of cycles.
uint cycleInterval = 1; // Total number of cycles intervals
| Pool_Utils.CryptoAsset public stakingAsset;
uint maxNoOfMembers = 1; // Maximum number of contributors.
uint minNoOfMembers = 1; // Minimum number of contributors.
uint numberOfCycles = 1; // Total number of cycles.
uint cycleInterval = 1; // Total number of cycles intervals
| 33,032 |
29 | // adding to the real contribution of the signer | uint256 realContribution = protocolWethAmount +
executorPriceAmount;
| uint256 realContribution = protocolWethAmount +
executorPriceAmount;
| 18,697 |
62 | // Override unpause so we can&39;t have newContractAddress set,/because then the contract was upgraded./This is public rather than external so we can call super.unpause/without using an expensive CALL. | function unpause() public onlyOwner whenPaused {
require(newContractAddress == address(0), "new contract cannot be 0x0");
// Actually unpause the contract.
super.unpause();
}
| function unpause() public onlyOwner whenPaused {
require(newContractAddress == address(0), "new contract cannot be 0x0");
// Actually unpause the contract.
super.unpause();
}
| 13,805 |
26 | // Math operations with safety checks / | 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, "SafeMath mul overflow");
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, "SafeMath div 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, "SafeMath sub 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, "SafeMath add overflow");
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, "SafeMath mod 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, "SafeMath mul overflow");
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, "SafeMath div 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, "SafeMath sub 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, "SafeMath add overflow");
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, "SafeMath mod 0");
return a % b;
}
}
| 1,573 |
18 | // Transfer tokens from one address to another_token erc20 The address of the ERC20 contract_from address The address which you want to send tokens from_to address The address which you want to transfer to_value uint256 the _value of tokens to be transferred/ | function safeTransferFrom(
IERC20 _token,
address _from,
address _to,
uint256 _value
) internal returns (bool)
| function safeTransferFrom(
IERC20 _token,
address _from,
address _to,
uint256 _value
) internal returns (bool)
| 4,841 |
28 | // Sets the auction mode of a specific Trade Pair Can only be called by DEFAULT_ADMIN. _tradePairIdid of the trading pair _modeAuction Mode / | function setAuctionMode(bytes32 _tradePairId, AuctionMode _mode) external override onlyRole(DEFAULT_ADMIN_ROLE) {
setAuctionModePrivate(_tradePairId, _mode);
}
| function setAuctionMode(bytes32 _tradePairId, AuctionMode _mode) external override onlyRole(DEFAULT_ADMIN_ROLE) {
setAuctionModePrivate(_tradePairId, _mode);
}
| 34,488 |
9 | // How the protection gets disabled. | function protectionChecker() internal view override returns(bool) {
return ProtectionSwitch_timestamp(1633046399); // Switch off protection on Thursday, September 30, 2021 11:59:59 PM GMT.
// return ProtectionSwitch_block(13000000); // Switch off protection on block 13000000.
// return ProtectionSwitch_manual(); // Switch off protection by calling disableProtection(); from owner. Default.
}
| function protectionChecker() internal view override returns(bool) {
return ProtectionSwitch_timestamp(1633046399); // Switch off protection on Thursday, September 30, 2021 11:59:59 PM GMT.
// return ProtectionSwitch_block(13000000); // Switch off protection on block 13000000.
// return ProtectionSwitch_manual(); // Switch off protection by calling disableProtection(); from owner. Default.
}
| 15,856 |
52 | // /DRIP | function ETHBalance() public view returns (uint256) { // get balance of ETH in contract
return address(this).balance;
}
| function ETHBalance() public view returns (uint256) { // get balance of ETH in contract
return address(this).balance;
}
| 26,691 |
4 | // constructs uniswap swap path from arrays of tokens and pool fees/ _path address[] of tokens/ _fees uint24[] of pool fees | function _constructUniswapPath(address[] memory _path, uint24[] memory _fees) private pure returns (bytes memory pathBytesString) {
pathBytesString = abi.encodePacked(_path[0]);
for (uint256 i = 0; i < _fees.length; i++) {
pathBytesString = abi.encodePacked(pathBytesString, _fees[i], _path[i + 1]);
}
}
| function _constructUniswapPath(address[] memory _path, uint24[] memory _fees) private pure returns (bytes memory pathBytesString) {
pathBytesString = abi.encodePacked(_path[0]);
for (uint256 i = 0; i < _fees.length; i++) {
pathBytesString = abi.encodePacked(pathBytesString, _fees[i], _path[i + 1]);
}
}
| 14,247 |
17 | // Merge update | function merge(uint256 _id, string memory _ipfsHash, address _contributor) public {
require(assets[_id].isPresent == true, "No asset with this id is present");
assets[_id].ipfsHash = _ipfsHash;
assets[_id].version += 1;
receiver = _contributor;
// mint the tokens for the contributor
callOracle(_contributor);
}
| function merge(uint256 _id, string memory _ipfsHash, address _contributor) public {
require(assets[_id].isPresent == true, "No asset with this id is present");
assets[_id].ipfsHash = _ipfsHash;
assets[_id].version += 1;
receiver = _contributor;
// mint the tokens for the contributor
callOracle(_contributor);
}
| 1,254 |
755 | // reset unclaimedFees counter | unclaimedFees = 0;
| unclaimedFees = 0;
| 29,584 |
51 | // Swap ETH for tokens | address[] memory path = new address[](2);
path[0] = address(weth);
path[1] = address(token);
| address[] memory path = new address[](2);
path[0] = address(weth);
path[1] = address(token);
| 934 |
13 | // special case for 0 deposit amount | if (_amount == 0) return 0;
| if (_amount == 0) return 0;
| 18,565 |
7 | // Right now sender/recipient args aren't used, but they may be in the future | function calculateFeeAmount(address sender, address recipient, uint256 amount)
external
override
view
returns (uint256 feeAmount)
| function calculateFeeAmount(address sender, address recipient, uint256 amount)
external
override
view
returns (uint256 feeAmount)
| 10,510 |
35 | // Get the incentive token address supported on this vaultreturn The address of incentive token / | function getIncentiveToken() public view override returns (address) {
address baseRewardPool = getBaseRewardPool();
return IConvexBaseRewardPool(baseRewardPool).rewardToken();
}
| function getIncentiveToken() public view override returns (address) {
address baseRewardPool = getBaseRewardPool();
return IConvexBaseRewardPool(baseRewardPool).rewardToken();
}
| 37,921 |
69 | // Update User Balance after playing dice game, only governance call it / | function updateUserBalance(address userAddress, uint256 gameAmount)
public
onlyGovernance
returns (bool)
| function updateUserBalance(address userAddress, uint256 gameAmount)
public
onlyGovernance
returns (bool)
| 40,899 |
233 | // mint reserved liquidity tokens for fee receiver | _mint(
FEE_RECEIVER_ADDRESS,
_getReservedLiquidityTokenId(isCall),
feeCost
);
emit Purchase(
account,
longTokenId,
contractSize,
| _mint(
FEE_RECEIVER_ADDRESS,
_getReservedLiquidityTokenId(isCall),
feeCost
);
emit Purchase(
account,
longTokenId,
contractSize,
| 22,781 |
70 | // Tells whether an operator is approved by a given owner. owner owner address which you want to query the approval of operator operator address which you want to query the approval ofreturn bool whether the given operator is approved by the given owner / | function isApprovedForAll(address owner, address operator) public view returns (bool) {
return _operatorApprovals[owner][operator];
}
| function isApprovedForAll(address owner, address operator) public view returns (bool) {
return _operatorApprovals[owner][operator];
}
| 1,261 |
107 | // mb deprecated | function robotRefund(address investor) public onlyTeam ICOFailed
| function robotRefund(address investor) public onlyTeam ICOFailed
| 45,239 |
13 | // /Initiates a deposit of want tokens to the vault./amountIn The amount of want tokens to deposit./receiver The address to receive vault tokens. | function deposit(uint256 amountIn, address receiver)
public
override
nonReentrant
ensureFeesAreCollected
returns (uint256 shares)
| function deposit(uint256 amountIn, address receiver)
public
override
nonReentrant
ensureFeesAreCollected
returns (uint256 shares)
| 9,837 |
27 | // Sets the next option the vault will be shorting, and closes the existing short.This allows all the users to withdraw if the next option is malicious. / | function commitAndClose(
ProtocolAdapterTypes.OptionTerms calldata optionTerms
| function commitAndClose(
ProtocolAdapterTypes.OptionTerms calldata optionTerms
| 32,279 |
13 | // recover lost erc20. getting them back chance very low | function reclaimERC20Token(address erc20Token) external onlyOwner {
IERC20(erc20Token).transfer(msg.sender, IERC20(erc20Token).balanceOf(address(this)));
}
| function reclaimERC20Token(address erc20Token) external onlyOwner {
IERC20(erc20Token).transfer(msg.sender, IERC20(erc20Token).balanceOf(address(this)));
}
| 74,210 |
173 | // usdc => sanUSDC_EUR | uint256 wantBalance = IERC20(want).balanceOf(address(this));
IStableMaster(stableMaster).deposit(wantBalance, address(this), IPoolManager(poolManager));
uint256 sanUsdcEurBalance = IERC20(sanUSDC_EUR).balanceOf(address(this));
IERC20(sanUSDC_EUR).transfer(IController(controller).vaults(want), sanUsdcEurBalance);
| uint256 wantBalance = IERC20(want).balanceOf(address(this));
IStableMaster(stableMaster).deposit(wantBalance, address(this), IPoolManager(poolManager));
uint256 sanUsdcEurBalance = IERC20(sanUSDC_EUR).balanceOf(address(this));
IERC20(sanUSDC_EUR).transfer(IController(controller).vaults(want), sanUsdcEurBalance);
| 43,228 |
67 | // Fund the farm: starts it if not already started, increases the end block | function fund(uint256 amount) public onlyOwner {
require(startBlock == 0 || block.number < endBlock, "fund: too late, the farm is closed");
_munchToken.safeTransferFrom(address(msg.sender), address(this), amount);
if (startBlock == 0) {
startBlock = block.number;
endBlock = startBlock;
}
endBlock += amount.div(rewardPerBlock);
fundsAdded = fundsAdded.add(amount);
}
| function fund(uint256 amount) public onlyOwner {
require(startBlock == 0 || block.number < endBlock, "fund: too late, the farm is closed");
_munchToken.safeTransferFrom(address(msg.sender), address(this), amount);
if (startBlock == 0) {
startBlock = block.number;
endBlock = startBlock;
}
endBlock += amount.div(rewardPerBlock);
fundsAdded = fundsAdded.add(amount);
}
| 3,917 |
13 | // reset the contract | function resetContract() public onlyAdmin {
delete playerSelector;
delete players;
lotteryStatus = false;
nftContract = address(0);
tokenId = 0;
ticketCost = 0;
totalEntries = 0;
resetEntryCount();
}
| function resetContract() public onlyAdmin {
delete playerSelector;
delete players;
lotteryStatus = false;
nftContract = address(0);
tokenId = 0;
ticketCost = 0;
totalEntries = 0;
resetEntryCount();
}
| 24,351 |
163 | // update the flash sale before starting NOTE: set 0 duration if you don't want an endTime | function updateFlashSale(
uint _saleID,
address[] memory _tokenAddresses,
uint[] memory _tokenIDs,
address _payTokenAddress,
uint _price,
address _receiver,
uint _purchaseLimitation,
uint _startTime,
uint _duration
| function updateFlashSale(
uint _saleID,
address[] memory _tokenAddresses,
uint[] memory _tokenIDs,
address _payTokenAddress,
uint _price,
address _receiver,
uint _purchaseLimitation,
uint _startTime,
uint _duration
| 54,129 |
3 | // The constructor sets the original `owner` of the contract to the sender account. / | constructor()
| constructor()
| 10,315 |
61 | // Check for an invalid timeStamp that is 0, or in the future | if (_response.timestamp == 0 || _response.timestamp > block.timestamp) {return true;}
| if (_response.timestamp == 0 || _response.timestamp > block.timestamp) {return true;}
| 10,709 |
291 | // Implementation of the {IERC20} interface.that a supply mechanism has to be added in a derived contract using {_mint}.For a generic mechanism see {ERC20PresetMinterPauser}.Additionally, an {Approval} event is emitted on calls to {transferFrom}.Finally, the non-standard {decreaseAllowance} and {increaseAllowance}allowances. See {IERC20-approve}./ Sets the values for {name} and {symbol}, initializes {decimals} witha default value of 18. To select a different value for {decimals}, use {_setupDecimals}. All three of these values are immutable: they can only be set once duringconstruction. / | constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
| constructor (string memory name, string memory symbol) public {
_name = name;
_symbol = symbol;
_decimals = 18;
}
| 237 |
10 | // Use in case of emergency 🦺./Check if the contract is initialized when the change is to true. | function updateContractOperation(bool _isFullyOperational) public onlyRole(ADMIN_ROLE) {
if (_isFullyOperational) {
require(
liquidityPool != address(0) && stakingManager != address(0),
"CONTRACT_NOT_INITIALIZED"
);
}
fullyOperational = _isFullyOperational;
emit ContractUpdateOperation(_isFullyOperational, msg.sender);
}
| function updateContractOperation(bool _isFullyOperational) public onlyRole(ADMIN_ROLE) {
if (_isFullyOperational) {
require(
liquidityPool != address(0) && stakingManager != address(0),
"CONTRACT_NOT_INITIALIZED"
);
}
fullyOperational = _isFullyOperational;
emit ContractUpdateOperation(_isFullyOperational, msg.sender);
}
| 15,125 |
186 | // move from not mintable -> whitelist 1 -> whitelist 2 -> public | function moveToNextStage(uint256 tokenId_) public onlyOwner checkTokenId(tokenId_) {
require(saleStage[tokenId_] < PUBLIC_SALE, "Now it's public sale. there is no more steps.");
saleStage[tokenId_] += 1;
}
| function moveToNextStage(uint256 tokenId_) public onlyOwner checkTokenId(tokenId_) {
require(saleStage[tokenId_] < PUBLIC_SALE, "Now it's public sale. there is no more steps.");
saleStage[tokenId_] += 1;
}
| 8,010 |
12 | // @custom:legacy Address of the LegacyERC20ETH predeploy. Deprecated. Balances are migrated to thestate trie as of the Bedrock upgrade. Contract has been locked and write functionscan no longer be accessed. / | address internal constant LEGACY_ERC20_ETH = 0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000;
| address internal constant LEGACY_ERC20_ETH = 0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000;
| 15,883 |
91 | // how many shares belong to each address | mapping (address => uint256) public addressToShares;
| mapping (address => uint256) public addressToShares;
| 55,155 |
141 | // management | bool public isShutdown;
bool public isInit;
address public owner;
string internal _tokenname;
string internal _tokensymbol;
event Deposited(address indexed _user, address indexed _account, uint256 _amount, bool _wrapped);
event Withdrawn(address indexed _user, uint256 _amount, bool _unwrapped);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
| bool public isShutdown;
bool public isInit;
address public owner;
string internal _tokenname;
string internal _tokensymbol;
event Deposited(address indexed _user, address indexed _account, uint256 _amount, bool _wrapped);
event Withdrawn(address indexed _user, uint256 _amount, bool _unwrapped);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
| 45,670 |
2 | // @custom:salt Governance/ @custom:deploy-type deployUpgradeable | contract Governance is IGovernor {
address internal immutable _factory;
constructor() {
_factory = msg.sender;
}
function updateValue(uint256 epoch, uint256 key, bytes32 value) external {
require(msg.sender == _factory , "Governance: Only factory allowed!");
emit ValueUpdated(epoch, key, value, msg.sender);
}
} | contract Governance is IGovernor {
address internal immutable _factory;
constructor() {
_factory = msg.sender;
}
function updateValue(uint256 epoch, uint256 key, bytes32 value) external {
require(msg.sender == _factory , "Governance: Only factory allowed!");
emit ValueUpdated(epoch, key, value, msg.sender);
}
} | 45,093 |
212 | // Choose proper router address according to your network:Ethereum mainnet: 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D (Uniswap)BSC mainnet: 0x10ED43C718714eb63d5aA57B78B54704E256024E (PancakeSwap) / | address private _routerAddress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address private _marketingAddress = 0xdA1ba4167d63Bb4f7CA30CE811eb60705103fF25;
| address private _routerAddress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;
address private _marketingAddress = 0xdA1ba4167d63Bb4f7CA30CE811eb60705103fF25;
| 18,988 |
9 | // Disallow withdraw if tokens haven't been bought yet. | require(bought_tokens);
uint256 contract_token_balance = token.balanceOf(address(this));
| require(bought_tokens);
uint256 contract_token_balance = token.balanceOf(address(this));
| 19,563 |
6 | // The index value of thenumber combination is fixed at 11, because 4 numbers have 11 winning combinations | uint8 constant keyLengthForEachBuy = 11;
| uint8 constant keyLengthForEachBuy = 11;
| 56,248 |
13 | // Give your vote (including votes delegated to you) to proposal 'proposals[proposal].name'. proposal index of proposal in the proposals array / | function vote(uint proposal) public {
Voter storage sender = voters[msg.sender];
require(sender.weight != 0, "Has no right to vote");
require(!sender.voted, "Already voted.");
sender.voted = true;
sender.vote = proposal;
// If 'proposal' is out of the range of the array,
// this will throw automatically and revert all changes.
proposals[proposal].voteCount += sender.weight;
}
| function vote(uint proposal) public {
Voter storage sender = voters[msg.sender];
require(sender.weight != 0, "Has no right to vote");
require(!sender.voted, "Already voted.");
sender.voted = true;
sender.vote = proposal;
// If 'proposal' is out of the range of the array,
// this will throw automatically and revert all changes.
proposals[proposal].voteCount += sender.weight;
}
| 24,963 |
12 | // uint256 tokensToReceive = ((payableAmount / 1018)_rate)10_tokenDecimals; | console.log("tokensToSale: ", tokenToSale.balanceOf(address(this)));
require(
tokenToSale.balanceOf(address(this)) >= tokensToReceive,
"Not enough tokens to sale"
);
require(
tokenToSale.transfer(buyer, tokensToReceive),
"Failed to transfer tokens"
| console.log("tokensToSale: ", tokenToSale.balanceOf(address(this)));
require(
tokenToSale.balanceOf(address(this)) >= tokensToReceive,
"Not enough tokens to sale"
);
require(
tokenToSale.transfer(buyer, tokensToReceive),
"Failed to transfer tokens"
| 17,815 |
2 | // The decimals of the auction token. | uint256 private constant AUCTION_TOKEN_DECIMAL_PLACES = 18;
uint256 private constant AUCTION_TOKEN_DECIMALS = 10 ** AUCTION_TOKEN_DECIMAL_PLACES;
| uint256 private constant AUCTION_TOKEN_DECIMAL_PLACES = 18;
uint256 private constant AUCTION_TOKEN_DECIMALS = 10 ** AUCTION_TOKEN_DECIMAL_PLACES;
| 25,185 |
4 | // We do an explicit type conversion from `address` to `TokenCreator` and assume that the type of the calling contract is `TokenCreator`, there is no real way to check that. | creator = TokenCreator(msg.sender);
tag = new Tag("ABC", 2);
name = _name;
| creator = TokenCreator(msg.sender);
tag = new Tag("ABC", 2);
name = _name;
| 50,412 |
129 | // New index has been set./newIndex Value of the new index. | event IndexUpdated(uint256 newIndex);
| event IndexUpdated(uint256 newIndex);
| 9,541 |
1 | // Sets the proxyTypeId. Should be called from the Proxy constructor_proxyTypeId uint representing Forwarding Proxy (id = 1) or Upgradeable Proxy (id = 2);/ | function setProxyTypeId (uint256 _proxyTypeId) internal {
require(_proxyTypeId == 1 || _proxyTypeId == 2, "Must be type 1 or 2");
bytes32 position = typeIdPosition;
assembly { // solhint-disable-line
sstore(position, _proxyTypeId)
}
}
| function setProxyTypeId (uint256 _proxyTypeId) internal {
require(_proxyTypeId == 1 || _proxyTypeId == 2, "Must be type 1 or 2");
bytes32 position = typeIdPosition;
assembly { // solhint-disable-line
sstore(position, _proxyTypeId)
}
}
| 35,617 |
9 | // Moves tokens `amount` from `sender` to `recipient`. Requirements: - `recipient` cannot be the zero address.- the caller must have a balance of at least `amount`. / | function transfer(address recipient, uint256 amount) public override returns (bool) {
_transferWithFee(msg.sender, recipient, amount);
return true;
}
| function transfer(address recipient, uint256 amount) public override returns (bool) {
_transferWithFee(msg.sender, recipient, amount);
return true;
}
| 34,292 |
161 | // Sets approved amount of tokens for spender. Returns success/spender Address of allowed account/value Number of approved tokens/ return Was approval successful? | function approve(address spender, uint value) public returns (bool) {
allowances[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
| function approve(address spender, uint value) public returns (bool) {
allowances[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
| 7,847 |
212 | // copy buffer 1 into buffer | for(uint256 i = 0; i < buf1.length; i++) {
buf[i] = buf1[i];
}
| for(uint256 i = 0; i < buf1.length; i++) {
buf[i] = buf1[i];
}
| 54,329 |
43 | // switch to next game | 40,304 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.