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 |
|---|---|---|---|---|
49 | // share 30% of the wrapped Ether as a profit sharing reward | notifyProfitInRewardToken(wethBalance);
uint256 remainingWethBalance = IERC20(weth).balanceOf(address(this));
IERC20(weth).safeApprove(uni, 0);
IERC20(weth).safeApprove(uni, remainingWethBalance.div(2));
| notifyProfitInRewardToken(wethBalance);
uint256 remainingWethBalance = IERC20(weth).balanceOf(address(this));
IERC20(weth).safeApprove(uni, 0);
IERC20(weth).safeApprove(uni, remainingWethBalance.div(2));
| 19,406 |
17 | // Once the owner loads the data, this is set to true, and the data is locked | bool public compressedDataLoaded;
| bool public compressedDataLoaded;
| 18,426 |
195 | // Calculate the new borrow amount | TypesV1.Par memory newPar = position.borrowedAmount.add(
TypesV1.Par({
sign: false,
value: borrowAmount.to128()
})
| TypesV1.Par memory newPar = position.borrowedAmount.add(
TypesV1.Par({
sign: false,
value: borrowAmount.to128()
})
| 32,826 |
26 | // Get total voters count . return total voters count./ | function getTotalVoters() external view returns (uint256) {
return voters.length;
}
| function getTotalVoters() external view returns (uint256) {
return voters.length;
}
| 22,086 |
253 | // Transfers `nftIndex` from `from` to `to`. | * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `nftIndex` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(address from, address to, uint256 nftIn... | * As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `nftIndex` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(address from, address to, uint256 nftIn... | 2,453 |
16 | // Returns true if the contract is frozen, and false otherwise. / | function isFrozen() public view returns (bool) {
return _frozen;
}
| function isFrozen() public view returns (bool) {
return _frozen;
}
| 41,354 |
416 | // Whether price of asset has been updated less than VALIDITY seconds ago/ofAsset Asset in registrar/ return isRecent Price information ofAsset is recent | function hasRecentPrice(address ofAsset)
view
pre_cond(assetIsRegistered(ofAsset))
returns (bool isRecent)
{
var ( , timestamp) = getPrice(ofAsset);
return (sub(now, timestamp) <= VALIDITY);
}
| function hasRecentPrice(address ofAsset)
view
pre_cond(assetIsRegistered(ofAsset))
returns (bool isRecent)
{
var ( , timestamp) = getPrice(ofAsset);
return (sub(now, timestamp) <= VALIDITY);
}
| 8,668 |
35 | // Set allowance for other address Allows `_spender` to spend no more than `_value` tokens in your behalf_spender The address authorized to spend_value the max amount they can spend/ | function approve(address _spender, uint256 _value) external returns (bool success) {
require(!safeguard);
/* AUDITOR NOTE:
Many dex and dapps pre-approve large amount of tokens to save gas for subsequent transaction. This is good use case.
On flip-side, some malicious dapp, m... | function approve(address _spender, uint256 _value) external returns (bool success) {
require(!safeguard);
/* AUDITOR NOTE:
Many dex and dapps pre-approve large amount of tokens to save gas for subsequent transaction. This is good use case.
On flip-side, some malicious dapp, m... | 8,699 |
32 | // temporarily commented out to prevent 'out of gas' error during migration / /Eth payable fallback in case any Ether is accidentally sent / | // function () public payable {
// revert("Don't accept ETH");
// }
| // function () public payable {
// revert("Don't accept ETH");
// }
| 22,163 |
163 | // Helpers | function balanceOfWant() public view returns (uint _balance){
return want.balanceOf(address(this));
}
| function balanceOfWant() public view returns (uint _balance){
return want.balanceOf(address(this));
}
| 15,497 |
10 | // Visibility is `public` to enable it being called by other contracts for composition. | function renderTokenById(uint256 id) public view returns (string memory) {
string memory render = string(abi.encodePacked(
'<g id="tree" stroke="#',color[id].toColor(),'" fill="none">',
'<path d="M 0 90 A 90 90 0 1 1 40 80.62257748" stroke-width="10"/>',
'<path d="M 0 90 L 0 -80 M 0 50 L 64.... | function renderTokenById(uint256 id) public view returns (string memory) {
string memory render = string(abi.encodePacked(
'<g id="tree" stroke="#',color[id].toColor(),'" fill="none">',
'<path d="M 0 90 A 90 90 0 1 1 40 80.62257748" stroke-width="10"/>',
'<path d="M 0 90 L 0 -80 M 0 50 L 64.... | 46,217 |
54 | // reflecting sender and recipient balances | _rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
| _rOwned[sender] = _rOwned[sender].sub(rAmount);
_rOwned[recipient] = _rOwned[recipient].add(rTransferAmount);
| 39,578 |
4 | // Map of sale data hash to sale state | mapping(bytes32 => Sale) internal sales_;
| mapping(bytes32 => Sale) internal sales_;
| 62,315 |
4 | // ERC20 Events |
event Transfer(address indexed from, address indexed to, uint256 value);
|
event Transfer(address indexed from, address indexed to, uint256 value);
| 4,346 |
52 | // ============ Internal Functions ============ // Set or change of manager. _newManager New _manager address.return Boolean to indicate if the operation was successful or not. / | function _setManager(address _newManager) private returns (bool) {
address _previousManager = _manager;
require(_newManager != _previousManager, "Manageable/existing-manager-address");
_manager = _newManager;
emit ManagerTransferred(_previousManager, _newManager);
return t... | function _setManager(address _newManager) private returns (bool) {
address _previousManager = _manager;
require(_newManager != _previousManager, "Manageable/existing-manager-address");
_manager = _newManager;
emit ManagerTransferred(_previousManager, _newManager);
return t... | 42,336 |
3 | // donate to the campaign logic of the app | function donateToCampaign(uint256 _id) public payable{
uint256 amount = msg.value;
Campaign storage campaign = campaigns[_id];
campaign.donators.push(msg.sender);
campaign.donations.push(amount);
(bool sent,) = payable(campaign.owner).call{value:amount}("");
if(se... | function donateToCampaign(uint256 _id) public payable{
uint256 amount = msg.value;
Campaign storage campaign = campaigns[_id];
campaign.donators.push(msg.sender);
campaign.donations.push(amount);
(bool sent,) = payable(campaign.owner).call{value:amount}("");
if(se... | 26,356 |
23 | // Perform the swap with Uniswap V3 to the given token addresses and amounts. _totalAmountToSwap Total amount of erc20TokenOrigin to spend in swaps. _deadline The unix timestamp after a swap will fail. _swaps The array of the Swaps data. Swap ETH to ERC20. / | function performSwapV3ETH(
uint256 _totalAmountToSwap,
uint32 _deadline,
SwapV3[] calldata _swaps
| function performSwapV3ETH(
uint256 _totalAmountToSwap,
uint32 _deadline,
SwapV3[] calldata _swaps
| 28,015 |
10 | // Event for token purchase logging purchaser who paid for the tokens beneficiary who got the tokens value weis paid for purchase amount amount of tokens purchased / | event TokensPurchased(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
| event TokensPurchased(
address indexed purchaser,
address indexed beneficiary,
uint256 value,
uint256 amount
);
| 9,916 |
77 | // This would be token B as described above | Swap memory secondSwap = swapSequences[i][1];
IBPool poolSecondSwap = IBPool(secondSwap.pool);
intermediateTokenAmount = poolSecondSwap.calcInGivenOut(
poolSecondSwap.getBalance(secondSwap.tokenIn),
poolSecondSwap.getDenormalizedWei... | Swap memory secondSwap = swapSequences[i][1];
IBPool poolSecondSwap = IBPool(secondSwap.pool);
intermediateTokenAmount = poolSecondSwap.calcInGivenOut(
poolSecondSwap.getBalance(secondSwap.tokenIn),
poolSecondSwap.getDenormalizedWei... | 32,596 |
5 | // My Custom ERC1155 Conditional Minting This is an example repository that mints ERC1155 tokens if sender owns a specific ERC721. @custom:type eip-2535-facet@custom:category NFTs@custom:required-dependencies IERC1155MintableExtension / | contract MyERC1155ConditionalMint is OwnableInternal {
bytes32 internal constant STORAGE_SLOT = keccak256("v1.my-amazing-team.contracts.storage.MyERC1155ConditionalMint");
function layout() internal pure returns (Layout storage l) {
bytes32 slot = STORAGE_SLOT;
assembly {
l.slot := ... | contract MyERC1155ConditionalMint is OwnableInternal {
bytes32 internal constant STORAGE_SLOT = keccak256("v1.my-amazing-team.contracts.storage.MyERC1155ConditionalMint");
function layout() internal pure returns (Layout storage l) {
bytes32 slot = STORAGE_SLOT;
assembly {
l.slot := ... | 36,391 |
44 | // Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE/TO CONFIRM THAT `_to` IS CAPABLE OF RECEIVING NFTS OR ELSE/THEY MAY BE PERMANENTLY LOST/Throws unless `msg.sender` is the current owner, an authorized/operator, or the approved address for this NFT. Throws if `_from` is/not the current owner. Throws if `_to` ... | function transferFrom(
address _from,
address _to,
uint256 _tokenId
| function transferFrom(
address _from,
address _to,
uint256 _tokenId
| 2,259 |
100 | // split the liquidity | uint256 half = forLiquidity.div(2);
uint256 otherHalf = forLiquidity.sub(half);
| uint256 half = forLiquidity.div(2);
uint256 otherHalf = forLiquidity.sub(half);
| 5,985 |
80 | // Gets the current value of the position. The value is zero if you didn't make any deposits in the liquidity pool.return Returns the value of the position expressed in collateral tokens. / | function getCollateralValue () external view ifInitialized returns (uint256) {
uint256 currentBalance = IERC20(poolAddress).balanceOf(address(this));
uint256 exchangeRate = IClearPoolBase(poolAddress).getCurrentExchangeRate();
return (currentBalance * exchangeRate) / 1e18;
}
| function getCollateralValue () external view ifInitialized returns (uint256) {
uint256 currentBalance = IERC20(poolAddress).balanceOf(address(this));
uint256 exchangeRate = IClearPoolBase(poolAddress).getCurrentExchangeRate();
return (currentBalance * exchangeRate) / 1e18;
}
| 16,260 |
29 | // Smart contract library of mathematical functions operating with signed64.64-bit fixed point numbers.Signed 64.64-bit fixed point number isbasically a simple fraction whose numerator is signed 128-bit integer anddenominator is 2^64.As long as denominator is always the same, there is noneed to store it, thus in Solidi... | library ABDKMath64x64 {
/*
* Minimum value signed 64.64-bit fixed point number may have.
*/
int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;
/*
* Maximum value signed 64.64-bit fixed point number may have.
*/
int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFF... | library ABDKMath64x64 {
/*
* Minimum value signed 64.64-bit fixed point number may have.
*/
int128 private constant MIN_64x64 = -0x80000000000000000000000000000000;
/*
* Maximum value signed 64.64-bit fixed point number may have.
*/
int128 private constant MAX_64x64 = 0x7FFFFFFFFFFFFFFFFFFFFFFFFF... | 31,291 |
22 | // should be zero | return (x.X == 0 && x.Y == 0);
| return (x.X == 0 && x.Y == 0);
| 32,197 |
55 | // function to get addresses of all members in congress return array of addresses / | function getAllMemberAddresses()
external
view
returns (address[] memory)
| function getAllMemberAddresses()
external
view
returns (address[] memory)
| 35,200 |
31 | // Return if price identifier is supported priceIdentifier Price feed identifierreturn isSupported True if price is supported otherwise false / | function isPriceSupported(bytes32 priceIdentifier)
external
view
override
returns (bool isSupported)
| function isPriceSupported(bytes32 priceIdentifier)
external
view
override
returns (bool isSupported)
| 8,912 |
54 | // add liquidity to uniswap pair | addLiquidity(tokenSaleInfo.contractAddress, tokenAmountToLock, saleEthToLock);
| addLiquidity(tokenSaleInfo.contractAddress, tokenAmountToLock, saleEthToLock);
| 73,763 |
733 | // Commit the block | commitBlock(S, blocks[i], publicDataHashes[i]);
| commitBlock(S, blocks[i], publicDataHashes[i]);
| 36,985 |
1 | // Reserve id for recipient. | hashes[newItemId] = recipient;
| hashes[newItemId] = recipient;
| 17,615 |
123 | // adds a pool to the list of pools of a liquidity providercan only be executed only by an ownerproviderliquidity provider address poolToken pool token address / | function addProviderPool(address provider, IDSToken poolToken) external override ownerOnly returns (bool) {
return _providerPools[provider].add(address(poolToken));
}
| function addProviderPool(address provider, IDSToken poolToken) external override ownerOnly returns (bool) {
return _providerPools[provider].add(address(poolToken));
}
| 41,263 |
2 | // require( _isApprovedOrOwner(msg.sender, tokenId), "ERC4907: transfer caller is not owner nor approved" ); | require(
msg.sender == getApproved(tokenId),
"ERC721A: transfer caller is not owner nor approved"
);
UserInfo storage info = _users[tokenId];
info.user = user;
info.expires = expires;
emit UpdateUser(tokenId, user, expires);
| require(
msg.sender == getApproved(tokenId),
"ERC721A: transfer caller is not owner nor approved"
);
UserInfo storage info = _users[tokenId];
info.user = user;
info.expires = expires;
emit UpdateUser(tokenId, user, expires);
| 19,761 |
99 | // Function to get staking count / | function getStakingCount() public view returns(uint256){
return _stakingCount;
}
| function getStakingCount() public view returns(uint256){
return _stakingCount;
}
| 34,638 |
5 | // Setting ERC20 implementation contract for the reference | ERC20Implementation = ERC20ImplementationAddress;
| ERC20Implementation = ERC20ImplementationAddress;
| 15,956 |
24 | // Initialization function for upgradable proxy contracts _nexus Nexus contract address / | function _initialize(address _nexus) internal {
require(_nexus != address(0), "Nexus address is zero");
nexus = INexus(_nexus);
InitializableModuleKeys._initialize();
}
| function _initialize(address _nexus) internal {
require(_nexus != address(0), "Nexus address is zero");
nexus = INexus(_nexus);
InitializableModuleKeys._initialize();
}
| 23,271 |
194 | // Traits | uint8 constant minTraits = 5;
uint8 constant maxTraits = 15;
mapping (uint16 => bool) private removedTraitsMap;
mapping (uint16 => uint8) private traitsUsedMap;
uint16[] private removedTraits;
| uint8 constant minTraits = 5;
uint8 constant maxTraits = 15;
mapping (uint16 => bool) private removedTraitsMap;
mapping (uint16 => uint8) private traitsUsedMap;
uint16[] private removedTraits;
| 42,068 |
148 | // in case rounding error, send all to final | token.transfer(
tokenPools[last],
totalTokens.mulBP(tokenPoolBPs[last])
);
| token.transfer(
tokenPools[last],
totalTokens.mulBP(tokenPoolBPs[last])
);
| 44,513 |
7 | // Authorize an issuer for specific ranges issuer Issuer that will be authorized ranges Ranges for which the issuer will be authorized / | function authorizeRanges(address issuer, Range[] memory ranges) external override onlyOwner {
for (uint256 i = 0; i < ranges.length; i++) {
_authorizeRange(issuer, ranges[i].min, ranges[i].max);
}
}
| function authorizeRanges(address issuer, Range[] memory ranges) external override onlyOwner {
for (uint256 i = 0; i < ranges.length; i++) {
_authorizeRange(issuer, ranges[i].min, ranges[i].max);
}
}
| 25,476 |
50 | // Minimu number of tiers should be 1 and less than or equal to 5 | require(_noOfTiers>=1 && _noOfTiers<=5);
| require(_noOfTiers>=1 && _noOfTiers<=5);
| 2,521 |
937 | // Checks if an address is already delegated _add in concernreturn bool value if the address is delegated or not / | function alreadyDelegated(address _add) public view returns(bool delegated) {
for (uint i=0; i < leaderDelegation[_add].length; i++) {
if (allDelegation[leaderDelegation[_add][i]].leader == _add) {
return true;
}
}
}
| function alreadyDelegated(address _add) public view returns(bool delegated) {
for (uint i=0; i < leaderDelegation[_add].length; i++) {
if (allDelegation[leaderDelegation[_add][i]].leader == _add) {
return true;
}
}
}
| 22,691 |
319 | // info stored for each user's position | struct Info {
bool isEmpty;
int24 tickLower;
int24 tickUpper;
}
| struct Info {
bool isEmpty;
int24 tickLower;
int24 tickUpper;
}
| 27,066 |
9 | // 0xe18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303 |
mapping(address => address) private _bridges;
event LogBridgeSet(address indexed token, address indexed bridge);
event LogConvert(
address indexed server,
address indexed token0,
uint256 amount0,
uint256 amountBENTO,
uint256 amountSUSHI
|
mapping(address => address) private _bridges;
event LogBridgeSet(address indexed token, address indexed bridge);
event LogConvert(
address indexed server,
address indexed token0,
uint256 amount0,
uint256 amountBENTO,
uint256 amountSUSHI
| 45,305 |
7 | // The token Id of the next set of packs to be minted. uint256 public nextTokenIdToMint; |
/*///////////////////////////////////////////////////////////////
Mappings
|
/*///////////////////////////////////////////////////////////////
Mappings
| 27,968 |
57 | // WHITELIST MGMT / | {
bool _didAdd = whitelist.add(_addr);
if (_didAdd) emit AddedToWhitelist(now, _addr, msg.sender);
}
| {
bool _didAdd = whitelist.add(_addr);
if (_didAdd) emit AddedToWhitelist(now, _addr, msg.sender);
}
| 21,645 |
231 | // Lets the token owner alter the end time of an auction in case they want to end an auction early or extendthe auction. This can only be called when the auction has not yet been concluded and is not within a minLastBidDuration from concluding. / | function alterEndTime(uint256 tokenId, uint256 endTime) external {
// 0 EndTimestamp is reserved to check if a tokenId is on auction or not
require(endTime != 0, "End time cannot be 0");
require(_msgSender() == ownerOf(tokenId), "Only token owner can alter end time");
Auction memory ... | function alterEndTime(uint256 tokenId, uint256 endTime) external {
// 0 EndTimestamp is reserved to check if a tokenId is on auction or not
require(endTime != 0, "End time cannot be 0");
require(_msgSender() == ownerOf(tokenId), "Only token owner can alter end time");
Auction memory ... | 33,591 |
51 | // convert to titan | return _wethToTitan(wethAmount);
| return _wethToTitan(wethAmount);
| 2,545 |
20 | // Function to check if an investor is eligible for investing in a TradingContract. | function checkBeta(address _addr) external view returns (bool) {
if (ITradingContract(msg.sender).deployer() == _addr) {
return true;
}
if (testMode) {
return true;
}
if (isParticipantWhitelisted[_addr]) {
return true;
}
... | function checkBeta(address _addr) external view returns (bool) {
if (ITradingContract(msg.sender).deployer() == _addr) {
return true;
}
if (testMode) {
return true;
}
if (isParticipantWhitelisted[_addr]) {
return true;
}
... | 30,245 |
2 | // Associated hird parties (discord, twitch...) | ThirdParty[] linkedThirdParties;
| ThirdParty[] linkedThirdParties;
| 22,191 |
174 | // After EIP-150, max gas cost allowed to be passed to the internal call is equal to the 63/64 of total gas left. In reality, min(gasLimit, 63/64gasleft()) will be used as the call gas limit. Imagine a situation, when message requires 10000000 gas to be executed successfully. Also suppose, that at this point, gasleft()... | require(_gas == 0xffffffff || (gasleft() * 63) / 64 > _gas);
bool status = _contract.call.gas(_gas)(_data);
_validateExecutionStatus(status);
setMessageSender(address(0));
setMessageId(bytes32(0));
setMessageSourceChainId(0);
return status;
| require(_gas == 0xffffffff || (gasleft() * 63) / 64 > _gas);
bool status = _contract.call.gas(_gas)(_data);
_validateExecutionStatus(status);
setMessageSender(address(0));
setMessageId(bytes32(0));
setMessageSourceChainId(0);
return status;
| 34,031 |
132 | // check if the user wants to unwrap its pair or not | if (unwrapPair) {
| if (unwrapPair) {
| 57,129 |
233 | // get the current scaled oracle price/ applies the change smoothly over a 28 day period/ scaled by 18 decimals | function getCurrentOraclePrice() external view returns (uint256);
| function getCurrentOraclePrice() external view returns (uint256);
| 13,998 |
123 | // Returns an URI for a given token IDThrows if the token ID does not exist. May return an empty string. tokenId uint256 ID of the token to query / | function tokenURI(uint256 tokenId) external view returns (string memory) {
require(_exists(tokenId));
return _tokenURIs[tokenId];
}
| function tokenURI(uint256 tokenId) external view returns (string memory) {
require(_exists(tokenId));
return _tokenURIs[tokenId];
}
| 22,849 |
68 | // uses the Multiplier contract for double rewarding------------------------------------------------------ _term --> the lockup term. amountETH --> ETH amount provided in liquidity amountToken --> token amount provided in liquidity wethRP--> return percentge for ETH based on term period tokenRP --> return percentge for... | function _withMultiplier(
uint _term, uint amountETH, uint amountToken, uint wethRP, uint tokenRP
| function _withMultiplier(
uint _term, uint amountETH, uint amountToken, uint wethRP, uint tokenRP
| 74,531 |
17 | // if address not in mapping , returns false | return lockedAccounts[_targetAddress];
| return lockedAccounts[_targetAddress];
| 16,662 |
5 | // The Authorizable constructor sets the first `authorized` of the contract to the senderaccount. / | function Authorizable() public {
authorize(msg.sender);
}
| function Authorizable() public {
authorize(msg.sender);
}
| 31,396 |
5 | // Error message for when the claim manager is used not initialized. / | error NotInitializedClaimManager();
| error NotInitializedClaimManager();
| 30,447 |
382 | // round 56 | ark(i, q, 9799099446406796696742256539758943483211846559715874347178722060519817626047);
sbox_full(i, q);
mix(i, q);
| ark(i, q, 9799099446406796696742256539758943483211846559715874347178722060519817626047);
sbox_full(i, q);
mix(i, q);
| 36,834 |
6 | // A mapping from an address to the balance of tokens held by that address. | mapping ( address => uint256 ) private balances;
| mapping ( address => uint256 ) private balances;
| 32,344 |
14 | // Transfer the token | super._transfer(from, to, tokenId);
| super._transfer(from, to, tokenId);
| 10,109 |
47 | // we check how much LP we have This call only happens once so we can assume a lot here | uint256 totalETHInLSW = (1500 ether + WETH.balanceOf(RESERVE_VAULT) + IDELTA_LSW(LSW).totalWETHEarmarkedForReferrers()) * 2;
uint256 totalInPairRatioE12 = uint256(1500 ether).mul(1e12).div(totalETHInLSW);
rlpPerLP = totalInPairRatioE12.mul(1e6); // 18 - 12
| uint256 totalETHInLSW = (1500 ether + WETH.balanceOf(RESERVE_VAULT) + IDELTA_LSW(LSW).totalWETHEarmarkedForReferrers()) * 2;
uint256 totalInPairRatioE12 = uint256(1500 ether).mul(1e12).div(totalETHInLSW);
rlpPerLP = totalInPairRatioE12.mul(1e6); // 18 - 12
| 30,509 |
278 | // Record race reults | RacerPosition[] storage racePositions = _results[raceId];
unchecked {
for (uint256 i = 0; i < positions.length; ++i) {
racePositions.push(RacerPosition({ racer: racers[indexes[i]], position: positions[i] }));
| RacerPosition[] storage racePositions = _results[raceId];
unchecked {
for (uint256 i = 0; i < positions.length; ++i) {
racePositions.push(RacerPosition({ racer: racers[indexes[i]], position: positions[i] }));
| 17,270 |
48 | // Deleting deadline process/ | uint _winningContributionId = getWinningContribution(_questId);
_transferQuestTokenTo(contributions[_winningContributionId].owner,
quests[_questId].tokenReward);
IERC20Token(cUsdTokenAddress).transferFrom(
address(this),
contributions[_winningContributionId].o... | uint _winningContributionId = getWinningContribution(_questId);
_transferQuestTokenTo(contributions[_winningContributionId].owner,
quests[_questId].tokenReward);
IERC20Token(cUsdTokenAddress).transferFrom(
address(this),
contributions[_winningContributionId].o... | 22,588 |
17 | // withdaw ether from contract | function withdraw() public onlyOwner {
require(address(this).balance > 0, "No ether to withdraw");
msg.sender.transfer(address(this).balance);
}
| function withdraw() public onlyOwner {
require(address(this).balance > 0, "No ether to withdraw");
msg.sender.transfer(address(this).balance);
}
| 36,396 |
29 | // not really needed but better safe then sorry if someone decides to add in a mapping to this array | ArbiterVote memory dummyArbiterVote = ArbiterVote({
state:VoteState.PENDING_VOTE,
arbitrationJobId:0,
vote:0,
arbiterId:0
});
| ArbiterVote memory dummyArbiterVote = ArbiterVote({
state:VoteState.PENDING_VOTE,
arbitrationJobId:0,
vote:0,
arbiterId:0
});
| 48,186 |
31 | // Only allow setting of the timeLockPeriod if the period is greater than the existing | require(
_timeLockPeriod > timeLockPeriod,
"TimeLockUpgradeV2: New period must be greater than existing"
);
timeLockPeriod = _timeLockPeriod;
| require(
_timeLockPeriod > timeLockPeriod,
"TimeLockUpgradeV2: New period must be greater than existing"
);
timeLockPeriod = _timeLockPeriod;
| 40,841 |
33 | // update claim data | claimsData[hash].numEntriesPerUser += priceStruct.numEntries;
claimsData[hash].amountSpentInWeis += msg.value;
emit EntrySold(_raffleId, msg.sender, raffle.entriesLength, _id); // 2377
| claimsData[hash].numEntriesPerUser += priceStruct.numEntries;
claimsData[hash].amountSpentInWeis += msg.value;
emit EntrySold(_raffleId, msg.sender, raffle.entriesLength, _id); // 2377
| 19,687 |
87 | // returns the available liquidity (including LP tokens) for a given asset asset the asset to calculate liquidity forreturn the amount of liquidity available / | function liquidityOf(address asset) public view returns (uint) {
return IERC20(asset).balanceOf(address(this)).
add(IERC20(asset).balanceOf(pair)
.mul(IERC20(pair).balanceOf(address(this)))
.div(IERC20(pair).totalSupply()));
}
| function liquidityOf(address asset) public view returns (uint) {
return IERC20(asset).balanceOf(address(this)).
add(IERC20(asset).balanceOf(pair)
.mul(IERC20(pair).balanceOf(address(this)))
.div(IERC20(pair).totalSupply()));
}
| 51,061 |
44 | // Test coverage [x] Does allowance update correctly? | function setAllowanceForPoolToken(
address spender,
uint256 _pid,
uint256 value
| function setAllowanceForPoolToken(
address spender,
uint256 _pid,
uint256 value
| 3,162 |
126 | // Transfer to non-rebasing account from rebasing account, credits are removed from the non rebasing tally | nonRebasingSupply = nonRebasingSupply.add(_value);
| nonRebasingSupply = nonRebasingSupply.add(_value);
| 11,371 |
1 | // See BaseRewardPool.sol / | constructor(
uint256 pid_,
address stakingToken_,
address rewardToken_,
address operator_,
address rewardManager_,
| constructor(
uint256 pid_,
address stakingToken_,
address rewardToken_,
address operator_,
address rewardManager_,
| 15,845 |
107 | // nothing to do here except update kn = \sum_{i=0}^{m-1}k_i - \sum_{i=m}^{n-1}k_i | kn := addmod(kn, k, gen_order)
| kn := addmod(kn, k, gen_order)
| 43,078 |
3 | // Returns the EIP712 hash of the handled asset data struct.See `getAssetTypedHash` in the subclasses for asset struct type description. / | function getAssetTypedHash(bytes memory data) internal view returns (bytes32);
| function getAssetTypedHash(bytes memory data) internal view returns (bytes32);
| 9,360 |
0 | // Reads the votes that an account has. / | interface IHasVotes {
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account) external view returns (uint96);
/**
* @notice Determin... | interface IHasVotes {
/**
* @notice Gets the current votes balance for `account`
* @param account The address to get votes balance
* @return The number of current votes for `account`
*/
function getCurrentVotes(address account) external view returns (uint96);
/**
* @notice Determin... | 13,264 |
9 | // Vote tracking during 'Pending' phase | mapping (address => bool) outcomeVoters;
uint256 outcomeVotersCount;
uint256 public votersFromForCount;
uint256 public votersFromAgainstCount;
uint256 public votersForCount;
uint256 public votersAgainstCount;
| mapping (address => bool) outcomeVoters;
uint256 outcomeVotersCount;
uint256 public votersFromForCount;
uint256 public votersFromAgainstCount;
uint256 public votersForCount;
uint256 public votersAgainstCount;
| 14,030 |
67 | // deposit registration fee | plyr_[1].gen = (msg.value).add(plyr_[1].gen);
| plyr_[1].gen = (msg.value).add(plyr_[1].gen);
| 7,893 |
21 | // Returns the integer division of two unsigned integers. Reverts with custom message ondivision by zero. The result is rounded towards zero. Counterpart to Solidity's `/` operator. Note: this function uses a`revert` opcode (which leaves remaining gas untouched) while Solidityuses an invalid opcode to revert (consuming... | function div(
uint256 a,
uint256 b,
string memory errorMessage
| function div(
uint256 a,
uint256 b,
string memory errorMessage
| 25,545 |
35 | // FlashLender: Borrow from the bank and enforce repayment by the end of transaction execution.Rich McAteer <rich@marble.org>, Max Wolff <max@marble.org> | contract FlashLender is ReentrancyGuard, Ownable {
using SafeMath for uint256;
string public version = '0.1';
address public bank;
uint256 public fee;
/**
* @dev Verify that the borrowed tokens are returned to the bank plus a fee by the end of transaction execution.
* @param token Addr... | contract FlashLender is ReentrancyGuard, Ownable {
using SafeMath for uint256;
string public version = '0.1';
address public bank;
uint256 public fee;
/**
* @dev Verify that the borrowed tokens are returned to the bank plus a fee by the end of transaction execution.
* @param token Addr... | 68,324 |
103 | // If the price is acceptable relative to the trade type | while (_orderId != 0 && _bestAmount > 0 && _tradeData.loopLimit > 0 && isMatch(_orderId, _type, _orderPrice, _tradeData.price)) {
bytes32 _nextOrderId = _orders.getWorseOrderId(_orderId);
_lastTradePrice = _orderPrice;
_bestAmount = fillOrder.fillOrder(_tradeData.sender, _ord... | while (_orderId != 0 && _bestAmount > 0 && _tradeData.loopLimit > 0 && isMatch(_orderId, _type, _orderPrice, _tradeData.price)) {
bytes32 _nextOrderId = _orders.getWorseOrderId(_orderId);
_lastTradePrice = _orderPrice;
_bestAmount = fillOrder.fillOrder(_tradeData.sender, _ord... | 37,066 |
23 | // Transfers `tokenId` token from `from` to `to`. | * Emits a {Transfer} event.
*/
function _transferFrom(
address from,
address to,
uint256 tokenId
) internal virtual {
require(
_isApprovedOrOwner(msg.sender, tokenId),
"ERC721: transfer caller is not owner nor approved"
);
require... | * Emits a {Transfer} event.
*/
function _transferFrom(
address from,
address to,
uint256 tokenId
) internal virtual {
require(
_isApprovedOrOwner(msg.sender, tokenId),
"ERC721: transfer caller is not owner nor approved"
);
require... | 21,473 |
111 | // Returns the URI for token type `id`. | * If the `\{id\}` substring is present in the URI, it must be replaced by
* clients with the actual token type ID.
*/
function uri(uint256 id) external view returns (string memory);
}
| * If the `\{id\}` substring is present in the URI, it must be replaced by
* clients with the actual token type ID.
*/
function uri(uint256 id) external view returns (string memory);
}
| 1,738 |
695 | // validatorId => bool - is Delegated or not |
mapping (uint => uint) delegated;
|
mapping (uint => uint) delegated;
| 1,099 |
49 | // A custom modifier which permits only approved minters to mint items. | modifier onlyMinters {
require(msg.sender == owner() || approvedMinters[msg.sender],
"You are not an approved minter for this item.");
_;
}
| modifier onlyMinters {
require(msg.sender == owner() || approvedMinters[msg.sender],
"You are not an approved minter for this item.");
_;
}
| 41,350 |
4 | // Works like address.send but with a customizable gas limit Make sure your code is safe for reentrancy when using this function! | function sendETH(
address to,
uint amount,
uint gasLimit
)
internal
returns (bool success)
| function sendETH(
address to,
uint amount,
uint gasLimit
)
internal
returns (bool success)
| 14,409 |
147 | // Collections on the platform are associated with a call to this | * function which will generate a {NiftyBuilderInstance} to house the
* NFTs for that particular artist release.
*
* @param name Of the collection being deployed.
* @param symbol Shorthand token identifier, for wallets, etc.
* @param typeCount The number of different Nifty types (differe... | * function which will generate a {NiftyBuilderInstance} to house the
* NFTs for that particular artist release.
*
* @param name Of the collection being deployed.
* @param symbol Shorthand token identifier, for wallets, etc.
* @param typeCount The number of different Nifty types (differe... | 26,054 |
63 | // Total to go to platform = base fee / platform fee % | uint totalPlatformFee = (contractFunds.mul(PLATFORM_FEE)).div(100);
| uint totalPlatformFee = (contractFunds.mul(PLATFORM_FEE)).div(100);
| 8,417 |
1,383 | // Create a new token and return it to the caller. The caller will become the only minter and burner and the new owner capable of assigning the roles. tokenName used to describe the new token. tokenSymbol short ticker abbreviation of the name. Ideally < 5 chars. tokenDecimals used to define the precision used in the to... | function createToken(
string calldata tokenName,
string calldata tokenSymbol,
uint8 tokenDecimals
| function createToken(
string calldata tokenName,
string calldata tokenSymbol,
uint8 tokenDecimals
| 21,870 |
80 | // transfers from a sender to receipent with subtracting spenders allowance with each successfull transfer / | function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
| function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
_transfer(sender, recipient, amount);
_approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance"));
return true;
}
| 13,577 |
8 | // override this since we're no longer tracking eth deposits / | receive() external virtual override payable {
revert();
}
| receive() external virtual override payable {
revert();
}
| 3,704 |
7 | // adds airline address to the list of addresses | registeredAirlines.push(firstAirline);
| registeredAirlines.push(firstAirline);
| 219 |
432 | // computeProportionalAmountsOut(per token)aO = tokenAmountOut /bptIn \ b = tokenBalancea0 = b| ---------------------|bptIn = bptAmountIn \ bptTotalSupply/bpt = bptTotalSupply/ Since we're computing an amount out, we round down overall. This means rounding down on both the multiplication and division. |
uint256 bptRatio = bptAmountIn.divDown(bptTotalSupply);
amountsOut = new uint256[](balances.length);
for (uint256 i = 0; i < balances.length; i++) {
amountsOut[i] = balances[i].mulDown(bptRatio);
}
|
uint256 bptRatio = bptAmountIn.divDown(bptTotalSupply);
amountsOut = new uint256[](balances.length);
for (uint256 i = 0; i < balances.length; i++) {
amountsOut[i] = balances[i].mulDown(bptRatio);
}
| 29,331 |
3 | // error IllegalAddressError, caller destination account address is invalid / | error IllegalAddressError(address account);
| error IllegalAddressError(address account);
| 23,617 |
236 | // Constants / | function WEI_PER_ETH() internal pure returns (uint256) {
return _WEI_PER_ETH;
}
| function WEI_PER_ETH() internal pure returns (uint256) {
return _WEI_PER_ETH;
}
| 20,199 |
167 | // Function to get token URI of given token IDURI will be blank untill totalSupply reaches MAX_NFT/ | function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
if (tokenId < 1000) {
return bytes(baseURI[0]).length > 0 && totalSupply >= 1000 ? string(abi.encodePacked(baseURI[0], ... | function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
if (tokenId < 1000) {
return bytes(baseURI[0]).length > 0 && totalSupply >= 1000 ? string(abi.encodePacked(baseURI[0], ... | 32,842 |
446 | // Redeem interest and/or principal from an ITranchedPool investment tokenId the ID of an IPoolTokens token to be redeemed / | function redeem(uint256 tokenId) public override whenNotPaused nonReentrant {
IPoolTokens poolTokens = config.getPoolTokens();
IPoolTokens.TokenInfo memory tokenInfo = poolTokens.getTokenInfo(tokenId);
ITranchedPool pool = ITranchedPool(tokenInfo.pool);
(uint256 interestRedeemed, uint256 principalRed... | function redeem(uint256 tokenId) public override whenNotPaused nonReentrant {
IPoolTokens poolTokens = config.getPoolTokens();
IPoolTokens.TokenInfo memory tokenInfo = poolTokens.getTokenInfo(tokenId);
ITranchedPool pool = ITranchedPool(tokenInfo.pool);
(uint256 interestRedeemed, uint256 principalRed... | 61,918 |
15 | // Solidity only automatically asserts when dividing by 0 | require(b > 0, errorMessage);
uint256 c = a / b;
| require(b > 0, errorMessage);
uint256 c = a / b;
| 2,216 |
10 | // Bid count by token address => token id => bid counts | mapping(address => mapping(uint256 => uint256)) public bidCounterByToken;
| mapping(address => mapping(uint256 => uint256)) public bidCounterByToken;
| 30,396 |
82 | // Modifier that validates a purchase at a tierAll the following has to be met:- current time within the offering period- valid sender address and ether value greater than 0.1- total Wei raised not greater than FUNDING_ETH_HARD_CAP- contribution per perticipant within contribution limit/ | modifier validPurchase() {
require(now >= startTime && now <= endTime && stage == Stages.OfferingStarted);
if(now > capReleaseTimestamp) {
maxContribution = 5000 * 1 ether;
}
uint256 contributionInWei = msg.value;
address participant = msg.sender;
require... | modifier validPurchase() {
require(now >= startTime && now <= endTime && stage == Stages.OfferingStarted);
if(now > capReleaseTimestamp) {
maxContribution = 5000 * 1 ether;
}
uint256 contributionInWei = msg.value;
address participant = msg.sender;
require... | 18,976 |
12 | // 储存奖励信息 | mapping (address => bool) public claimed;
event ActionCommitted(uint indexed punkId, uint indexed time, ActionChoices action);
event GoldPicked(uint indexed punkId, uint indexed time, int x, int y, uint amount);
event GoldPut(uint indexed punkId, int x, int y, uint amount, bool isPut);
| mapping (address => bool) public claimed;
event ActionCommitted(uint indexed punkId, uint indexed time, ActionChoices action);
event GoldPicked(uint indexed punkId, uint indexed time, int x, int y, uint amount);
event GoldPut(uint indexed punkId, int x, int y, uint amount, bool isPut);
| 24,748 |
26 | // Sets the treasury fee Throws if setting fee over 20% _treasuryFee The value for the treasury fee / | function setTreasuryFee(uint256 _treasuryFee) public {
require(msg.sender == governance, "!governance");
require(_treasuryFee <= 2000, "_treasuryFee over 20%");
treasuryFee = _treasuryFee;
}
| function setTreasuryFee(uint256 _treasuryFee) public {
require(msg.sender == governance, "!governance");
require(_treasuryFee <= 2000, "_treasuryFee over 20%");
treasuryFee = _treasuryFee;
}
| 39,931 |
55 | // A variant of {claim} that combines multiple claims for the same Champion & version into a single call./This is more efficient than {claimMultiple} since it only checks Champion ownership & verifies Merkle proof once. | function claimMultipleTokensForChampion(
address recipient,
Version version,
ERC20[] calldata tokenList,
Champion champion,
uint256 shares,
bytes32[] calldata merkleProof
) external returns (uint256[] memory claimedTokenAmountList) {
| function claimMultipleTokensForChampion(
address recipient,
Version version,
ERC20[] calldata tokenList,
Champion champion,
uint256 shares,
bytes32[] calldata merkleProof
) external returns (uint256[] memory claimedTokenAmountList) {
| 22,830 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.