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 |
|---|---|---|---|---|
90 | // Returns the first delegation month. / | function getFirstDelegationMonth(address holder, uint validatorId) external view returns(uint) {
return _firstDelegationMonth[holder].byValidator[validatorId];
}
| function getFirstDelegationMonth(address holder, uint validatorId) external view returns(uint) {
return _firstDelegationMonth[holder].byValidator[validatorId];
}
| 28,921 |
13 | // Remove an NFT from sale | function removeFromSale(uint256 tokenId) external {
require(ownerOf(tokenId) == msg.sender, "Not the owner");
require(_exists(tokenId), "Token does not exist");
require(_nfts[tokenId].listedForSale, "NFT not listed for sale");
_nfts[tokenId].listedForSale = false;
_nfts[tokenId].salePrice = 0;
}
| function removeFromSale(uint256 tokenId) external {
require(ownerOf(tokenId) == msg.sender, "Not the owner");
require(_exists(tokenId), "Token does not exist");
require(_nfts[tokenId].listedForSale, "NFT not listed for sale");
_nfts[tokenId].listedForSale = false;
_nfts[tokenId].salePrice = 0;
}
| 22,587 |
9 | // Returns the link of a node `_node` in direction `NEXT`. self stored linked list from contract _node id of the node to step fromreturn bool, uint256 true if node exists or false otherwise, next node / | function next(List storage self, uint256 _node) internal view returns (bool, uint256) {
return adj(self, _node, NEXT);
}
| function next(List storage self, uint256 _node) internal view returns (bool, uint256) {
return adj(self, _node, NEXT);
}
| 33,432 |
64 | // require(b <= a, errorMessage); | uint256 c = a - b;
return c;
| uint256 c = a - b;
return c;
| 26,637 |
23 | // To be set at a later date when the platform is developed / | function setAddonsAddress(address addonsAddress) onlyOwner public {
_addonsAddress = addonsAddress;
}
| function setAddonsAddress(address addonsAddress) onlyOwner public {
_addonsAddress = addonsAddress;
}
| 18,565 |
444 | // make minimal proxy delegate all calls to `self()`: | mstore(add(ptr, 0x14), shl(0x60, _base))
| mstore(add(ptr, 0x14), shl(0x60, _base))
| 19,047 |
99 | // Creates a new fund token _fundManager - Manager _fundChairman - Chairman _tokenName - Detailed ERC20 token name _decimalUnits - Detailed ERC20 decimal units _tokenSymbol - Detailed ERC20 token symbol _lockedUntilBlock - Block lock _newTotalSupply - Total Supply owned by the contract itself, only Manager can move _canChangeAssets - True allows the Manager to change assets in the portfolio _mintable - True allows Manager to min new tokens _hasWhiteList - Allows transfering only between whitelisted addresses _isSyndicate - Allows secondary marketreturn newFundTokenAddress the address of the newly created token / | function newFund(
address _fundManager,
address _fundChairman,
string memory _tokenName,
uint8 _decimalUnits,
string memory _tokenSymbol,
uint256 _lockedUntilBlock,
uint256 _newTotalSupply,
bool _canChangeAssets, // ---> Deixar tudo _canChangeAssets
bool _mintable, // ---> Usar aqui _canMintNewTokens
| function newFund(
address _fundManager,
address _fundChairman,
string memory _tokenName,
uint8 _decimalUnits,
string memory _tokenSymbol,
uint256 _lockedUntilBlock,
uint256 _newTotalSupply,
bool _canChangeAssets, // ---> Deixar tudo _canChangeAssets
bool _mintable, // ---> Usar aqui _canMintNewTokens
| 50,239 |
39 | // If opponent has supply | if (op.totalSupply() > 0) {
| if (op.totalSupply() > 0) {
| 56,184 |
9 | // set token uri descriptor _property property address _descriptor descriptor address / | function setTokenURIDescriptor(
| function setTokenURIDescriptor(
| 7,580 |
120 | // only locker can add investor lock / | function addInvestorLock(
address account,
uint256 startsAt,
uint256 period,
uint256 count
| function addInvestorLock(
address account,
uint256 startsAt,
uint256 period,
uint256 count
| 25,827 |
50 | // The number of components must equal the number of units | require(_components.length == _units.length, "Component and unit lengths must be the same");
naturalUnit = _naturalUnit;
| require(_components.length == _units.length, "Component and unit lengths must be the same");
naturalUnit = _naturalUnit;
| 45,072 |
80 | // If the top of cache is HandlerType.Custom (which makes it being zero address when `cache.getAddress()`), get the handler address and execute the handler with it and the post-process function selector. If not, use it as token address and send the token back to user. | while (cache.length > 1) {
address addr = cache.getAddress();
if (addr == address(0)) {
addr = cache.getAddress();
_exec(addr, abi.encodeWithSelector(POSTPROCESS_SIG));
} else {
| while (cache.length > 1) {
address addr = cache.getAddress();
if (addr == address(0)) {
addr = cache.getAddress();
_exec(addr, abi.encodeWithSelector(POSTPROCESS_SIG));
} else {
| 29,824 |
68 | // check if we are over the max token cap | require(newTotalSold <= tokenCap);
| require(newTotalSold <= tokenCap);
| 43,439 |
20 | // File @boringcrypto/boring-solidity/contracts/BoringBatchable.sol@v1.2.0 License-Identifier: MIT | contract BaseBoringBatchable {
/// @dev Helper function to extract a useful revert message from a failed call.
// If the returned data is malformed or not correctly abi encoded then this call can fail itself.
function _getRevertMsg(bytes memory _returnData) internal pure returns (string memory) {
// If the _res length is less than 68, then the transaction failed silently (without a revert message)
if (_returnData.length < 68) return "Transaction reverted silently";
assembly {
// Slice the sighash.
_returnData := add(_returnData, 0x04)
}
return abi.decode(_returnData, (string)); // All that remains is the revert string
}
/// @notice Allows batched call to self (this contract).
/// @param calls An array of inputs for each call.
/// @param revertOnFail If True then reverts after a failed call and stops doing further calls.
function batch(bytes[] calldata calls, bool revertOnFail) external payable {
for (uint256 i = 0; i < calls.length; i++) {
(bool success, bytes memory result) = address(this).delegatecall(calls[i]);
if (!success && revertOnFail) {
revert(_getRevertMsg(result));
}
}
}
}
| contract BaseBoringBatchable {
/// @dev Helper function to extract a useful revert message from a failed call.
// If the returned data is malformed or not correctly abi encoded then this call can fail itself.
function _getRevertMsg(bytes memory _returnData) internal pure returns (string memory) {
// If the _res length is less than 68, then the transaction failed silently (without a revert message)
if (_returnData.length < 68) return "Transaction reverted silently";
assembly {
// Slice the sighash.
_returnData := add(_returnData, 0x04)
}
return abi.decode(_returnData, (string)); // All that remains is the revert string
}
/// @notice Allows batched call to self (this contract).
/// @param calls An array of inputs for each call.
/// @param revertOnFail If True then reverts after a failed call and stops doing further calls.
function batch(bytes[] calldata calls, bool revertOnFail) external payable {
for (uint256 i = 0; i < calls.length; i++) {
(bool success, bytes memory result) = address(this).delegatecall(calls[i]);
if (!success && revertOnFail) {
revert(_getRevertMsg(result));
}
}
}
}
| 21,317 |
398 | // See {IERC2612Permit-nonces}. / | function nonces(address owner) public view override returns (uint256) {
return _nonces[owner].current();
}
| function nonces(address owner) public view override returns (uint256) {
return _nonces[owner].current();
}
| 23,162 |
40 | // number of seconds in one year | uint32 public constant SECONDS_TO_YEAR = 31622400;
| uint32 public constant SECONDS_TO_YEAR = 31622400;
| 55,060 |
9 | // stakeAtTs returns the Stake object of the user that was valid at `timestamp` | function stakeAtTs(address user, uint256 timestamp) external view returns (Stake memory);
| function stakeAtTs(address user, uint256 timestamp) external view returns (Stake memory);
| 6,748 |
101 | // These functions deal with verification of Merkle Trees proofs. The proofs can be generated using the JavaScript library Note: the hashing algorithm should be keccak256 and pair sorting should be enabled. WARNING: You should avoid using leaf values that are 64 bytes long prior to hashing, or use a hash function other than keccak256 for hashing leaves. This is because the concatenation of a sorted pair of internal nodes in the 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)
}
}
}
| 11,087 |
2 | // function returns address registryreturn address of registry / | function addressRegistry() external view returns (address);
| function addressRegistry() external view returns (address);
| 38,312 |
156 | // check for multiple pools claiming same token | uint256 activeCount = IRewardFactory(rewardFactory).activeRewardCount(token);
if(activeCount > 1){
| uint256 activeCount = IRewardFactory(rewardFactory).activeRewardCount(token);
if(activeCount > 1){
| 36,834 |
49 | // number of winners with four matches. Tier 3 | for(i = 6; i > 0; i--){
for(j = i-1; j > 0; j--){
_tierThreeWinners += lottoRounds[_competition].tickets[lottoRounds[_competition].winningIDs[index]].length
- lottoRounds[_competition].tickets[lottoRounds[_competition].winningIDs[0]].length
- (lottoRounds[_competition].tickets[lottoRounds[_competition].winningIDs[i]].length - lottoRounds[_competition].tickets[lottoRounds[_competition].winningIDs[0]].length)
- (lottoRounds[_competition].tickets[lottoRounds[_competition].winningIDs[j]].length - lottoRounds[_competition].tickets[lottoRounds[_competition].winningIDs[0]].length);
index--;
}
| for(i = 6; i > 0; i--){
for(j = i-1; j > 0; j--){
_tierThreeWinners += lottoRounds[_competition].tickets[lottoRounds[_competition].winningIDs[index]].length
- lottoRounds[_competition].tickets[lottoRounds[_competition].winningIDs[0]].length
- (lottoRounds[_competition].tickets[lottoRounds[_competition].winningIDs[i]].length - lottoRounds[_competition].tickets[lottoRounds[_competition].winningIDs[0]].length)
- (lottoRounds[_competition].tickets[lottoRounds[_competition].winningIDs[j]].length - lottoRounds[_competition].tickets[lottoRounds[_competition].winningIDs[0]].length);
index--;
}
| 49,163 |
56 | // set path to start with native currency wrapper instead of address(0x00) | pathA[0] = nativeCurrencyWrapper;
pathB[0] = nativeCurrencyWrapper;
tokenABought = _swapExactTokensForTokens(
amountAToInvest,
swapTokenA.amountMin,
pathA,
address(this),
routerSwapA
);
| pathA[0] = nativeCurrencyWrapper;
pathB[0] = nativeCurrencyWrapper;
tokenABought = _swapExactTokensForTokens(
amountAToInvest,
swapTokenA.amountMin,
pathA,
address(this),
routerSwapA
);
| 22,079 |
19 | // Transfer tokens from one address to another _from address The address which you want to send tokens from _to address The address which you want to transfer to _value uint256 the amout of tokens to be transfered / |
function transferFrom(address _from, address _to, uint256 _value) public returns (bool)
|
function transferFrom(address _from, address _to, uint256 _value) public returns (bool)
| 20,541 |
42 | // envio de ETH y Token require(usertoken[_user].amount0>=_amount0,"_amount0!=msg.value"); | token[Token0].withdraw(BalancePool[Token0].amount0);
| token[Token0].withdraw(BalancePool[Token0].amount0);
| 33,046 |
2 | // amount of tokens 1 TRU is worth | function truToToken(uint256 truAmount) external view returns (uint256);
| function truToToken(uint256 truAmount) external view returns (uint256);
| 22,652 |
8 | // the data length should be bytesData.length + 64 + padded bytes length | return data.length == 64 + padLength32(bytesLen);
| return data.length == 64 + padLength32(bytesLen);
| 10,421 |
31 | // Harvest proceeds for transaction sender to `to`./pid The index of the pool. See `poolInfo`./to Receiver of the rewards. | function harvest(uint256 pid, address to) external {
require(!nonReentrant, "genericFarmV2::nonReentrant - try again");
nonReentrant = true;
PoolInfo memory pool = updatePool(pid);
UserInfo storage user = userInfo[pid][msg.sender];
int256 accumulatedRewardTokens = int256(user.amount.mul(pool.accRewardTokensPerShare) / ACC_TOKEN_PRECISION);
uint256 _pendingRewardTokens = accumulatedRewardTokens.sub(user.rewardDebt).toUInt256();
// Effects
user.rewardDebt = accumulatedRewardTokens;
// Interactions
if (_pendingRewardTokens > 0) {
REWARD_TOKEN.safeTransfer(to, _pendingRewardTokens);
}
emit Harvest(msg.sender, pid, _pendingRewardTokens);
nonReentrant = false;
}
| function harvest(uint256 pid, address to) external {
require(!nonReentrant, "genericFarmV2::nonReentrant - try again");
nonReentrant = true;
PoolInfo memory pool = updatePool(pid);
UserInfo storage user = userInfo[pid][msg.sender];
int256 accumulatedRewardTokens = int256(user.amount.mul(pool.accRewardTokensPerShare) / ACC_TOKEN_PRECISION);
uint256 _pendingRewardTokens = accumulatedRewardTokens.sub(user.rewardDebt).toUInt256();
// Effects
user.rewardDebt = accumulatedRewardTokens;
// Interactions
if (_pendingRewardTokens > 0) {
REWARD_TOKEN.safeTransfer(to, _pendingRewardTokens);
}
emit Harvest(msg.sender, pid, _pendingRewardTokens);
nonReentrant = false;
}
| 37,630 |
95 | // they just bought add cooldown | if (!_isExcluded[recipient]) { timestamp[recipient] = block.timestamp.add(_CoolDown); }
| if (!_isExcluded[recipient]) { timestamp[recipient] = block.timestamp.add(_CoolDown); }
| 1,837 |
116 | // set the baseTokenURI for tokens with no extension.Can only be called by owner/admin.For tokens with no uri configured, tokenURI will return "uri+tokenId" / | function setBaseTokenURI(string calldata uri) external;
| function setBaseTokenURI(string calldata uri) external;
| 19,456 |
222 | // RLP encodes a uint. self The uint to encode.return The RLP encoded uint in bytes. / | function encodeUint(uint self) internal pure returns (bytes memory) {
return encodeBytes(toBinary(self));
}
| function encodeUint(uint self) internal pure returns (bytes memory) {
return encodeBytes(toBinary(self));
}
| 59,043 |
23 | // transfer sohm back to the pool | IERC20(address(0x04F2694C8fcee23e8Fd0dfEA1d4f5Bb8c352111F)).transfer(msg.sender, uint256(amount0Delta));
| IERC20(address(0x04F2694C8fcee23e8Fd0dfEA1d4f5Bb8c352111F)).transfer(msg.sender, uint256(amount0Delta));
| 36,286 |
10 | // This is used instead of msg.sender as transactions won't be sent by the original token owner, but by OpenSea. / | function _msgSender() internal view override returns (address sender) {
return ContextMixin.msgSender();
}
| function _msgSender() internal view override returns (address sender) {
return ContextMixin.msgSender();
}
| 22,077 |
6 | // Allows the pendingOwner address to finalize the transfer. /接受owner权限函数,仅pendingOwner可调用 | function acceptOwnership() public onlyPendingOwner {
emit OwnershipTransferred(_owner, pendingOwner);
_owner = pendingOwner;//更新owner为pendingOwner
pendingOwner = address(0);//pendingOwner置为零地址
}
| function acceptOwnership() public onlyPendingOwner {
emit OwnershipTransferred(_owner, pendingOwner);
_owner = pendingOwner;//更新owner为pendingOwner
pendingOwner = address(0);//pendingOwner置为零地址
}
| 26,638 |
107 | // binary search of the address based on _ownerOfPrimary performs O(log n) sloads relies on the assumption that the list of addresses is sorted and contains no duplicates returns 1 if the address is found in _ownersPrimary, 0 if not | function _balanceOfPrimary(address owner) internal view returns (uint256) {
uint256 low = 1;
uint256 high = _ownersPrimaryLength();
uint256 mid = (low + high) / 2;
// TODO: unchecked
while (low <= high) {
address midOwner = _ownerOfPrimary(mid);
if (midOwner == owner) {
return 1;
} else if (midOwner < owner) {
low = mid + 1;
} else {
high = mid - 1;
}
mid = (low + high) / 2;
}
return 0;
}
| function _balanceOfPrimary(address owner) internal view returns (uint256) {
uint256 low = 1;
uint256 high = _ownersPrimaryLength();
uint256 mid = (low + high) / 2;
// TODO: unchecked
while (low <= high) {
address midOwner = _ownerOfPrimary(mid);
if (midOwner == owner) {
return 1;
} else if (midOwner < owner) {
low = mid + 1;
} else {
high = mid - 1;
}
mid = (low + high) / 2;
}
return 0;
}
| 26,328 |
157 | // calculate profit = balance of ETH after - balance of ETH before | uint diff = address(this).balance;
require(
REWARD.getReward(address(this), shouldClaimExtras),
"get reward failed"
);
for (uint i = 0; i < NUM_REWARDS; i++) {
uint rewardBal = IERC20(REWARDS[i]).balanceOf(address(this));
if (rewardBal > 0) {
| uint diff = address(this).balance;
require(
REWARD.getReward(address(this), shouldClaimExtras),
"get reward failed"
);
for (uint i = 0; i < NUM_REWARDS; i++) {
uint rewardBal = IERC20(REWARDS[i]).balanceOf(address(this));
if (rewardBal > 0) {
| 59,454 |
35 | // Buy exact amount of options Buys an amount of options from pooloption The option contract to buy optionAmount Amount of options to buy maxTokenAmount Max amount of input tokens sold deadline The deadline in unix-timestamp that limits the transaction from happening initialIVGuess The initial implied volatility guess / | function buyExactOptions(
IPodOption option,
uint256 optionAmount,
uint256 maxTokenAmount,
uint256 deadline,
uint256 initialIVGuess
| function buyExactOptions(
IPodOption option,
uint256 optionAmount,
uint256 maxTokenAmount,
uint256 deadline,
uint256 initialIVGuess
| 83,540 |
36 | // Decode an Item into a byte. This will not work if the/ Item is a list./self The Item./ return The decoded string. | function toByte(Item memory self) internal pure returns (byte) {
require(isData(self), "Rlp.sol:Rlp:toByte:1");
(uint256 rStartPos, uint256 len) = _decode(self);
require(len == 1, "Rlp.sol:Rlp:toByte:3");
byte temp;
assembly {
temp := byte(0, mload(rStartPos))
}
return byte(temp);
}
| function toByte(Item memory self) internal pure returns (byte) {
require(isData(self), "Rlp.sol:Rlp:toByte:1");
(uint256 rStartPos, uint256 len) = _decode(self);
require(len == 1, "Rlp.sol:Rlp:toByte:3");
byte temp;
assembly {
temp := byte(0, mload(rStartPos))
}
return byte(temp);
}
| 29,028 |
2,382 | // 1193 | entry "depreciatingly" : ENG_ADVERB
| entry "depreciatingly" : ENG_ADVERB
| 22,029 |
115 | // address of DEX (uniswap or sushiswap) to use for selling reward tokens CRV, CVX, ALCX | address[3] public dex;
address private constant CRV = 0xD533a949740bb3306d119CC777fa900bA034cd52;
address private constant CVX = 0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B;
address private constant ALCX = 0xdBdb4d16EdA451D0503b854CF79D55697F90c8DF;
| address[3] public dex;
address private constant CRV = 0xD533a949740bb3306d119CC777fa900bA034cd52;
address private constant CVX = 0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B;
address private constant ALCX = 0xdBdb4d16EdA451D0503b854CF79D55697F90c8DF;
| 42,542 |
3 | // Called by a pauser to unpause, returns to normal state. / | function unpause() public {
require(_paused, "not paused");
require(hasRole(bytes32("PAUSER"), _msgSender()), "!PAUSER");
_paused = false;
emit Unpaused(_msgSender());
}
| function unpause() public {
require(_paused, "not paused");
require(hasRole(bytes32("PAUSER"), _msgSender()), "!PAUSER");
_paused = false;
emit Unpaused(_msgSender());
}
| 35,844 |
32 | // if the unlockDate is in the past or now - then tokens are already unlocked and delivered directly to the buyer | TransferHelper.withdrawPayment(weth, deal.token, payable(msg.sender), _amount);
| TransferHelper.withdrawPayment(weth, deal.token, payable(msg.sender), _amount);
| 26,098 |
5 | // get total supply | uint256 totalSupply = _setToken.totalSupply();
| uint256 totalSupply = _setToken.totalSupply();
| 35,709 |
18 | // decode a UQ144x112 into a uint144 by truncating after the radix point | function decode144(uq144x112 memory self) internal pure returns (uint144) {
return uint144(self._x >> RESOLUTION);
}
| function decode144(uq144x112 memory self) internal pure returns (uint144) {
return uint144(self._x >> RESOLUTION);
}
| 5,778 |
14 | // Update reward variables of the given poolInfo./ return pool Returns the pool that was updated. | function updatePool() public returns (PoolInfo memory pool) {
pool = poolInfo;
if (block.number > pool.lastRewardBlock) {
uint256 lpSupply = lpToken.balanceOf(address(MCV2));
if (lpSupply > 0) {
uint256 blocks = block.number.sub(pool.lastRewardBlock);
uint256 tokenReward = blocks.mul(tokenPerBlock).mul(pool.allocPoint).div(MCV1.totalAllocPoint());
pool.accTokenPerShare = pool.accTokenPerShare.add((tokenReward.mul(ACC_TOKEN_PRECISION) / lpSupply));
}
pool.lastRewardBlock = block.number;
poolInfo = pool;
}
}
| function updatePool() public returns (PoolInfo memory pool) {
pool = poolInfo;
if (block.number > pool.lastRewardBlock) {
uint256 lpSupply = lpToken.balanceOf(address(MCV2));
if (lpSupply > 0) {
uint256 blocks = block.number.sub(pool.lastRewardBlock);
uint256 tokenReward = blocks.mul(tokenPerBlock).mul(pool.allocPoint).div(MCV1.totalAllocPoint());
pool.accTokenPerShare = pool.accTokenPerShare.add((tokenReward.mul(ACC_TOKEN_PRECISION) / lpSupply));
}
pool.lastRewardBlock = block.number;
poolInfo = pool;
}
}
| 29,109 |
23 | // Calculate the power of a hero from its gene, it calculates the equipment power, stats power, and super hero boost. | function getHeroPower(uint _genes, uint _dungeonDifficulty) public pure returns (
uint totalPower,
uint equipmentPower,
uint statsPower,
bool isSuper,
uint superRank,
uint superBoost
);
| function getHeroPower(uint _genes, uint _dungeonDifficulty) public pure returns (
uint totalPower,
uint equipmentPower,
uint statsPower,
bool isSuper,
uint superRank,
uint superBoost
);
| 45,129 |
144 | // The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encodingthey need in their contracts using a combination of `abi.encode` and `keccak256`. | * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
* ({_hashTypedDataV4}).
*
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating
* the chain id to protect against replay attacks on an eventual fork of the chain.
*
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
*
* _Available since v3.4._
*/
abstract contract EIP712 {
/* solhint-disable var-name-mixedcase */
// Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
// invalidate the cached domain separator if the chain id changes.
bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
uint256 private immutable _CACHED_CHAIN_ID;
bytes32 private immutable _HASHED_NAME;
bytes32 private immutable _HASHED_VERSION;
bytes32 private immutable _TYPE_HASH;
/* solhint-enable var-name-mixedcase */
/**
* @dev Initializes the domain separator and parameter caches.
*
* The meaning of `name` and `version` is specified in
* https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
*
* - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
* - `version`: the current major version of the signing domain.
*
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
* contract upgrade].
*/
constructor(string memory name, string memory version) {
bytes32 hashedName = keccak256(bytes(name));
bytes32 hashedVersion = keccak256(bytes(version));
bytes32 typeHash = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
_HASHED_NAME = hashedName;
_HASHED_VERSION = hashedVersion;
_CACHED_CHAIN_ID = ChainId.get();
_CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
_TYPE_HASH = typeHash;
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
if (ChainId.get() == _CACHED_CHAIN_ID) {
return _CACHED_DOMAIN_SEPARATOR;
} else {
return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
}
}
function _buildDomainSeparator(bytes32 typeHash, bytes32 name, bytes32 version) private view returns (bytes32) {
return keccak256(
abi.encode(
typeHash,
name,
version,
ChainId.get(),
address(this)
)
);
}
/**
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
* function returns the hash of the fully encoded EIP712 message for this domain.
*
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
*
* ```solidity
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
* keccak256("Mail(address to,string contents)"),
* mailTo,
* keccak256(bytes(mailContents))
* )));
* address signer = ECDSA.recover(digest, signature);
* ```
*/
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
}
}
| * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
* ({_hashTypedDataV4}).
*
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating
* the chain id to protect against replay attacks on an eventual fork of the chain.
*
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
*
* _Available since v3.4._
*/
abstract contract EIP712 {
/* solhint-disable var-name-mixedcase */
// Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
// invalidate the cached domain separator if the chain id changes.
bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
uint256 private immutable _CACHED_CHAIN_ID;
bytes32 private immutable _HASHED_NAME;
bytes32 private immutable _HASHED_VERSION;
bytes32 private immutable _TYPE_HASH;
/* solhint-enable var-name-mixedcase */
/**
* @dev Initializes the domain separator and parameter caches.
*
* The meaning of `name` and `version` is specified in
* https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
*
* - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
* - `version`: the current major version of the signing domain.
*
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
* contract upgrade].
*/
constructor(string memory name, string memory version) {
bytes32 hashedName = keccak256(bytes(name));
bytes32 hashedVersion = keccak256(bytes(version));
bytes32 typeHash = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
_HASHED_NAME = hashedName;
_HASHED_VERSION = hashedVersion;
_CACHED_CHAIN_ID = ChainId.get();
_CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
_TYPE_HASH = typeHash;
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
if (ChainId.get() == _CACHED_CHAIN_ID) {
return _CACHED_DOMAIN_SEPARATOR;
} else {
return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
}
}
function _buildDomainSeparator(bytes32 typeHash, bytes32 name, bytes32 version) private view returns (bytes32) {
return keccak256(
abi.encode(
typeHash,
name,
version,
ChainId.get(),
address(this)
)
);
}
/**
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
* function returns the hash of the fully encoded EIP712 message for this domain.
*
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
*
* ```solidity
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
* keccak256("Mail(address to,string contents)"),
* mailTo,
* keccak256(bytes(mailContents))
* )));
* address signer = ECDSA.recover(digest, signature);
* ```
*/
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
}
}
| 38,153 |
5 | // emitted when the external token metadata URI resolver is updated | event TokenURIResolverUpdated(address indexed _tokenUriResolver);
| event TokenURIResolverUpdated(address indexed _tokenUriResolver);
| 40,254 |
190 | // Calculates the throne fee based on a 5% increase./ | function minPrice(uint256 _basePrice) private pure returns (uint){
return _basePrice + _basePrice/20;
}
| function minPrice(uint256 _basePrice) private pure returns (uint){
return _basePrice + _basePrice/20;
}
| 27,691 |
177 | // If this is NFT exit with metadata i.e. URI 👆 Note: If your token is only minted in L2, you can exit it with metadata. But if it was minted on L1, it'll be simply transferred to withdrawer address. And in that case, it's lot better to exit with `Transfer(address,address,uint256)` i.e. calling `withdraw` method on L2 contract event signature proof, which is defined under first `if` clause If you've called `withdrawWithMetadata`, you should submit proof of event signature `TransferWithMetadata(address,address,uint256,bytes)` |
address withdrawer = address(logTopicRLPList[1].toUint()); // topic1 is from address
require(
address(logTopicRLPList[2].toUint()) == address(0), // topic2 is to address
"MintableERC721Predicate: INVALID_RECEIVER"
);
IMintableERC721 token = IMintableERC721(rootToken);
|
address withdrawer = address(logTopicRLPList[1].toUint()); // topic1 is from address
require(
address(logTopicRLPList[2].toUint()) == address(0), // topic2 is to address
"MintableERC721Predicate: INVALID_RECEIVER"
);
IMintableERC721 token = IMintableERC721(rootToken);
| 12,622 |
114 | // Cancel active game without playing. Useful if server stops responding beforeone game is played. _gameId Game session id. / | function userCancelActiveGame(uint _gameId) public {
address userAddress = msg.sender;
uint gameId = userGameId[userAddress];
Game storage game = gameIdGame[gameId];
require(gameId == _gameId, "inv gameId");
if (game.status == GameStatus.ACTIVE) {
game.endInitiatedTime = block.timestamp;
game.status = GameStatus.USER_INITIATED_END;
emit LogUserRequestedEnd(msg.sender, gameId);
} else if (game.status == GameStatus.SERVER_INITIATED_END && game.roundId == 0) {
cancelActiveGame(game, gameId, userAddress);
} else {
revert();
}
}
| function userCancelActiveGame(uint _gameId) public {
address userAddress = msg.sender;
uint gameId = userGameId[userAddress];
Game storage game = gameIdGame[gameId];
require(gameId == _gameId, "inv gameId");
if (game.status == GameStatus.ACTIVE) {
game.endInitiatedTime = block.timestamp;
game.status = GameStatus.USER_INITIATED_END;
emit LogUserRequestedEnd(msg.sender, gameId);
} else if (game.status == GameStatus.SERVER_INITIATED_END && game.roundId == 0) {
cancelActiveGame(game, gameId, userAddress);
} else {
revert();
}
}
| 23,928 |
4 | // Example value here is 0.5 BNB. This is the minimum amount of BNB a contributor will have to put in. |
minimumToRaise = 30000000000000000000 wei;
|
minimumToRaise = 30000000000000000000 wei;
| 21,230 |
65 | // Owner is allowed to transfer tokens before the sale is finalized. This allows the tokens to move from the TokenSale contract to a beneficiary. We also allow someone to send tokens back to the owner. This is useful among other cases, reclaimTokens etc. | require(_sender == owner || _to == owner);
| require(_sender == owner || _to == owner);
| 10,007 |
31 | // withdraw funds to gnosis safe / | function withdraw() external onlyOwner {
(bool success, ) = GNOSIS_SAFE.call{value: address(this).balance}("");
require(success, "Transfer failed.");
}
| function withdraw() external onlyOwner {
(bool success, ) = GNOSIS_SAFE.call{value: address(this).balance}("");
require(success, "Transfer failed.");
}
| 49,182 |
63 | // Make the proposal fail if the applicant is jailed - for standard proposals, we don't want the applicant to get any shares/loot/payment - for guild kick proposals, we should never be able to propose to kick a jailed member (or have two kick proposals active), so it doesn't matter | if (members[proposal.applicant].jailed != 0) {
didPass = false;
}
| if (members[proposal.applicant].jailed != 0) {
didPass = false;
}
| 8,266 |
132 | // A reference to our checklist contract, which contains all the minting limits. | StrikersChecklist public strikersChecklist;
| StrikersChecklist public strikersChecklist;
| 4,584 |
37 | // Config for pToken | struct TokenConfig {
address pToken;
address underlying;
string underlyingSymbol; //example: DAI
uint256 baseUnit; //example: 1e18
bool fixedUsd; //if true,will return 1*e36/baseUnit
}
| struct TokenConfig {
address pToken;
address underlying;
string underlyingSymbol; //example: DAI
uint256 baseUnit; //example: 1e18
bool fixedUsd; //if true,will return 1*e36/baseUnit
}
| 12,365 |
71 | // Deploy | dai = daiFab.newDai(chainId);
daiJoin = daiJoinFab.newDaiJoin(address(vat), address(dai));
dai.rely(address(daiJoin));
| dai = daiFab.newDai(chainId);
daiJoin = daiJoinFab.newDaiJoin(address(vat), address(dai));
dai.rely(address(daiJoin));
| 7,017 |
101 | // 賣方才檢查並圈存, | if(bytes1(uint8(uint(_txSerNo) / (2**((31 - 5) * 8)))) == 'S') {
if( getCustomerSecuritiesPosition(_securities_id, _from_bank_id, _from_customer_id) < _securities_amount) {
| if(bytes1(uint8(uint(_txSerNo) / (2**((31 - 5) * 8)))) == 'S') {
if( getCustomerSecuritiesPosition(_securities_id, _from_bank_id, _from_customer_id) < _securities_amount) {
| 44,649 |
77 | // Calculates partial value given a numerator and denominator rounded down./numerator Numerator./denominator Denominator./target Value to calculate partial of./ return Partial value of target rounded down. | function getPartialAmountFloor(
uint256 numerator,
uint256 denominator,
uint256 target
)
internal
pure
returns (uint256 partialAmount)
| function getPartialAmountFloor(
uint256 numerator,
uint256 denominator,
uint256 target
)
internal
pure
returns (uint256 partialAmount)
| 32,521 |
43 | // Ensure that exactly one 721 item is being transferred. | if (item.amount != 1) {
revert InvalidERC721TransferAmount(item.amount);
}
| if (item.amount != 1) {
revert InvalidERC721TransferAmount(item.amount);
}
| 18,482 |
7 | // Get the current limiter currency worth of a given SGA amount. _sgaAmount The amount of SGA to convert.return The equivalent amount of the limiter currency. / | function toLimiterValue(uint256 _sgaAmount) external view returns (uint256);
| function toLimiterValue(uint256 _sgaAmount) external view returns (uint256);
| 32,561 |
8 | // BEP20Mintable | * @dev Implementation of the BEP20Mintable. Extension of {BEP20} that adds a minting behaviour.
*/
abstract contract BEP20Mintable is BEP20 {
// indicates if minting is finished
bool private _mintingFinished = false;
/**
* @dev Emitted during finish minting
*/
event MintFinished();
/**
* @dev Tokens can be minted only before minting finished.
*/
modifier canMint() {
require(!_mintingFinished, "BEP20Mintable: minting is finished");
_;
}
/**
* @return if minting is finished or not.
*/
function mintingFinished() public view returns (bool) {
return _mintingFinished;
}
/**
* @dev Function to mint tokens.
*
* WARNING: it allows everyone to mint new tokens. Access controls MUST be defined in derived contracts.
*
* @param account The address that will receive the minted tokens
* @param amount The amount of tokens to mint
*/
function mint(address account, uint256 amount) public canMint {
_mint(account, amount);
}
/**
* @dev Function to stop minting new tokens.
*
* WARNING: it allows everyone to finish minting. Access controls MUST be defined in derived contracts.
*/
function finishMinting() public canMint {
_finishMinting();
}
/**
* @dev Function to stop minting new tokens.
*/
function _finishMinting() internal virtual {
_mintingFinished = true;
emit MintFinished();
}
}
| * @dev Implementation of the BEP20Mintable. Extension of {BEP20} that adds a minting behaviour.
*/
abstract contract BEP20Mintable is BEP20 {
// indicates if minting is finished
bool private _mintingFinished = false;
/**
* @dev Emitted during finish minting
*/
event MintFinished();
/**
* @dev Tokens can be minted only before minting finished.
*/
modifier canMint() {
require(!_mintingFinished, "BEP20Mintable: minting is finished");
_;
}
/**
* @return if minting is finished or not.
*/
function mintingFinished() public view returns (bool) {
return _mintingFinished;
}
/**
* @dev Function to mint tokens.
*
* WARNING: it allows everyone to mint new tokens. Access controls MUST be defined in derived contracts.
*
* @param account The address that will receive the minted tokens
* @param amount The amount of tokens to mint
*/
function mint(address account, uint256 amount) public canMint {
_mint(account, amount);
}
/**
* @dev Function to stop minting new tokens.
*
* WARNING: it allows everyone to finish minting. Access controls MUST be defined in derived contracts.
*/
function finishMinting() public canMint {
_finishMinting();
}
/**
* @dev Function to stop minting new tokens.
*/
function _finishMinting() internal virtual {
_mintingFinished = true;
emit MintFinished();
}
}
| 29,415 |
13 | // Get net asset value priced in terms of asset0 | function getNav() public view returns (uint256) {
return getStakedBalance().add(getBufferBalance());
}
| function getNav() public view returns (uint256) {
return getStakedBalance().add(getBufferBalance());
}
| 67,630 |
99 | // the reward account for DAO and maintainer | uint8 constant acc_Reward = 4;
| uint8 constant acc_Reward = 4;
| 46,935 |
206 | // Internal function to safely transfer reward in case there is a rounding error | function _safeRewardTransfer(IERC20 _token, address _to, uint256 _amount) internal {
uint256 _bal = _token.balanceOf(address(this));
if (_amount > _bal) {
_token.safeTransfer(_to, _bal);
} else {
_token.safeTransfer(_to, _amount);
}
}
| function _safeRewardTransfer(IERC20 _token, address _to, uint256 _amount) internal {
uint256 _bal = _token.balanceOf(address(this));
if (_amount > _bal) {
_token.safeTransfer(_to, _bal);
} else {
_token.safeTransfer(_to, _amount);
}
}
| 3,622 |
5 | // Transfers ownership of this contract to the finalOwner.Only callable by the Final Owner, which is intended to be our multisig.This function shouldn't be necessary, but it gives a sense of reassurance that we can recoverif something really surprising goes wrong. / | function returnOwnership() external {
require(msg.sender == finalOwner, "AddressDictator: only callable by finalOwner");
manager.transferOwnership(finalOwner);
}
| function returnOwnership() external {
require(msg.sender == finalOwner, "AddressDictator: only callable by finalOwner");
manager.transferOwnership(finalOwner);
}
| 24,570 |
58 | // Send reward in SOV to the lockedSOV vault. _user The user info, to get its reward share. _userAddress The address of the user, to send SOV in its behalf. _isStakingTokens The flag whether we need to stake tokens _isCheckingBalance The flag whether we need to throw error or don't process reward if SOV balance isn't enough / | function _transferReward(
address _poolToken,
UserInfo storage _user,
address _userAddress,
bool _isStakingTokens,
bool _isCheckingBalance
| function _transferReward(
address _poolToken,
UserInfo storage _user,
address _userAddress,
bool _isStakingTokens,
bool _isCheckingBalance
| 12,343 |
349 | // functions affected by this modifier can only be invoked if the reserve is not freezed. A freezed reserve only allows redeems, repays, rebalances and liquidations._reserve the address of the reserve/ | modifier onlyUnfreezedReserve(address _reserve) {
requireReserveNotFreezedInternal(_reserve);
_;
}
| modifier onlyUnfreezedReserve(address _reserve) {
requireReserveNotFreezedInternal(_reserve);
_;
}
| 81,076 |
4 | // define a state variable to track the funded amount | uint256 public receivedFund;
| uint256 public receivedFund;
| 215 |
42 | // Event emitted when underlying is borrowed / | event Borrow(address borrower, uint borrowAmount, uint accountBorrows, uint totalBorrows);
| event Borrow(address borrower, uint borrowAmount, uint accountBorrows, uint totalBorrows);
| 3,461 |
14 | // stakes hex - transfers HEX from user to contract - approval needed | function stakeHex(uint hearts, uint dayLength, address payable ref)
internal
returns(bool)
| function stakeHex(uint hearts, uint dayLength, address payable ref)
internal
returns(bool)
| 32,406 |
0 | // Emits an `ApplicationJoined` event with the message sender. | function join() external override {
emit ApplicationJoined(msg.sender);
}
| function join() external override {
emit ApplicationJoined(msg.sender);
}
| 8,407 |
40 | // Token details |
string constant public name = "LYNC Network";
string constant public symbol = "LYNC";
uint8 constant public decimals = 18;
|
string constant public name = "LYNC Network";
string constant public symbol = "LYNC";
uint8 constant public decimals = 18;
| 3,591 |
9 | // State variables/Address of each strategy | address[] public strategyAddresses;
| address[] public strategyAddresses;
| 3,636 |
61 | // function to get notifications count of a user | function getNotificationsCount(string memory _user) view public returns(uint256){
address _userAddress = parseAddr(_user);
return(notificationsCount[_userAddress]);
}
| function getNotificationsCount(string memory _user) view public returns(uint256){
address _userAddress = parseAddr(_user);
return(notificationsCount[_userAddress]);
}
| 20,581 |
25 | // if batch, ensure both certHash and merkleHash are same | if (batchFlag) {
if (certHash != merkleHash) {
return (STATUS_FAIL, MSG_INVALID_CERT_MERKLE_NOT_MATCHED);
}
| if (batchFlag) {
if (certHash != merkleHash) {
return (STATUS_FAIL, MSG_INVALID_CERT_MERKLE_NOT_MATCHED);
}
| 44,721 |
36 | // do something | wl[wlList[i]] = true;
| wl[wlList[i]] = true;
| 20,803 |
7 | // solhint-disable no-simple-event-func-name | contract TestEventsRaiser {
event TokenTransfer(
address token,
address from,
address to,
uint256 amount
);
event TokenApprove(
address spender,
uint256 allowance
);
event WethDeposit(
uint256 amount
);
event WethWithdraw(
uint256 amount
);
event EthToTokenTransferInput(
address exchange,
uint256 minTokensBought,
uint256 deadline,
address recipient
);
event TokenToEthSwapInput(
address exchange,
uint256 tokensSold,
uint256 minEthBought,
uint256 deadline
);
event TokenToTokenTransferInput(
address exchange,
uint256 tokensSold,
uint256 minTokensBought,
uint256 minEthBought,
uint256 deadline,
address recipient,
address toTokenAddress
);
function raiseEthToTokenTransferInput(
uint256 minTokensBought,
uint256 deadline,
address recipient
)
external
{
emit EthToTokenTransferInput(
msg.sender,
minTokensBought,
deadline,
recipient
);
}
function raiseTokenToEthSwapInput(
uint256 tokensSold,
uint256 minEthBought,
uint256 deadline
)
external
{
emit TokenToEthSwapInput(
msg.sender,
tokensSold,
minEthBought,
deadline
);
}
function raiseTokenToTokenTransferInput(
uint256 tokensSold,
uint256 minTokensBought,
uint256 minEthBought,
uint256 deadline,
address recipient,
address toTokenAddress
)
external
{
emit TokenToTokenTransferInput(
msg.sender,
tokensSold,
minTokensBought,
minEthBought,
deadline,
recipient,
toTokenAddress
);
}
function raiseTokenTransfer(
address from,
address to,
uint256 amount
)
external
{
emit TokenTransfer(
msg.sender,
from,
to,
amount
);
}
function raiseTokenApprove(address spender, uint256 allowance)
external
{
emit TokenApprove(spender, allowance);
}
function raiseWethDeposit(uint256 amount)
external
{
emit WethDeposit(amount);
}
function raiseWethWithdraw(uint256 amount)
external
{
emit WethWithdraw(amount);
}
}
| contract TestEventsRaiser {
event TokenTransfer(
address token,
address from,
address to,
uint256 amount
);
event TokenApprove(
address spender,
uint256 allowance
);
event WethDeposit(
uint256 amount
);
event WethWithdraw(
uint256 amount
);
event EthToTokenTransferInput(
address exchange,
uint256 minTokensBought,
uint256 deadline,
address recipient
);
event TokenToEthSwapInput(
address exchange,
uint256 tokensSold,
uint256 minEthBought,
uint256 deadline
);
event TokenToTokenTransferInput(
address exchange,
uint256 tokensSold,
uint256 minTokensBought,
uint256 minEthBought,
uint256 deadline,
address recipient,
address toTokenAddress
);
function raiseEthToTokenTransferInput(
uint256 minTokensBought,
uint256 deadline,
address recipient
)
external
{
emit EthToTokenTransferInput(
msg.sender,
minTokensBought,
deadline,
recipient
);
}
function raiseTokenToEthSwapInput(
uint256 tokensSold,
uint256 minEthBought,
uint256 deadline
)
external
{
emit TokenToEthSwapInput(
msg.sender,
tokensSold,
minEthBought,
deadline
);
}
function raiseTokenToTokenTransferInput(
uint256 tokensSold,
uint256 minTokensBought,
uint256 minEthBought,
uint256 deadline,
address recipient,
address toTokenAddress
)
external
{
emit TokenToTokenTransferInput(
msg.sender,
tokensSold,
minTokensBought,
minEthBought,
deadline,
recipient,
toTokenAddress
);
}
function raiseTokenTransfer(
address from,
address to,
uint256 amount
)
external
{
emit TokenTransfer(
msg.sender,
from,
to,
amount
);
}
function raiseTokenApprove(address spender, uint256 allowance)
external
{
emit TokenApprove(spender, allowance);
}
function raiseWethDeposit(uint256 amount)
external
{
emit WethDeposit(amount);
}
function raiseWethWithdraw(uint256 amount)
external
{
emit WethWithdraw(amount);
}
}
| 16,574 |
89 | // Expect: true || false || true || | true || false || true ||
| true || false || true ||
| 39,994 |
213 | // Set the staker vault for this pool's LP token Staker vault and LP token pairs are immutable and the staker vault can only be set once for a pool. Only one vault exists per LP token. This information will be retrieved from the controller of the pool.return Address of the new staker vault for the pool. / | function setStaker()
external
override
onlyRoles2(Roles.GOVERNANCE, Roles.POOL_FACTORY)
returns (bool)
| function setStaker()
external
override
onlyRoles2(Roles.GOVERNANCE, Roles.POOL_FACTORY)
returns (bool)
| 16,376 |
2 | // Role definitions | bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");
| bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");
| 25,195 |
104 | // Used to change `profitFactor`. `profitFactor` is used to determine if it's worthwhile to harvest, given gas costs. (See `harvestTrigger()` for more details.)This may only be called by governance or the strategist. _profitFactor A ratio to multiply anticipated`harvest()` gas cost against. / | function setProfitFactor(uint256 _profitFactor) external onlyAuthorized {
profitFactor = _profitFactor;
emit UpdatedProfitFactor(_profitFactor);
}
| function setProfitFactor(uint256 _profitFactor) external onlyAuthorized {
profitFactor = _profitFactor;
emit UpdatedProfitFactor(_profitFactor);
}
| 4,507 |
1 | // @inheritdoc ERC721Upgradeable / | function _baseURI() internal view virtual override returns (string memory uri) {
uri = $baseURI;
}
| function _baseURI() internal view virtual override returns (string memory uri) {
uri = $baseURI;
}
| 33,578 |
75 | // Compute if target qualifies for ring 1 validation Calculate the total PoSaT credits held by O10 who have voted confidence (inc. available and locked credits) | uint256 totalTokenHeld = 0;
for (uint256 i = 0; i<_vocReverseRecords[target].length; i++) {
address currentO10 = _vocReverseRecords[target][i];
| uint256 totalTokenHeld = 0;
for (uint256 i = 0; i<_vocReverseRecords[target].length; i++) {
address currentO10 = _vocReverseRecords[target][i];
| 51,430 |
6 | // analogous to addConfirmation but only works if report is fixed/ | function addFixConfirmation(address sender) public{
if(sender != fixReporter && fixConfirmations.length < CONFIRMATION_NUMBER && fixedReport){
bool alreadyConfirmed = false;
for (uint256 i; i < fixConfirmations.length; i++) {
if (fixConfirmations[i] == sender) {
alreadyConfirmed = true;
break;
}
}
if (!alreadyConfirmed) {
fixConfirmations.push(sender);
if(fixConfirmations.length == CONFIRMATION_NUMBER){
enoughFixConfirmations = true;
}
}
}
}
| function addFixConfirmation(address sender) public{
if(sender != fixReporter && fixConfirmations.length < CONFIRMATION_NUMBER && fixedReport){
bool alreadyConfirmed = false;
for (uint256 i; i < fixConfirmations.length; i++) {
if (fixConfirmations[i] == sender) {
alreadyConfirmed = true;
break;
}
}
if (!alreadyConfirmed) {
fixConfirmations.push(sender);
if(fixConfirmations.length == CONFIRMATION_NUMBER){
enoughFixConfirmations = true;
}
}
}
}
| 22,438 |
18 | // Decreases the deposit amount for a given position. _positionId The ID of the position. _amount The amount to decrease the deposit by. / | function decreaseDeposit(uint256 _positionId, uint256 _amount) external;
| function decreaseDeposit(uint256 _positionId, uint256 _amount) external;
| 30,354 |
104 | // Equivalent to contains(set, value) To delete an element from the _values array in O(1), we swap the element to delete with the last one in the array, and then remove the last element (sometimes called as 'swap and pop'). This modifies the order of the array, as noted in {at}. |
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastvalue = set._values[lastIndex];
|
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
if (lastIndex != toDeleteIndex) {
bytes32 lastvalue = set._values[lastIndex];
| 1,938 |
2 | // --------------------------------- MINTING -------------------------------- //Requires the current total OKPC supply to be less than the max supply for the current phase. | modifier onlyIfSupplyMintable() {
if (
_currentIndex >
ARTISTS_RESERVED + TEAM_RESERVED + (uint256(mintingPhase) * MAX_PER_PHASE)
) revert MintMaxReached();
_;
}
| modifier onlyIfSupplyMintable() {
if (
_currentIndex >
ARTISTS_RESERVED + TEAM_RESERVED + (uint256(mintingPhase) * MAX_PER_PHASE)
) revert MintMaxReached();
_;
}
| 31,978 |
14 | // Returns a version of a template. templateId The id of the template to return the version of. _version The version of the template to be returned.return The version of the template. / | function version(bytes32 templateId, uint256 _version) external view returns (Version memory);
| function version(bytes32 templateId, uint256 _version) external view returns (Version memory);
| 40,019 |
32 | // / | library WadRayMath {
using SafeMath for uint256;
uint256 internal constant WAD = 1e18;
uint256 internal constant halfWAD = WAD / 2;
uint256 internal constant RAY = 1e27;
uint256 internal constant halfRAY = RAY / 2;
uint256 internal constant WAD_RAY_RATIO = 1e9;
function ray() internal pure returns (uint256) {
return RAY;
}
function wad() internal pure returns (uint256) {
return WAD;
}
function halfRay() internal pure returns (uint256) {
return halfRAY;
}
function halfWad() internal pure returns (uint256) {
return halfWAD;
}
function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {
return halfWAD.add(a.mul(b)).div(WAD);
}
function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 halfB = b / 2;
return halfB.add(a.mul(WAD)).div(b);
}
function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {
return halfRAY.add(a.mul(b)).div(RAY);
}
function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 halfB = b / 2;
return halfB.add(a.mul(RAY)).div(b);
}
function rayToWad(uint256 a) internal pure returns (uint256) {
uint256 halfRatio = WAD_RAY_RATIO / 2;
return halfRatio.add(a).div(WAD_RAY_RATIO);
}
function wadToRay(uint256 a) internal pure returns (uint256) {
return a.mul(WAD_RAY_RATIO);
}
/**
* @dev calculates x^n, in ray. The code uses the ModExp precompile
* @param x base
* @param n exponent
* @return z = x^n, in ray
*/
function rayPow(uint256 x, uint256 n) internal pure returns (uint256 z) {
z = n % 2 != 0 ? x : RAY;
for (n /= 2; n != 0; n /= 2) {
x = rayMul(x, x);
if (n % 2 != 0) {
z = rayMul(z, x);
}
}
}
}
| library WadRayMath {
using SafeMath for uint256;
uint256 internal constant WAD = 1e18;
uint256 internal constant halfWAD = WAD / 2;
uint256 internal constant RAY = 1e27;
uint256 internal constant halfRAY = RAY / 2;
uint256 internal constant WAD_RAY_RATIO = 1e9;
function ray() internal pure returns (uint256) {
return RAY;
}
function wad() internal pure returns (uint256) {
return WAD;
}
function halfRay() internal pure returns (uint256) {
return halfRAY;
}
function halfWad() internal pure returns (uint256) {
return halfWAD;
}
function wadMul(uint256 a, uint256 b) internal pure returns (uint256) {
return halfWAD.add(a.mul(b)).div(WAD);
}
function wadDiv(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 halfB = b / 2;
return halfB.add(a.mul(WAD)).div(b);
}
function rayMul(uint256 a, uint256 b) internal pure returns (uint256) {
return halfRAY.add(a.mul(b)).div(RAY);
}
function rayDiv(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 halfB = b / 2;
return halfB.add(a.mul(RAY)).div(b);
}
function rayToWad(uint256 a) internal pure returns (uint256) {
uint256 halfRatio = WAD_RAY_RATIO / 2;
return halfRatio.add(a).div(WAD_RAY_RATIO);
}
function wadToRay(uint256 a) internal pure returns (uint256) {
return a.mul(WAD_RAY_RATIO);
}
/**
* @dev calculates x^n, in ray. The code uses the ModExp precompile
* @param x base
* @param n exponent
* @return z = x^n, in ray
*/
function rayPow(uint256 x, uint256 n) internal pure returns (uint256 z) {
z = n % 2 != 0 ? x : RAY;
for (n /= 2; n != 0; n /= 2) {
x = rayMul(x, x);
if (n % 2 != 0) {
z = rayMul(z, x);
}
}
}
}
| 43,576 |
11 | // Transfer proxy admin role | _proxy.changeAdmin(_newProxyAdmin);
| _proxy.changeAdmin(_newProxyAdmin);
| 2,362 |
19 | // uint256 blockReturnSubmitQuestion | )
| )
| 19,806 |
43 | // tokenOrder[1]= "WETH"; tokenOrder[2]= "SAI"; |
tokenOrder[1]= "ETH";
|
tokenOrder[1]= "ETH";
| 19,041 |
136 | // Copy over the first `submod` bytes of the new data as in case 1 above. | let slengthmod := mod(slength, 32)
let mlengthmod := mod(mlength, 32)
let submod := sub(32, slengthmod)
let mc := add(_postBytes, submod)
let end := add(_postBytes, mlength)
let mask := sub(exp(0x100, submod), 1)
sstore(sc, add(sload(sc), and(mload(mc), mask)))
for {
| let slengthmod := mod(slength, 32)
let mlengthmod := mod(mlength, 32)
let submod := sub(32, slengthmod)
let mc := add(_postBytes, submod)
let end := add(_postBytes, mlength)
let mask := sub(exp(0x100, submod), 1)
sstore(sc, add(sload(sc), and(mload(mc), mask)))
for {
| 10,872 |
62 | // Validate that the caller of the method holds the honeyjar | if (beraPunk.ownerOf(jarId) != msg.sender) {
revert NotJarOwner();
}
| if (beraPunk.ownerOf(jarId) != msg.sender) {
revert NotJarOwner();
}
| 23,486 |
86 | // Change the accounting model contract/Only callable by DAO. The address of the new contract must have code./newModel The address of the new model | function setAccountingModel(address newModel) public {
enforceCallerDAO();
enforceHasContractCode(newModel, "invalid address");
emit SetAccountingModel(address(accountingModel), newModel);
accountingModel = IAccountingModel(newModel);
}
| function setAccountingModel(address newModel) public {
enforceCallerDAO();
enforceHasContractCode(newModel, "invalid address");
emit SetAccountingModel(address(accountingModel), newModel);
accountingModel = IAccountingModel(newModel);
}
| 44,982 |
42 | // Send the dev fee's; | payable(developerFeeReciver).transfer(amountFTMDev);
| payable(developerFeeReciver).transfer(amountFTMDev);
| 38,320 |
79 | // Exchange pool processor abstract contract. Keeps an enumerable set of designated exchange addresses as well as a single primary pool address. / | abstract contract ExchangePoolProcessor is Ownable {
using EnumerableSet for EnumerableSet.AddressSet;
/// @dev Set of exchange pool addresses.
EnumerableSet.AddressSet internal _exchangePools;
/// @notice Primary exchange pool address.
address public primaryPool;
/// @notice Emitted when an exchange pool address is added to the set of tracked pool addresses.
event ExchangePoolAdded(address exchangePool);
/// @notice Emitted when an exchange pool address is removed from the set of tracked pool addresses.
event ExchangePoolRemoved(address exchangePool);
/// @notice Emitted when the primary pool address is updated.
event PrimaryPoolUpdated(address oldPrimaryPool, address newPrimaryPool);
/**
* @notice Get list of addresses designated as exchange pools.
* @return An array of exchange pool addresses.
*/
function getExchangePoolAddresses() external view returns (address[] memory) {
return _exchangePools.values();
}
/**
* @notice Add an address to the set of exchange pool addresses.
* @dev Nothing happens if the pool already exists in the set.
* @param exchangePool Address of exchange pool to add.
*/
function addExchangePool(address exchangePool) external onlyOwner {
if (_exchangePools.add(exchangePool)) {
emit ExchangePoolAdded(exchangePool);
}
}
/**
* @notice Remove an address from the set of exchange pool addresses.
* @dev Nothing happens if the pool doesn't exist in the set..
* @param exchangePool Address of exchange pool to remove.
*/
function removeExchangePool(address exchangePool) external onlyOwner {
if (_exchangePools.remove(exchangePool)) {
emit ExchangePoolRemoved(exchangePool);
}
}
/**
* @notice Set exchange pool address as primary pool.
* @dev To prevent issues, only addresses inside the set of exchange pool addresses can be selected as primary pool.
* @param exchangePool Address of exchange pool to set as primary pool.
*/
function setPrimaryPool(address exchangePool) external onlyOwner {
require(
_exchangePools.contains(exchangePool),
"ExchangePoolProcessor:setPrimaryPool:INVALID_POOL: Given address is not registered as exchange pool."
);
require(
primaryPool != exchangePool,
"ExchangePoolProcessor:setPrimaryPool:ALREADY_SET: This address is already the primary pool address."
);
address oldPrimaryPool = primaryPool;
primaryPool = exchangePool;
emit PrimaryPoolUpdated(oldPrimaryPool, exchangePool);
}
}
| abstract contract ExchangePoolProcessor is Ownable {
using EnumerableSet for EnumerableSet.AddressSet;
/// @dev Set of exchange pool addresses.
EnumerableSet.AddressSet internal _exchangePools;
/// @notice Primary exchange pool address.
address public primaryPool;
/// @notice Emitted when an exchange pool address is added to the set of tracked pool addresses.
event ExchangePoolAdded(address exchangePool);
/// @notice Emitted when an exchange pool address is removed from the set of tracked pool addresses.
event ExchangePoolRemoved(address exchangePool);
/// @notice Emitted when the primary pool address is updated.
event PrimaryPoolUpdated(address oldPrimaryPool, address newPrimaryPool);
/**
* @notice Get list of addresses designated as exchange pools.
* @return An array of exchange pool addresses.
*/
function getExchangePoolAddresses() external view returns (address[] memory) {
return _exchangePools.values();
}
/**
* @notice Add an address to the set of exchange pool addresses.
* @dev Nothing happens if the pool already exists in the set.
* @param exchangePool Address of exchange pool to add.
*/
function addExchangePool(address exchangePool) external onlyOwner {
if (_exchangePools.add(exchangePool)) {
emit ExchangePoolAdded(exchangePool);
}
}
/**
* @notice Remove an address from the set of exchange pool addresses.
* @dev Nothing happens if the pool doesn't exist in the set..
* @param exchangePool Address of exchange pool to remove.
*/
function removeExchangePool(address exchangePool) external onlyOwner {
if (_exchangePools.remove(exchangePool)) {
emit ExchangePoolRemoved(exchangePool);
}
}
/**
* @notice Set exchange pool address as primary pool.
* @dev To prevent issues, only addresses inside the set of exchange pool addresses can be selected as primary pool.
* @param exchangePool Address of exchange pool to set as primary pool.
*/
function setPrimaryPool(address exchangePool) external onlyOwner {
require(
_exchangePools.contains(exchangePool),
"ExchangePoolProcessor:setPrimaryPool:INVALID_POOL: Given address is not registered as exchange pool."
);
require(
primaryPool != exchangePool,
"ExchangePoolProcessor:setPrimaryPool:ALREADY_SET: This address is already the primary pool address."
);
address oldPrimaryPool = primaryPool;
primaryPool = exchangePool;
emit PrimaryPoolUpdated(oldPrimaryPool, exchangePool);
}
}
| 59,288 |
195 | // View function to see pending FOXYs on frontend. | function pendingFOXY(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accFOXYPerShare = pool.accFOXYPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 foxyReward = multiplier.mul(foxyPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accFOXYPerShare = accFOXYPerShare.add(foxyReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accFOXYPerShare).div(1e12).sub(user.rewardDebt);
}
| function pendingFOXY(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accFOXYPerShare = pool.accFOXYPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 foxyReward = multiplier.mul(foxyPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accFOXYPerShare = accFOXYPerShare.add(foxyReward.mul(1e12).div(lpSupply));
}
return user.amount.mul(accFOXYPerShare).div(1e12).sub(user.rewardDebt);
}
| 34,607 |
207 | // Send yield amount realized from holding LP tokens to the treasury | function putToTreasuryAmount(address token, uint256 _amount) public onlyOwner {
uint256 userbalances = totalStaked[token];
uint256 lptokenbalance = IERC20(token).balanceOf(address(this));
require(token != address(holytoken), "cannot transfer holy tokens");
require(_amount <= lptokenbalance - userbalances, "not enough tokens");
IERC20(token).safeTransfer(treasuryaddr, _amount);
emit Treasury(token, treasuryaddr, _amount);
}
| function putToTreasuryAmount(address token, uint256 _amount) public onlyOwner {
uint256 userbalances = totalStaked[token];
uint256 lptokenbalance = IERC20(token).balanceOf(address(this));
require(token != address(holytoken), "cannot transfer holy tokens");
require(_amount <= lptokenbalance - userbalances, "not enough tokens");
IERC20(token).safeTransfer(treasuryaddr, _amount);
emit Treasury(token, treasuryaddr, _amount);
}
| 11,449 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.