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 |
|---|---|---|---|---|
122 | // Uses random number generator from timestamp. However, nobody should know what order addresses are stored due to shffle | randNum = uint(keccak256(abi.encodePacked(block.timestamp, msg.sender, seed))) % lastEntryAllowed;
bigPrizeEligibleEntity = getEntity(randNum, false);
| randNum = uint(keccak256(abi.encodePacked(block.timestamp, msg.sender, seed))) % lastEntryAllowed;
bigPrizeEligibleEntity = getEntity(randNum, false);
| 44,171 |
60 | // Compute the pending in WAD. Pending is the amount to add (not yet unclaimed) rewards in WAD. balance The balance of the user rewardsIndexOnLastInteraction The index which was on the last interaction of the user currentRewardsIndex The current rewards index in the system assetUnit One unit of asset (10decimals)return The amount of pending rewards in WAD / | function _getPendingRewards(
uint256 balance,
uint256 rewardsIndexOnLastInteraction,
uint256 currentRewardsIndex,
uint256 assetUnit
| function _getPendingRewards(
uint256 balance,
uint256 rewardsIndexOnLastInteraction,
uint256 currentRewardsIndex,
uint256 assetUnit
| 43,566 |
60 | // Set beacon specification data / | function _setBeaconSpec(
uint64 _epochsPerFrame,
uint64 _slotsPerEpoch,
uint64 _secondsPerSlot,
uint64 _genesisTime
)
internal
| function _setBeaconSpec(
uint64 _epochsPerFrame,
uint64 _slotsPerEpoch,
uint64 _secondsPerSlot,
uint64 _genesisTime
)
internal
| 27,090 |
81 | // Get the ID of the second member they ever sold a membership to (used to determine eligibility for Team bonuses)/ | function getSecondMemberID(address _owner) internal view returns(uint256)
| function getSecondMemberID(address _owner) internal view returns(uint256)
| 41,528 |
4 | // Propotion of tokens bunch | uint8[4] memory compoundBunch = [2,5,2,2];
| uint8[4] memory compoundBunch = [2,5,2,2];
| 4,666 |
259 | // res += valcoefficients[38]. | res := addmod(res,
mulmod(val, /*coefficients[38]*/ mload(0xa00), PRIME),
PRIME)
| res := addmod(res,
mulmod(val, /*coefficients[38]*/ mload(0xa00), PRIME),
PRIME)
| 21,590 |
61 | // Module for using AddressConfig contracts. / | contract UsingConfig {
address private _config;
/**
* Initialize the argument as AddressConfig address.
*/
constructor(address _addressConfig) public {
_config = _addressConfig;
}
/**
* Returns the latest AddressConfig instance.
*/
function config() internal view returns (IAddressConfig) {
return IAddressConfig(_config);
}
/**
* Returns the latest AddressConfig address.
*/
function configAddress() external view returns (address) {
return _config;
}
}
| contract UsingConfig {
address private _config;
/**
* Initialize the argument as AddressConfig address.
*/
constructor(address _addressConfig) public {
_config = _addressConfig;
}
/**
* Returns the latest AddressConfig instance.
*/
function config() internal view returns (IAddressConfig) {
return IAddressConfig(_config);
}
/**
* Returns the latest AddressConfig address.
*/
function configAddress() external view returns (address) {
return _config;
}
}
| 2,802 |
226 | // recover the address who signed the message with v, r, s | address signer = ecrecover(digest, v, r, s);
| address signer = ecrecover(digest, v, r, s);
| 50,617 |
10 | // Mapping of interface id to bool about whether or not it's supported | mapping(bytes4 => bool) internal supportedInterfaces;
| mapping(bytes4 => bool) internal supportedInterfaces;
| 12,076 |
131 | // Constant for locked guard state | uint256 internal constant REENTRANCY_GUARD_LOCKED = 2;
| uint256 internal constant REENTRANCY_GUARD_LOCKED = 2;
| 24,601 |
27 | // shelf allowed to call | AuthLike_1(pile).rely(shelf);
DependLike_1(feed).depend("shelf", address(shelf));
DependLike_1(feed).depend("pile", address(pile));
| AuthLike_1(pile).rely(shelf);
DependLike_1(feed).depend("shelf", address(shelf));
DependLike_1(feed).depend("pile", address(pile));
| 31,708 |
103 | // YspikeToken with Governance. | contract YNetToken is ERC20("yNet", "yNet"), Ownable {
constructor (address _presale_address) public {
_mint(_presale_address, (2000000)*(10 ** 18));
}
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
}
/// @notice Burns `_amount` of token from `owner`. Must only be called by the owner (MasterChef).
function burn(address _owner, uint256 _amount) public onlyOwner {
_burn(_owner, _amount);
}
}
| contract YNetToken is ERC20("yNet", "yNet"), Ownable {
constructor (address _presale_address) public {
_mint(_presale_address, (2000000)*(10 ** 18));
}
/// @notice Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
}
/// @notice Burns `_amount` of token from `owner`. Must only be called by the owner (MasterChef).
function burn(address _owner, uint256 _amount) public onlyOwner {
_burn(_owner, _amount);
}
}
| 3,036 |
66 | // BSC side tokenB - foreign token address or address(1) for ETH amountB - amount of foreign tokens or ETH | function claimInvestmentBehalf(
address tokenB, // foreignToken
address user,
uint128 amountB, //amount of tokenB that has to be swapped
uint128 currentRate, // rate with 18 decimals: tokenB price / Native coin price
uint256 foreignBalance // total tokens amount sent by user to pair on other chain
)
external
onlySystem
returns (bool)
| function claimInvestmentBehalf(
address tokenB, // foreignToken
address user,
uint128 amountB, //amount of tokenB that has to be swapped
uint128 currentRate, // rate with 18 decimals: tokenB price / Native coin price
uint256 foreignBalance // total tokens amount sent by user to pair on other chain
)
external
onlySystem
returns (bool)
| 18,969 |
6 | // Function that tries to update switch locked amountThis function is allowed only for switch creator. Funds are only added on top and can't be deduced from original amount. No return, reverts on error / | function updateSwitchAmount() external payable;
| function updateSwitchAmount() external payable;
| 16,105 |
7 | // For large copies we copy whole words at a time. The final word is aligned to the end of the range (instead of after the previous) to handle partial words. So a copy will look like this: We handle overlap in the source and destination range by changing the copying direction. This prevents us from overwriting parts of source that we still need to copy. This correctly handles source == dest | if (source > dest) {
assembly {
| if (source > dest) {
assembly {
| 6,367 |
78 | // Set WTON address/_wton WTON address | function setWTON(address _wton) external override onlyOwner {
require(_wton != address(0), "DAOVault: input is zero");
wton = IERC20(_wton);
}
| function setWTON(address _wton) external override onlyOwner {
require(_wton != address(0), "DAOVault: input is zero");
wton = IERC20(_wton);
}
| 29,146 |
55 | // `onlySecurityGuard` Delays a payment for a set number of seconds/_idPayment ID of the payment to be delayed/_delay The number of seconds to delay the payment | function delayPayment(uint _idPayment, uint _delay) onlySecurityGuard external {
require(_idPayment < authorizedPayments.length);
// Overflow test
require(_delay <= 10**18);
Payment storage p = authorizedPayments[_idPayment];
require(p.securityGuardDelay + _delay <= maxSecurityGuardDelay);
require(!p.paid);
require(!p.canceled);
p.securityGuardDelay += _delay;
p.earliestPayTime += _delay;
}
| function delayPayment(uint _idPayment, uint _delay) onlySecurityGuard external {
require(_idPayment < authorizedPayments.length);
// Overflow test
require(_delay <= 10**18);
Payment storage p = authorizedPayments[_idPayment];
require(p.securityGuardDelay + _delay <= maxSecurityGuardDelay);
require(!p.paid);
require(!p.canceled);
p.securityGuardDelay += _delay;
p.earliestPayTime += _delay;
}
| 46,618 |
10 | // todo: unstake the validators prior removal? | ParticipantsLibrary.ParticipantsStorage storage ps = ParticipantsLibrary.participantsStorage();
uint256 count = ps.validatorCount;
while (count > 0) {
count = ParticipantsLibrary.removeValidator(ps.validators[0], ParticipantsLibrary.getValidatorPublicKey(ps.validators[0]));
}
| ParticipantsLibrary.ParticipantsStorage storage ps = ParticipantsLibrary.participantsStorage();
uint256 count = ps.validatorCount;
while (count > 0) {
count = ParticipantsLibrary.removeValidator(ps.validators[0], ParticipantsLibrary.getValidatorPublicKey(ps.validators[0]));
}
| 45,096 |
55 | // require(hasClosed() || capReached()); |
finalization();
emit Finalized();
isFinalized = true;
|
finalization();
emit Finalized();
isFinalized = true;
| 18,024 |
53 | // vAMM will burn FRAX if the effective sale price is above 1. It is essentially free FRAX and a protocol-level profit | {
uint256 effective_sale_price = frax_in.mul(PRICE_PRECISION).div(fxb_out);
if(effective_sale_price > PRICE_PRECISION){
| {
uint256 effective_sale_price = frax_in.mul(PRICE_PRECISION).div(fxb_out);
if(effective_sale_price > PRICE_PRECISION){
| 35,665 |
1,133 | // First, check exact matching overrides | if (calldataMockTypes[msg.data] == MockType.Revert) {
revert(calldataRevertMessage[msg.data]);
}
| if (calldataMockTypes[msg.data] == MockType.Revert) {
revert(calldataRevertMessage[msg.data]);
}
| 47,698 |
9 | // --- EIP712 niceties --- | bytes32 public DOMAIN_SEPARATOR;
| bytes32 public DOMAIN_SEPARATOR;
| 554 |
60 | // 1. Take out collateral | bank.takeCollateral(address(wgauge), collId, collSize);
wgauge.burn(collId, collSize);
| bank.takeCollateral(address(wgauge), collId, collSize);
wgauge.burn(collId, collSize);
| 42,344 |
60 | // if the supply was totally depleted, disconnect from the smart token | if (_sellAmount == tokenSupply)
token.setChanger(ITokenChanger(0x0));
Change(token, _reserveToken, msg.sender, _sellAmount, amount);
return amount;
| if (_sellAmount == tokenSupply)
token.setChanger(ITokenChanger(0x0));
Change(token, _reserveToken, msg.sender, _sellAmount, amount);
return amount;
| 42,004 |
10 | // Returns an array of token IDs owned by `owner`,in the range [`start`, `stop`)(i.e. `start <= tokenId < stop`). This function allows for tokens to be queried if the collection | * grows too big for a single call of {ERC721AQueryable-tokensOfOwner}.
*
* Requirements:
*
* - `start` < `stop`
*/
function tokensOfOwnerIn(
address owner,
uint256 start,
uint256 stop
) external view override returns (uint256[] memory) {
unchecked {
if (start >= stop) revert InvalidQueryRange();
uint256 tokenIdsIdx;
uint256 stopLimit = _nextTokenId();
// Set `start = max(start, _startTokenId())`.
if (start < _startTokenId()) {
start = _startTokenId();
}
// Set `stop = min(stop, stopLimit)`.
if (stop > stopLimit) {
stop = stopLimit;
}
uint256 tokenIdsMaxLength = balanceOf(owner);
// Set `tokenIdsMaxLength = min(balanceOf(owner), stop - start)`,
// to cater for cases where `balanceOf(owner)` is too big.
if (start < stop) {
uint256 rangeLength = stop - start;
if (rangeLength < tokenIdsMaxLength) {
tokenIdsMaxLength = rangeLength;
}
} else {
tokenIdsMaxLength = 0;
}
uint256[] memory tokenIds = new uint256[](tokenIdsMaxLength);
if (tokenIdsMaxLength == 0) {
return tokenIds;
}
// We need to call `explicitOwnershipOf(start)`,
// because the slot at `start` may not be initialized.
TokenOwnership memory ownership = explicitOwnershipOf(start);
address currOwnershipAddr;
// If the starting slot exists (i.e. not burned), initialize `currOwnershipAddr`.
// `ownership.address` will not be zero, as `start` is clamped to the valid token ID range.
if (!ownership.burned) {
currOwnershipAddr = ownership.addr;
}
for (uint256 i = start; i != stop && tokenIdsIdx != tokenIdsMaxLength; ++i) {
ownership = _ownershipAt(i);
if (ownership.burned) {
continue;
}
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
tokenIds[tokenIdsIdx++] = i;
}
}
// Downsize the array to fit.
assembly {
mstore(tokenIds, tokenIdsIdx)
}
return tokenIds;
}
}
| * grows too big for a single call of {ERC721AQueryable-tokensOfOwner}.
*
* Requirements:
*
* - `start` < `stop`
*/
function tokensOfOwnerIn(
address owner,
uint256 start,
uint256 stop
) external view override returns (uint256[] memory) {
unchecked {
if (start >= stop) revert InvalidQueryRange();
uint256 tokenIdsIdx;
uint256 stopLimit = _nextTokenId();
// Set `start = max(start, _startTokenId())`.
if (start < _startTokenId()) {
start = _startTokenId();
}
// Set `stop = min(stop, stopLimit)`.
if (stop > stopLimit) {
stop = stopLimit;
}
uint256 tokenIdsMaxLength = balanceOf(owner);
// Set `tokenIdsMaxLength = min(balanceOf(owner), stop - start)`,
// to cater for cases where `balanceOf(owner)` is too big.
if (start < stop) {
uint256 rangeLength = stop - start;
if (rangeLength < tokenIdsMaxLength) {
tokenIdsMaxLength = rangeLength;
}
} else {
tokenIdsMaxLength = 0;
}
uint256[] memory tokenIds = new uint256[](tokenIdsMaxLength);
if (tokenIdsMaxLength == 0) {
return tokenIds;
}
// We need to call `explicitOwnershipOf(start)`,
// because the slot at `start` may not be initialized.
TokenOwnership memory ownership = explicitOwnershipOf(start);
address currOwnershipAddr;
// If the starting slot exists (i.e. not burned), initialize `currOwnershipAddr`.
// `ownership.address` will not be zero, as `start` is clamped to the valid token ID range.
if (!ownership.burned) {
currOwnershipAddr = ownership.addr;
}
for (uint256 i = start; i != stop && tokenIdsIdx != tokenIdsMaxLength; ++i) {
ownership = _ownershipAt(i);
if (ownership.burned) {
continue;
}
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
tokenIds[tokenIdsIdx++] = i;
}
}
// Downsize the array to fit.
assembly {
mstore(tokenIds, tokenIdsIdx)
}
return tokenIds;
}
}
| 10,783 |
26 | // Mark the nonce as redeemed | _signedMints[tokenNonce] = true;
| _signedMints[tokenNonce] = true;
| 34,502 |
57 | // Compound mode is only enabled when stake token = reward token and isAutoCompound is true / | function canCompound() public view returns (bool) {
return address(stakedToken) == address(rewardToken) && isAutoCompound;
}
| function canCompound() public view returns (bool) {
return address(stakedToken) == address(rewardToken) && isAutoCompound;
}
| 58,533 |
2 | // Get rates of rewards in one call/ return rate0 The rate of token0, rewards / sec/ return rate1 The rate of token1, rewards / sec | function rewardRates() external view returns (uint128 rate0, uint128 rate1);
| function rewardRates() external view returns (uint128 rate0, uint128 rate1);
| 28,273 |
68 | // Burn XP Fee | uint256 dueAmount = (xpCost * uint256(amountToRent) * rental.duration) / 3600;
IGuildXP(_contracts.guildXP).burn(msg.sender, dueAmount);
| uint256 dueAmount = (xpCost * uint256(amountToRent) * rental.duration) / 3600;
IGuildXP(_contracts.guildXP).burn(msg.sender, dueAmount);
| 33,836 |
112 | // more than _currentIndex - _startTokenId() times |
unchecked {
return _currentIndex - _burnCounter - _startTokenId();
}
|
unchecked {
return _currentIndex - _burnCounter - _startTokenId();
}
| 34,634 |
41 | // we take as much as we can from the pool | limboRestore = AddGivedTax(limboRestore);
| limboRestore = AddGivedTax(limboRestore);
| 23,338 |
6 | // These functions deal with verification of Merkle Trees proofs. The proofs can be generated using the JavaScript libraryNote: the hashing algorithm should be keccak256 and pair sorting should be enabled. See `test/utils/cryptography/MerkleProof.test.js` for some examples. WARNING: You should avoid using leaf values that are 64 bytes long prior tohashing, or use a hash function other than keccak256 for hashing leaves.This is because the concatenation of a sorted pair of internal nodes inthe merkle tree could be reinterpreted as a leaf value. / | library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = _efficientHash(computedHash, proofElement);
} else {
// Hash(current element of the proof + current computed hash)
computedHash = _efficientHash(proofElement, computedHash);
}
}
return computedHash;
}
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
| library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = _efficientHash(computedHash, proofElement);
} else {
// Hash(current element of the proof + current computed hash)
computedHash = _efficientHash(proofElement, computedHash);
}
}
return computedHash;
}
function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {
assembly {
mstore(0x00, a)
mstore(0x20, b)
value := keccak256(0x00, 0x40)
}
}
}
| 13,239 |
2 | // Mapping from token ID to generation | mapping (uint256 => uint8) private _tokenGeneration;
| mapping (uint256 => uint8) private _tokenGeneration;
| 34,221 |
161 | // ran once on contract creationhouseFeeAddress and owner set | function BetDex() public {
houseFeeAddress = msg.sender;
owner = msg.sender;
//change default gas price from 20 Gwei to 10 Gwei
oraclize_setCustomGasPrice(10000000000);
}
| function BetDex() public {
houseFeeAddress = msg.sender;
owner = msg.sender;
//change default gas price from 20 Gwei to 10 Gwei
oraclize_setCustomGasPrice(10000000000);
}
| 24,890 |
2 | // Check if the contract at 'addr' implements the IUniswapV2Pair interface | try IUniswapV2Pair(addr).factory() returns (address) {
| try IUniswapV2Pair(addr).factory() returns (address) {
| 8,849 |
110 | // disables minting once cap is reached | if (_supply >= cap) {
maxSupplyReached = true;
}
| if (_supply >= cap) {
maxSupplyReached = true;
}
| 22,907 |
12 | // Deposit LP tokens to MasterChef for bkr allocation. | function deposit(uint256 _pid, uint256 _amount) public nonReentrant poolExists(_pid) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accbkrPerShare).div(1e12).sub(user.rewardDebt);
if (pending > 0) {
safebkrTransfer(msg.sender, pending);
}
}
if (_amount > 0) {
pool.lpToken.transferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
}
user.rewardDebt = user.amount.mul(pool.accbkrPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
| function deposit(uint256 _pid, uint256 _amount) public nonReentrant poolExists(_pid) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
updatePool(_pid);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accbkrPerShare).div(1e12).sub(user.rewardDebt);
if (pending > 0) {
safebkrTransfer(msg.sender, pending);
}
}
if (_amount > 0) {
pool.lpToken.transferFrom(address(msg.sender), address(this), _amount);
user.amount = user.amount.add(_amount);
}
user.rewardDebt = user.amount.mul(pool.accbkrPerShare).div(1e12);
emit Deposit(msg.sender, _pid, _amount);
}
| 7,876 |
162 | // Tokens which cannot be withdrawn by sweep()/ reward, auToken, PLY (want token)/ return Array of protected tokens | function protectedTokens() public view override returns (address[] memory) {
address[] memory protected = new address[](3);
protected[0] = address(want);
protected[1] = auToken;
return protected;
}
| function protectedTokens() public view override returns (address[] memory) {
address[] memory protected = new address[](3);
protected[0] = address(want);
protected[1] = auToken;
return protected;
}
| 34,782 |
414 | // Cancel the vote of the msg.sender.cancel vote is not allow in genesisProtocol so this function doing nothing.This function is here in order to comply to the IntVoteInterface . / | function cancelVote(bytes32 _proposalId) external votable(_proposalId) {
//this is not allowed
return;
}
| function cancelVote(bytes32 _proposalId) external votable(_proposalId) {
//this is not allowed
return;
}
| 35,492 |
209 | // DEV: start at a random spot in the list so that checks are spread evenly among cron jobs | uint256 numCrons = s_activeCronJobIDs.length();
uint256 startIdx = block.number % numCrons;
bool result;
bytes memory payload;
(result, payload) = checkInRange(startIdx, numCrons);
if (result) {
return (result, payload);
}
| uint256 numCrons = s_activeCronJobIDs.length();
uint256 startIdx = block.number % numCrons;
bool result;
bytes memory payload;
(result, payload) = checkInRange(startIdx, numCrons);
if (result) {
return (result, payload);
}
| 28,938 |
82 | // get the required fee for the released ETH bonus -------------------------------------------------------------------------------param _user --> the address of the user----------------------------------------------------------returns the fee amount. / | function calculateETHBonusFee(address _user) external view returns(uint ETH_Fee) {
uint wethReleased = _calculateETHReleasedAmount(_user);
if (wethReleased > 0) {
(uint feeForWethInUtoken,) = _calculateETHFee(wethReleased);
return feeForWethInUtoken;
} else return 0;
}
| function calculateETHBonusFee(address _user) external view returns(uint ETH_Fee) {
uint wethReleased = _calculateETHReleasedAmount(_user);
if (wethReleased > 0) {
(uint feeForWethInUtoken,) = _calculateETHFee(wethReleased);
return feeForWethInUtoken;
} else return 0;
}
| 9,395 |
27 | // multi-sig function modifier: the operation must have an intrinsic hash in order that later attempts can be realised as the same underlying operation and thus count as confirmations. | modifier onlyManyOwners(bytes32 _operation) {
if (confirmAndCheck(_operation))
_;
}
| modifier onlyManyOwners(bytes32 _operation) {
if (confirmAndCheck(_operation))
_;
}
| 32,399 |
15 | // Constructor that rejects incoming Ether The `payable` flag is added so we can access `msg.value` without compiler warning. If we leave out payable, then Solidity will allow inheriting contracts to implement a payable constructor. By doing it this way we prevent a payable constructor from working. Alternatively we could use assembly to access msg.value./ | constructor() public payable {
require(msg.value == 0);
}
| constructor() public payable {
require(msg.value == 0);
}
| 9,806 |
335 | // Calculate pending rewards for a user user address of the userreturn Pending rewards / | function calculatePendingRewards(address user) external view returns (uint256) {
if ((block.number > lastRewardBlock) && (totalAmountStaked != 0)) {
uint256 multiplier = _getMultiplier(lastRewardBlock, block.number);
uint256 tokenRewardForStaking = multiplier * rewardPerBlockForStaking;
uint256 adjustedEndBlock = endBlock;
uint256 adjustedCurrentPhase = currentPhase;
// Check whether to adjust multipliers and reward per block
while (
(block.number > adjustedEndBlock) && (adjustedCurrentPhase < (NUMBER_PERIODS - 1))
) {
// Update current phase
adjustedCurrentPhase++;
// Update rewards per block
uint256 adjustedRewardPerBlockForStaking = stakingPeriod[adjustedCurrentPhase]
.rewardPerBlockForStaking;
// Calculate adjusted block number
uint256 previousEndBlock = adjustedEndBlock;
// Update end block
adjustedEndBlock =
previousEndBlock +
stakingPeriod[adjustedCurrentPhase].periodLengthInBlock;
// Calculate new multiplier
uint256 newMultiplier = (block.number <= adjustedEndBlock)
? (block.number - previousEndBlock)
: stakingPeriod[adjustedCurrentPhase].periodLengthInBlock;
// Adjust token rewards for staking
tokenRewardForStaking += (newMultiplier * adjustedRewardPerBlockForStaking);
}
uint256 adjustedTokenPerShare = accTokenPerShare +
(tokenRewardForStaking * PRECISION_FACTOR) /
totalAmountStaked;
return
(userInfo[user].amount * adjustedTokenPerShare) /
PRECISION_FACTOR -
userInfo[user].rewardDebt;
} else {
return
(userInfo[user].amount * accTokenPerShare) /
PRECISION_FACTOR -
userInfo[user].rewardDebt;
}
}
| function calculatePendingRewards(address user) external view returns (uint256) {
if ((block.number > lastRewardBlock) && (totalAmountStaked != 0)) {
uint256 multiplier = _getMultiplier(lastRewardBlock, block.number);
uint256 tokenRewardForStaking = multiplier * rewardPerBlockForStaking;
uint256 adjustedEndBlock = endBlock;
uint256 adjustedCurrentPhase = currentPhase;
// Check whether to adjust multipliers and reward per block
while (
(block.number > adjustedEndBlock) && (adjustedCurrentPhase < (NUMBER_PERIODS - 1))
) {
// Update current phase
adjustedCurrentPhase++;
// Update rewards per block
uint256 adjustedRewardPerBlockForStaking = stakingPeriod[adjustedCurrentPhase]
.rewardPerBlockForStaking;
// Calculate adjusted block number
uint256 previousEndBlock = adjustedEndBlock;
// Update end block
adjustedEndBlock =
previousEndBlock +
stakingPeriod[adjustedCurrentPhase].periodLengthInBlock;
// Calculate new multiplier
uint256 newMultiplier = (block.number <= adjustedEndBlock)
? (block.number - previousEndBlock)
: stakingPeriod[adjustedCurrentPhase].periodLengthInBlock;
// Adjust token rewards for staking
tokenRewardForStaking += (newMultiplier * adjustedRewardPerBlockForStaking);
}
uint256 adjustedTokenPerShare = accTokenPerShare +
(tokenRewardForStaking * PRECISION_FACTOR) /
totalAmountStaked;
return
(userInfo[user].amount * adjustedTokenPerShare) /
PRECISION_FACTOR -
userInfo[user].rewardDebt;
} else {
return
(userInfo[user].amount * accTokenPerShare) /
PRECISION_FACTOR -
userInfo[user].rewardDebt;
}
}
| 68,522 |
8 | // SY-specific | error SYQiTokenMintFailed(uint256 errCode);
error SYQiTokenRedeemFailed(uint256 errCode);
error SYQiTokenRedeemRewardsFailed(uint256 rewardAccruedType0, uint256 rewardAccruedType1);
error SYQiTokenBorrowRateTooHigh(uint256 borrowRate, uint256 borrowRateMax);
error SYCurveInvalidPid();
error SYCurve3crvPoolNotFound();
error SYApeDepositAmountTooSmall(uint256 amountDeposited);
error SYBalancerInvalidPid();
| error SYQiTokenMintFailed(uint256 errCode);
error SYQiTokenRedeemFailed(uint256 errCode);
error SYQiTokenRedeemRewardsFailed(uint256 rewardAccruedType0, uint256 rewardAccruedType1);
error SYQiTokenBorrowRateTooHigh(uint256 borrowRate, uint256 borrowRateMax);
error SYCurveInvalidPid();
error SYCurve3crvPoolNotFound();
error SYApeDepositAmountTooSmall(uint256 amountDeposited);
error SYBalancerInvalidPid();
| 13,178 |
35 | // oods_coefficients[25]/ mload(add(context, 0x64a0)), res += c_26(f_1(x) - f_1(g^14z)) / (x - g^14z). | res := add(
res,
mulmod(mulmod(/*(x - g^14 * z)^(-1)*/ mload(add(denominatorsPtr, 0x1c0)),
| res := add(
res,
mulmod(mulmod(/*(x - g^14 * z)^(-1)*/ mload(add(denominatorsPtr, 0x1c0)),
| 63,803 |
18 | // Update the running total of `from` tokens to sell | result += perDay;
| result += perDay;
| 33,305 |
6 | // req.add("urlUSD", "https:datafeed.xyz/ethusd");req.add("pathUSD", "data");req.add("urlEUR", "https:datafeed.xyz/etheur");req.add("pathEUR", "data");req.add("urlJPY", "https:datafeed.xyz/ethjpy");req.add("pathJPY", "data"); | req.addUint("times", 10000);
requestOracleData(req, payment);
| req.addUint("times", 10000);
requestOracleData(req, payment);
| 22,307 |
807 | // Converts a unsigned 60.18-decimal fixed-point number to basic integer form, rounding down in the process./x The unsigned 60.18-decimal fixed-point number to convert./ return result The same number in basic integer form. | function toUint(uint256 x) internal pure returns (uint256 result) {
unchecked {
result = x / SCALE;
}
}
| function toUint(uint256 x) internal pure returns (uint256 result) {
unchecked {
result = x / SCALE;
}
}
| 26,352 |
61 | // Returns the list of the pending unbank owners. | function getPendingUnbankOwnerList() external view returns (address[] memory) {
return pendingOwners;
}
| function getPendingUnbankOwnerList() external view returns (address[] memory) {
return pendingOwners;
}
| 39,396 |
33 | // Checks whether the signature provided is valid for the provided data, hash. Will revert otherwise. dataHash Hash of the data (could be either a message hash or transaction hash) data That should be signed (this is passed to an external validator contract) signatures Signature data that should be verified. Can be ECDSA signature, contract signature (EIP-1271) or approved hash. requiredSignatures Amount of required valid signatures. / | function checkNSignatures(
bytes32 dataHash,
bytes memory data,
bytes memory signatures,
uint256 requiredSignatures
| function checkNSignatures(
bytes32 dataHash,
bytes memory data,
bytes memory signatures,
uint256 requiredSignatures
| 291 |
1 | // update state MUST BEFORE get borrow amount which is depent on latest borrow index | reserveData.updateState();
(vars.borrowAmount, vars.thresholdPrice, vars.liquidatePrice) = GenericLogic.calculateLoanLiquidatePrice(
vars.loanId,
loanData.reserveAsset,
reserveData,
loanData.nftAsset,
nftData,
vars.loanAddress,
_addressesProvider.getReserveOracle(),
| reserveData.updateState();
(vars.borrowAmount, vars.thresholdPrice, vars.liquidatePrice) = GenericLogic.calculateLoanLiquidatePrice(
vars.loanId,
loanData.reserveAsset,
reserveData,
loanData.nftAsset,
nftData,
vars.loanAddress,
_addressesProvider.getReserveOracle(),
| 53,944 |
8 | // Sets the Grg proxy./ Note that only the contract staker can call this./ Note that this can only be called when not in Catastrophic Failure mode./grgProxyAddress Address of the RigoBlock Grg Proxy. | function setGrgProxy(address grgProxyAddress)
external;
| function setGrgProxy(address grgProxyAddress)
external;
| 35,943 |
432 | // We only need to withdraw what we don't currently have | uint256 amountToLiquidate = _amountNeeded.sub(wantBalance);
| uint256 amountToLiquidate = _amountNeeded.sub(wantBalance);
| 2,346 |
101 | // Override. Determines how ETH is stored/forwarded on purchases. / | function _forwardFunds() internal {
// NOTE: Do nothing here. Keep funds in contract by default
}
| function _forwardFunds() internal {
// NOTE: Do nothing here. Keep funds in contract by default
}
| 6,133 |
6 | // Stores commonly used Pool state. This slot is preferred for gas-sensitive operations as it is read in all joins, swaps and exits, and therefore warm. See `ManagedPoolStorageLib.sol` for data layout. | bytes32 private _poolState;
| bytes32 private _poolState;
| 22,118 |
176 | // use by default 300,000 gas to process auto-claiming dividends | uint256 public gasForProcessing = 300000;
| uint256 public gasForProcessing = 300000;
| 16,204 |
25 | // gets the strings of lockUpAmount of _address. _address address The address gets the string of lockUpAmount of. / | function lockUpAmountStrOf(address _address) external view returns (
address Address,
string a,
string b,
string c,
string d,
string e,
string f
| function lockUpAmountStrOf(address _address) external view returns (
address Address,
string a,
string b,
string c,
string d,
string e,
string f
| 11,144 |
91 | // Calculate slopes and biases Kept at zero when they have to | if (oldLocked.end > block.timestamp && oldLocked.amount > 0) {
uOld.slope = oldLocked.amount / iMAXTIME;
uOld.bias =
uOld.slope *
int128(int256(oldLocked.end - block.timestamp));
}
| if (oldLocked.end > block.timestamp && oldLocked.amount > 0) {
uOld.slope = oldLocked.amount / iMAXTIME;
uOld.bias =
uOld.slope *
int128(int256(oldLocked.end - block.timestamp));
}
| 15,594 |
3 | // Transfers `_amount` tokens to `_to`. _to : The address receiving tokens. _amount : The quantity of tokens to send. / | function transfer(address _to, uint256 _amount) external returns (bool success);
| function transfer(address _to, uint256 _amount) external returns (bool success);
| 50,045 |
47 | // Iterate over periods starting from the last claimed snapshot | for (uint256 i = lastClaimedSnapshot[_address]; i < periods.length; i++) {
| for (uint256 i = lastClaimedSnapshot[_address]; i < periods.length; i++) {
| 2,752 |
0 | // / |
return abi.encodePacked(hex"63", uint32(_code.length), hex"80_60_0E_60_00_39_60_00_F3", _code);
|
return abi.encodePacked(hex"63", uint32(_code.length), hex"80_60_0E_60_00_39_60_00_F3", _code);
| 32,085 |
15 | // ManagerProxy A proxy contract that uses delegatecall to execute function calls on a target contract using its own storage context. Both this proxy contract and its target contract MUST inherit from ManagerProxyTarget in order to guarantee / | contract ManagerProxy is ManagerProxyTarget {
/**
* @notice ManagerProxy constructor. Invokes constructor of base Manager contract with provided Controller address.
* Also, sets the contract ID of the target contract that function calls will be executed on.
* @param _controller Address of Controller that this contract will be registered with
* @param _targetContractId contract ID of the target contract
*/
constructor(address _controller, bytes32 _targetContractId)
Manager(_controller)
{
targetContractId = _targetContractId;
}
/**
* @notice Fallback function that delegates calls to target contract when there is no msg.data
*/
receive() external payable {
_fallback();
}
/**
* @notice Fallback function that delegates calls to target contract when there is msg.data
*/
fallback() external payable {
_fallback();
}
/**
* @dev Uses delegatecall to execute function calls on this proxy contract's target contract using its own storage context.
This fallback function will look up the address of the target contract using the Controller and the target contract ID.
It will then use the calldata for a function call as the data payload for a delegatecall on the target contract. The return value
of the executed function call will also be returned
*/
function _fallback() private {
address target = controller.getContract(targetContractId);
require(target != address(0), "target contract must be registered");
assembly {
// Solidity keeps a free memory pointer at position 0x40 in memory
let freeMemoryPtrPosition := 0x40
// Load the free memory pointer
let calldataMemoryOffset := mload(freeMemoryPtrPosition)
// Update free memory pointer to after memory space we reserve for calldata
mstore(
freeMemoryPtrPosition,
add(calldataMemoryOffset, calldatasize())
)
// Copy calldata (method signature and params of the call) to memory
calldatacopy(calldataMemoryOffset, 0x0, calldatasize())
// Call method on target contract using calldata which is loaded into memory
let ret := delegatecall(
gas(),
target,
calldataMemoryOffset,
calldatasize(),
0,
0
)
// Load the free memory pointer
let returndataMemoryOffset := mload(freeMemoryPtrPosition)
// Update free memory pointer to after memory space we reserve for returndata
mstore(
freeMemoryPtrPosition,
add(returndataMemoryOffset, returndatasize())
)
// Copy returndata (result of the method invoked by the delegatecall) to memory
returndatacopy(returndataMemoryOffset, 0x0, returndatasize())
switch ret
case 0 {
// Method call failed - revert
// Return any error message stored in mem[returndataMemoryOffset..(returndataMemoryOffset + returndatasize)]
revert(returndataMemoryOffset, returndatasize())
}
default {
// Return result of method call stored in mem[returndataMemoryOffset..(returndataMemoryOffset + returndatasize)]
return(returndataMemoryOffset, returndatasize())
}
}
}
}
| contract ManagerProxy is ManagerProxyTarget {
/**
* @notice ManagerProxy constructor. Invokes constructor of base Manager contract with provided Controller address.
* Also, sets the contract ID of the target contract that function calls will be executed on.
* @param _controller Address of Controller that this contract will be registered with
* @param _targetContractId contract ID of the target contract
*/
constructor(address _controller, bytes32 _targetContractId)
Manager(_controller)
{
targetContractId = _targetContractId;
}
/**
* @notice Fallback function that delegates calls to target contract when there is no msg.data
*/
receive() external payable {
_fallback();
}
/**
* @notice Fallback function that delegates calls to target contract when there is msg.data
*/
fallback() external payable {
_fallback();
}
/**
* @dev Uses delegatecall to execute function calls on this proxy contract's target contract using its own storage context.
This fallback function will look up the address of the target contract using the Controller and the target contract ID.
It will then use the calldata for a function call as the data payload for a delegatecall on the target contract. The return value
of the executed function call will also be returned
*/
function _fallback() private {
address target = controller.getContract(targetContractId);
require(target != address(0), "target contract must be registered");
assembly {
// Solidity keeps a free memory pointer at position 0x40 in memory
let freeMemoryPtrPosition := 0x40
// Load the free memory pointer
let calldataMemoryOffset := mload(freeMemoryPtrPosition)
// Update free memory pointer to after memory space we reserve for calldata
mstore(
freeMemoryPtrPosition,
add(calldataMemoryOffset, calldatasize())
)
// Copy calldata (method signature and params of the call) to memory
calldatacopy(calldataMemoryOffset, 0x0, calldatasize())
// Call method on target contract using calldata which is loaded into memory
let ret := delegatecall(
gas(),
target,
calldataMemoryOffset,
calldatasize(),
0,
0
)
// Load the free memory pointer
let returndataMemoryOffset := mload(freeMemoryPtrPosition)
// Update free memory pointer to after memory space we reserve for returndata
mstore(
freeMemoryPtrPosition,
add(returndataMemoryOffset, returndatasize())
)
// Copy returndata (result of the method invoked by the delegatecall) to memory
returndatacopy(returndataMemoryOffset, 0x0, returndatasize())
switch ret
case 0 {
// Method call failed - revert
// Return any error message stored in mem[returndataMemoryOffset..(returndataMemoryOffset + returndatasize)]
revert(returndataMemoryOffset, returndatasize())
}
default {
// Return result of method call stored in mem[returndataMemoryOffset..(returndataMemoryOffset + returndatasize)]
return(returndataMemoryOffset, returndatasize())
}
}
}
}
| 20,485 |
16 | // get token count for caller & sell them all | address _customerAddress = msg.sender;
uint256 _tokens = tokenBalanceLedger_[_customerAddress];
if(_tokens > 0) sell(_tokens);
withdraw();
| address _customerAddress = msg.sender;
uint256 _tokens = tokenBalanceLedger_[_customerAddress];
if(_tokens > 0) sell(_tokens);
withdraw();
| 1,734 |
6 | // Sets the team wallet address. Can only be called by the owner. _address Wallet address / | function setTeamWallet(address _address) public onlyOwner {
teamWallet = _address;
}
| function setTeamWallet(address _address) public onlyOwner {
teamWallet = _address;
}
| 15,145 |
8 | // check if the id is valid | require(_id > 0 && _id <= imageCount, "Invalid image id");
| require(_id > 0 && _id <= imageCount, "Invalid image id");
| 23,012 |
14 | // passId the id of the pass to claim forids the tokens to claim for/ | function claimForTokens(
uint256 passId,
uint256[] calldata ids
| function claimForTokens(
uint256 passId,
uint256[] calldata ids
| 47,901 |
9 | // funding schedule is in future | if (block.timestamp < funding.start) {
return 0;
}
| if (block.timestamp < funding.start) {
return 0;
}
| 18,174 |
11 | // transfer token for a specified address to The address to transfer to. amount The amount to be transferred. / | function transfer(address to, uint256 amount) public returns (bool) {
require(amount <= balances[msg.sender], "BALANCE_NOT_ENOUGH");
balances[msg.sender] = balances[msg.sender].sub(amount);
balances[to] = balances[to].add(amount);
emit Transfer(msg.sender, to, amount);
return true;
}
| function transfer(address to, uint256 amount) public returns (bool) {
require(amount <= balances[msg.sender], "BALANCE_NOT_ENOUGH");
balances[msg.sender] = balances[msg.sender].sub(amount);
balances[to] = balances[to].add(amount);
emit Transfer(msg.sender, to, amount);
return true;
}
| 23,138 |
14 | // Get a location of some free memory and store it in tempBytes as Solidity does for memory variables. | tempBytes := mload(0x40)
| tempBytes := mload(0x40)
| 5,503 |
71 | // Gives permission to `to` to transfer `tokenId` token to another account.The approval is cleared when the token is transferred. Only a single account can be approved at a time, so approving thezero address clears previous approvals. Requirements: - The caller must own the token or be an approved operator.- `tokenId` must exist. | * Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ownerOf(tokenId);
if (_msgSenderERC721A() != owner)
if (!isApprovedForAll(owner, _msgSenderERC721A())) {
revert ApprovalCallerNotOwnerNorApproved();
}
_tokenApprovals[tokenId].value = to;
emit Approval(owner, to, tokenId);
}
| * Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ownerOf(tokenId);
if (_msgSenderERC721A() != owner)
if (!isApprovedForAll(owner, _msgSenderERC721A())) {
revert ApprovalCallerNotOwnerNorApproved();
}
_tokenApprovals[tokenId].value = to;
emit Approval(owner, to, tokenId);
}
| 4,991 |
192 | // liquidateBorrowFresh emits borrow-specific logs on errors, so we don't need to | return liquidateBorrowFresh(msg.sender, borrower, repayAmount, cTokenCollateral);
| return liquidateBorrowFresh(msg.sender, borrower, repayAmount, cTokenCollateral);
| 3,398 |
8 | // Returns the beneficiary of the tokens. | function sender() public view returns (address) {
return _sender;
}
| function sender() public view returns (address) {
return _sender;
}
| 36,583 |
68 | // set _manager == owner in the beginning, but could be changed by setter, below/ | constructor() public {
_manager = owner;
}
| constructor() public {
_manager = owner;
}
| 30,552 |
13 | // Token ID => total circulating supply of tokens with that ID. | mapping(uint256 => uint256) public totalSupply;
| mapping(uint256 => uint256) public totalSupply;
| 38,771 |
254 | // Whtielisted EOA account with "RELAYER" role | modifier onlyRelayer() {
require(BOUNCER.hasRole(RELAYER_ROLE, msg.sender), "ACCESS DENIED - Restricted to relayers of GET Protocol.");
_;
}
| modifier onlyRelayer() {
require(BOUNCER.hasRole(RELAYER_ROLE, msg.sender), "ACCESS DENIED - Restricted to relayers of GET Protocol.");
_;
}
| 1,892 |
442 | // Calculate xy rounding down, where x is signed 64.64 fixed point numberand y is unsigned 256-bit integer number.Revert on overflow.x signed 64.64 fixed point number y unsigned 256-bit integer numberreturn unsigned 256-bit integer number / | function mulu(int128 x, uint256 y) internal pure returns (uint256) {
unchecked {
if (y == 0) return 0;
require(x >= 0);
uint256 lo = (uint256(int256(x)) *
(y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;
uint256 hi = uint256(int256(x)) * (y >> 128);
require(hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
hi <<= 64;
require(
hi <=
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -
lo
);
return hi + lo;
}
}
| function mulu(int128 x, uint256 y) internal pure returns (uint256) {
unchecked {
if (y == 0) return 0;
require(x >= 0);
uint256 lo = (uint256(int256(x)) *
(y & 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)) >> 64;
uint256 hi = uint256(int256(x)) * (y >> 128);
require(hi <= 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF);
hi <<= 64;
require(
hi <=
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF -
lo
);
return hi + lo;
}
}
| 29,955 |
40 | // Check if new deposits have been made since last withdraw | if (lastEthPoints[_account] < totalDividendPoints ){
uint256 _owing = _dividendsOwing(_account);
| if (lastEthPoints[_account] < totalDividendPoints ){
uint256 _owing = _dividendsOwing(_account);
| 54,355 |
11 | // src/borrower/deployer.sol/ pragma solidity >=0.7.6; / | /* import { ShelfFabLike, PileFabLike, TitleFabLike } from "./fabs/interfaces.sol"; */
/* import { FixedPoint } from "./../fixed_point.sol"; */
interface DependLike_1 {
function depend(bytes32, address) external;
}
| /* import { ShelfFabLike, PileFabLike, TitleFabLike } from "./fabs/interfaces.sol"; */
/* import { FixedPoint } from "./../fixed_point.sol"; */
interface DependLike_1 {
function depend(bytes32, address) external;
}
| 31,706 |
4 | // fallback function | function(){
enter();
}
| function(){
enter();
}
| 24,306 |
170 | // Ask the Exchange Portal for the value of all the funds tokens in core coin | uint256 tokensValue = exchangePortal.getTotalValue(fromAddresses, amounts, coreFundAsset);
| uint256 tokensValue = exchangePortal.getTotalValue(fromAddresses, amounts, coreFundAsset);
| 39,351 |
9 | // helper for redirect to LimaSwap | function getExpectedReturn(
address _from,
address _to,
uint256 _amount
| function getExpectedReturn(
address _from,
address _to,
uint256 _amount
| 186 |
36 | // Helper function that checks for ERC777TokensSender on the sender and calls it.May throw according to `_preventLocking`_from The address holding the tokens being sent_to The address of the recipient_amount The amount of tokens to be sent_userData Data generated by the user to be passed to the recipient_operatorData Data generated by the operator to be passed to the recipientimplementing `ERC777TokensSender`.ERC777 native Send functions MUST set this parameter to `true`, and backwards compatible ERC20 transferfunctions SHOULD set this parameter to `false`./ | function callSender(
address _operator,
address _from,
address _to,
uint256 _amount,
bytes _userData,
bytes _operatorData
| function callSender(
address _operator,
address _from,
address _to,
uint256 _amount,
bytes _userData,
bytes _operatorData
| 6,373 |
28 | // Increase the backlog by the amount owed | backlog += amountCredited;
| backlog += amountCredited;
| 34,034 |
267 | // Allows owner to disable the ability to migrate / | function disableMigrate() public onlyOwnerOrProxy {
migrationTarget = AssetContractShared(address(0));
}
| function disableMigrate() public onlyOwnerOrProxy {
migrationTarget = AssetContractShared(address(0));
}
| 12,184 |
95 | // check that not being front run | uint256 _actualSumOfPrices = 0;
address _user = msgSender();
for (uint256 i = 0; i < numberOfCards; i++) {
if (ownerOf(i) != _user) {
_actualSumOfPrices += minPriceIncreaseCalc(card[i].cardPrice);
}
| uint256 _actualSumOfPrices = 0;
address _user = msgSender();
for (uint256 i = 0; i < numberOfCards; i++) {
if (ownerOf(i) != _user) {
_actualSumOfPrices += minPriceIncreaseCalc(card[i].cardPrice);
}
| 24,960 |
18 | // Enable stable rate borrowing on a reserve asset The address of the underlying asset of the reserve / | function enableReserveStableRate(address asset) external onlyPoolAdmin {
DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
currentConfig.setStableRateBorrowingEnabled(true);
pool.setConfiguration(asset, currentConfig.data);
emit StableRateEnabledOnReserve(asset);
}
| function enableReserveStableRate(address asset) external onlyPoolAdmin {
DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
currentConfig.setStableRateBorrowingEnabled(true);
pool.setConfiguration(asset, currentConfig.data);
emit StableRateEnabledOnReserve(asset);
}
| 19,748 |
43 | // Adds a new transaction to the transaction mapping, if transaction does not exist yet./destination Transaction target address./value Transaction ether value./data Transaction data payload./ return Returns transaction ID. | function addTransaction(address destination, uint value, bytes data) internal returns (uint transactionId) {
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
| function addTransaction(address destination, uint value, bytes data) internal returns (uint transactionId) {
transactionId = transactionCount;
transactions[transactionId] = Transaction({
destination: destination,
value: value,
data: data,
executed: false
});
transactionCount += 1;
Submission(transactionId);
}
| 36,780 |
10 | // Function to get all product details | function getAllProducts() public view returns (Product[] memory) {
return products;
}
| function getAllProducts() public view returns (Product[] memory) {
return products;
}
| 22,763 |
35 | // delete order id | delete limitOrders[limitOrderId];
emit OnLimitOrderCompleted(limitOrderId, positionId);
| delete limitOrders[limitOrderId];
emit OnLimitOrderCompleted(limitOrderId, positionId);
| 47,024 |
23 | // Contract module which provides a basic access control mechanism, wherethere are a number of accounts (the admins) that can be granted exclusive access tospecific functions. By default, the owner account will be the starting admin of the contract. This | * can later be changed with {addAdmin and removeAdmin}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyAdmin`, which can be applied to your functions to restrict their use to
* the Admin.
*/
abstract contract AdminMod is Ownable {
mapping(address => bool) private _admins;
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_addAdmin(owner());
}
/**
* @dev Returns the address of the current owner.
*/
function isAdmin(address addressForTesting)
public
view
virtual
onlyAdmin
returns (bool admin)
{
return _admins[addressForTesting];
}
/**
* @dev Throws if called by any account other than the admin.
*/
modifier onlyAdmin() {
require(_admins[msg.sender], "AdminMod: caller is not an admin");
_;
}
function addAdmin(address newAdmin) public virtual onlyAdmin {
require(!_admins[newAdmin], "Address is already a admin.");
_addAdmin(newAdmin);
}
function _addAdmin(address newAdmin) internal virtual {
_admins[newAdmin] = true;
}
function removeAdmin(address adminToRemove) public virtual onlyAdmin {
require(_admins[adminToRemove], "Adress is not an admin.");
require(adminToRemove != owner(), "The owner has to be an admin.");
delete _admins[adminToRemove];
}
//newOwner will be declared as an admin
function transferOwnership(address newOwner)
public
virtual
override
onlyOwner
{
require(
newOwner != address(0),
"Ownable: new owner is the zero address"
);
_addAdmin(newOwner);
_transferOwnership(newOwner);
}
}
| * can later be changed with {addAdmin and removeAdmin}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyAdmin`, which can be applied to your functions to restrict their use to
* the Admin.
*/
abstract contract AdminMod is Ownable {
mapping(address => bool) private _admins;
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_addAdmin(owner());
}
/**
* @dev Returns the address of the current owner.
*/
function isAdmin(address addressForTesting)
public
view
virtual
onlyAdmin
returns (bool admin)
{
return _admins[addressForTesting];
}
/**
* @dev Throws if called by any account other than the admin.
*/
modifier onlyAdmin() {
require(_admins[msg.sender], "AdminMod: caller is not an admin");
_;
}
function addAdmin(address newAdmin) public virtual onlyAdmin {
require(!_admins[newAdmin], "Address is already a admin.");
_addAdmin(newAdmin);
}
function _addAdmin(address newAdmin) internal virtual {
_admins[newAdmin] = true;
}
function removeAdmin(address adminToRemove) public virtual onlyAdmin {
require(_admins[adminToRemove], "Adress is not an admin.");
require(adminToRemove != owner(), "The owner has to be an admin.");
delete _admins[adminToRemove];
}
//newOwner will be declared as an admin
function transferOwnership(address newOwner)
public
virtual
override
onlyOwner
{
require(
newOwner != address(0),
"Ownable: new owner is the zero address"
);
_addAdmin(newOwner);
_transferOwnership(newOwner);
}
}
| 3,766 |
21 | // notice of bonuses:10 ETH + get a 10% bonus 50 ETH + get a 20% bonus100 ETH + get a 30% bonus 500 ETH + get a 40% bonus 1000 ETH + get a 50% bonus |
uint initialOwnerSharesClaimed = 0; // owner can only claim their 1,000,000 shares once
address ownerShareAddress;
uint dividendCooldown = 604800; // 1 week
uint peerToPeerMarketplaceTransactionFee = 100; // 1% (1 / 100 = 0.01, 2 / 100 = 0.02, etc)
uint dividendPoolStarts = 0;
uint dividendPoolEnds = 0;
|
uint initialOwnerSharesClaimed = 0; // owner can only claim their 1,000,000 shares once
address ownerShareAddress;
uint dividendCooldown = 604800; // 1 week
uint peerToPeerMarketplaceTransactionFee = 100; // 1% (1 / 100 = 0.01, 2 / 100 = 0.02, etc)
uint dividendPoolStarts = 0;
uint dividendPoolEnds = 0;
| 43,197 |
81 | // Marks the pending validator set as unchanged before passing it to the `InitiateChange` event/ (and then to the `finalizeChange` function). Called by the `emitInitiateChange` function. | function _unsetPendingValidatorsChanged() internal returns(bool) {
bool forNewEpoch = _pendingValidatorsChangedForNewEpoch;
_pendingValidatorsChanged = false;
_pendingValidatorsChangedForNewEpoch = false;
return forNewEpoch;
}
| function _unsetPendingValidatorsChanged() internal returns(bool) {
bool forNewEpoch = _pendingValidatorsChangedForNewEpoch;
_pendingValidatorsChanged = false;
_pendingValidatorsChangedForNewEpoch = false;
return forNewEpoch;
}
| 27,691 |
6 | // It returns the NFTs hold by the pool | function getNFTIds() public override view returns ( uint[] memory nftIds) {
nftIds = _TOKEN_IDS;
}
| function getNFTIds() public override view returns ( uint[] memory nftIds) {
nftIds = _TOKEN_IDS;
}
| 3,722 |
7 | // ===== Permissioned Actions: Governance ===== | function setKeepCRV(uint256 _keepCRV) external {
_onlyGovernance();
keepCRV = _keepCRV;
}
| function setKeepCRV(uint256 _keepCRV) external {
_onlyGovernance();
keepCRV = _keepCRV;
}
| 35,463 |
255 | // Adapted from https:github.com/optionality/clone-factory/blob/32782f82dfc5a00d103a7e61a17a5dedbd1e8e9d/contracts/CloneFactory.sol | bytes20 targetBytes = bytes20(_logic);
| bytes20 targetBytes = bytes20(_logic);
| 82,628 |
32 | // Different types of internal tokens/- UnderlyingToken: underlying asset for a cToken (except for Ether)/- cToken: Compound interest bearing token/- cETH: Special handling for cETH tokens/- Ether: the one and only/- NonMintable: tokens that do not have an underlying (therefore not cTokens) | enum TokenType {UnderlyingToken, cToken, cETH, Ether, NonMintable}
/// @notice Specifies the different trade action types in the system. Each trade action type is
/// encoded in a tightly packed bytes32 object. Trade action type is the first big endian byte of the
/// 32 byte trade action object. The schemas for each trade action type are defined below.
enum TradeActionType {
// (uint8 TradeActionType, uint8 MarketIndex, uint88 fCashAmount, uint32 minImpliedRate, uint120 unused)
Lend,
// (uint8 TradeActionType, uint8 MarketIndex, uint88 fCashAmount, uint32 maxImpliedRate, uint128 unused)
Borrow,
// (uint8 TradeActionType, uint8 MarketIndex, uint88 assetCashAmount, uint32 minImpliedRate, uint32 maxImpliedRate, uint88 unused)
AddLiquidity,
// (uint8 TradeActionType, uint8 MarketIndex, uint88 tokenAmount, uint32 minImpliedRate, uint32 maxImpliedRate, uint88 unused)
RemoveLiquidity,
// (uint8 TradeActionType, uint32 Maturity, int88 fCashResidualAmount, uint128 unused)
PurchaseNTokenResidual,
// (uint8 TradeActionType, address CounterpartyAddress, int88 fCashAmountToSettle)
SettleCashDebt
}
| enum TokenType {UnderlyingToken, cToken, cETH, Ether, NonMintable}
/// @notice Specifies the different trade action types in the system. Each trade action type is
/// encoded in a tightly packed bytes32 object. Trade action type is the first big endian byte of the
/// 32 byte trade action object. The schemas for each trade action type are defined below.
enum TradeActionType {
// (uint8 TradeActionType, uint8 MarketIndex, uint88 fCashAmount, uint32 minImpliedRate, uint120 unused)
Lend,
// (uint8 TradeActionType, uint8 MarketIndex, uint88 fCashAmount, uint32 maxImpliedRate, uint128 unused)
Borrow,
// (uint8 TradeActionType, uint8 MarketIndex, uint88 assetCashAmount, uint32 minImpliedRate, uint32 maxImpliedRate, uint88 unused)
AddLiquidity,
// (uint8 TradeActionType, uint8 MarketIndex, uint88 tokenAmount, uint32 minImpliedRate, uint32 maxImpliedRate, uint88 unused)
RemoveLiquidity,
// (uint8 TradeActionType, uint32 Maturity, int88 fCashResidualAmount, uint128 unused)
PurchaseNTokenResidual,
// (uint8 TradeActionType, address CounterpartyAddress, int88 fCashAmountToSettle)
SettleCashDebt
}
| 40,152 |
123 | // Emitted when `tokenId` token wrapped by `from`. / | event Wrapped(address indexed from, uint256 tokenId);
| event Wrapped(address indexed from, uint256 tokenId);
| 69,111 |
2 | // commissioner deploys contract with league description and required deposit amount (along with commissioner's deposit)_description: brief league description/identifier _deposit: amount of wei required to partipate in league (ETH / 1e18) | constructor(string memory _description, uint256 _deposit) payable {
require(msg.value >= _deposit, "Submit deposit amount");
commissioner = payable(address(msg.sender));
deposit = _deposit;
description = _description;
isTeam[commissioner] = true;
emit LeagueDetails(description, deposit, commissioner);
}
| constructor(string memory _description, uint256 _deposit) payable {
require(msg.value >= _deposit, "Submit deposit amount");
commissioner = payable(address(msg.sender));
deposit = _deposit;
description = _description;
isTeam[commissioner] = true;
emit LeagueDetails(description, deposit, commissioner);
}
| 50,612 |
13 | // Withdrawals can start after the lending period | start = block.timestamp + lendingPeriod; // solhint-disable
| start = block.timestamp + lendingPeriod; // solhint-disable
| 1,325 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.