Unnamed: 0 int64 0 7.36k | comments stringlengths 3 35.2k | code_string stringlengths 1 527k | code stringlengths 1 527k | __index_level_0__ int64 0 88.6k |
|---|---|---|---|---|
2 | // This algorithm has been extracted from the implementation of smart pool (https:github.com/smartpool) | library Keccak {
function keccakF(uint256[25] memory a) internal pure returns (uint256[25] memory) {
uint256[5] memory c;
uint256[5] memory d;
//uint D_0; uint D_1; uint D_2; uint D_3; uint D_4;
uint256[25] memory b;
uint256[24] memory rc = [
uint256(0x0000000000... | library Keccak {
function keccakF(uint256[25] memory a) internal pure returns (uint256[25] memory) {
uint256[5] memory c;
uint256[5] memory d;
//uint D_0; uint D_1; uint D_2; uint D_3; uint D_4;
uint256[25] memory b;
uint256[24] memory rc = [
uint256(0x0000000000... | 41,875 |
81 | // Return the entitied LP token balance for the given shares./share The number of shares to be converted to LP balance. | function shareToBalance(uint256 share) public view returns (uint256) {
if (totalShare == 0) return share; // When there's no share, 1 share = 1 balance.
(uint256 totalBalance, ) = masterChef.userInfo(pid, address(this));
return share.mul(totalBalance).div(totalShare);
}
| function shareToBalance(uint256 share) public view returns (uint256) {
if (totalShare == 0) return share; // When there's no share, 1 share = 1 balance.
(uint256 totalBalance, ) = masterChef.userInfo(pid, address(this));
return share.mul(totalBalance).div(totalShare);
}
| 31,884 |
7 | // initialization address / | function initialize() initializer public {
__Pausable_init();
__AccessControl_init();
__ReentrancyGuard_init();
// init default values
managerFeeShare = 200; // 20%
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(CONTROLLER_ROLE, msg.sender);
... | function initialize() initializer public {
__Pausable_init();
__AccessControl_init();
__ReentrancyGuard_init();
// init default values
managerFeeShare = 200; // 20%
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(CONTROLLER_ROLE, msg.sender);
... | 32,202 |
43 | // deposits The underlying asset into the reserve. _pool the address of the pool _amount the amount to be deposited / | {
(address _token0, address _token1) = getPoolTokens(_pool);
require(_token0 != address(0), "UnilendV2: POOL NOT FOUND");
uint _nftID = IUnilendV2Position(positionsAddress).getNftId(
_pool,
msg.sender
);
if (_nftID == 0) {
_nftID = IUnilen... | {
(address _token0, address _token1) = getPoolTokens(_pool);
require(_token0 != address(0), "UnilendV2: POOL NOT FOUND");
uint _nftID = IUnilendV2Position(positionsAddress).getNftId(
_pool,
msg.sender
);
if (_nftID == 0) {
_nftID = IUnilen... | 22,370 |
1 | // address public constant devAddress = 0xbF535Abb8E3b277B250d4f9e444E81355A1E68ae; |
uint256 public reservedClaimed;
uint256 public numNFTsMinted;
string public baseTokenURI;
bool public publicSaleStarted;
bool public presaleStarted;
|
uint256 public reservedClaimed;
uint256 public numNFTsMinted;
string public baseTokenURI;
bool public publicSaleStarted;
bool public presaleStarted;
| 19,392 |
23 | // Image | metadata = string(
abi.encodePacked(
metadata,
' "image": "',
string(
abi.encodePacked(
"data:image/svg+xml;base64,",
Base64.encode(bytes(image))
)
... | metadata = string(
abi.encodePacked(
metadata,
' "image": "',
string(
abi.encodePacked(
"data:image/svg+xml;base64,",
Base64.encode(bytes(image))
)
... | 56,538 |
34 | // 40 is the final reward era, almost all tokens mintedonce the final era is reached, more tokens will not be given out because the assert function | if( tokensMinted.add(getMiningReward()) > maxSupplyForEra && rewardEra < 39)
{
rewardEra = rewardEra + 1;
}
| if( tokensMinted.add(getMiningReward()) > maxSupplyForEra && rewardEra < 39)
{
rewardEra = rewardEra + 1;
}
| 11,094 |
33 | // Validates that a given wallet has reached a given nonce Used as an optional transaction on a Sequence batch, to define transaction execution order_wallet Sequence wallet _nonceRequired nonce / | function requireMinNonce(address _wallet, uint256 _nonce) external view {
(uint256 space, uint256 nonce) = _decodeNonce(_nonce);
uint256 currentNonce = IModuleCalls(_wallet).readNonce(space);
require(currentNonce >= nonce, "RequireUtils#requireMinNonce: NONCE_BELOW_REQUIRED");
}
| function requireMinNonce(address _wallet, uint256 _nonce) external view {
(uint256 space, uint256 nonce) = _decodeNonce(_nonce);
uint256 currentNonce = IModuleCalls(_wallet).readNonce(space);
require(currentNonce >= nonce, "RequireUtils#requireMinNonce: NONCE_BELOW_REQUIRED");
}
| 10,532 |
22 | // Calculate trade to sell eggs | function calculateEggSell(uint256 eggs) public view returns(uint256){
return calculateTrade(eggs,marketEggs, tokenContract.myTokens());
}
| function calculateEggSell(uint256 eggs) public view returns(uint256){
return calculateTrade(eggs,marketEggs, tokenContract.myTokens());
}
| 18,096 |
17 | // The function can be called only by crowdsale agent. / | modifier onlyCrowdsaleAgent() {
assert(msg.sender == crowdsaleAgent);
_;
}
| modifier onlyCrowdsaleAgent() {
assert(msg.sender == crowdsaleAgent);
_;
}
| 18,855 |
273 | // our current supply rate.we only calculate once because it is expensive | uint256 currentSR = currentSupplyRate();
| uint256 currentSR = currentSupplyRate();
| 5,889 |
392 | // Unwind liquidity from a protocol (i.e exit a farm) Implementation should unstake LP tokens and remove liquidity If there is only one token to unwind, `index` should be 0 amount Amount of liquidity to unwind index Which token should be unwound / | function unwindLiquidity(uint256 amount, uint8 index) external;
| function unwindLiquidity(uint256 amount, uint8 index) external;
| 12,857 |
270 | // Nov 17 20:00 UTC (1 hour later) | uint32 publicSaleLaunchTime = nHolderSaleLaunchTime + 3600;
DerivativeParameters params = DerivativeParameters(false, false, 0, 383, 4);
mapping(uint256 => bool) public override nUsed;
INOwnerResolver public immutable nOwnerResolver;
IKarmaScore public immutable karmaScoreResolver;
constructo... | uint32 publicSaleLaunchTime = nHolderSaleLaunchTime + 3600;
DerivativeParameters params = DerivativeParameters(false, false, 0, 383, 4);
mapping(uint256 => bool) public override nUsed;
INOwnerResolver public immutable nOwnerResolver;
IKarmaScore public immutable karmaScoreResolver;
constructo... | 17,141 |
91 | // Global Debt Ceiling [wad] | uint256 public override globalDebtCeiling;
| uint256 public override globalDebtCeiling;
| 69,607 |
113 | // Triggers stopped state Only possible when contract not paused. / | function pause() external onlyAdmin whenNotPaused {
_pause();
emit Pause();
}
| function pause() external onlyAdmin whenNotPaused {
_pause();
emit Pause();
}
| 82,072 |
72 | // supplyDelta = totalSupply(price - targetPrice) / targetPrice | int256 pricex1T = price.mul(1000000000000).toInt256Safe();
int256 targetPricex1T = mcap.toInt256Safe();
return BASE.totalSupply().toInt256Safe()
.mul(pricex1T.sub(targetPricex1T))
.div(targetPricex1T);
| int256 pricex1T = price.mul(1000000000000).toInt256Safe();
int256 targetPricex1T = mcap.toInt256Safe();
return BASE.totalSupply().toInt256Safe()
.mul(pricex1T.sub(targetPricex1T))
.div(targetPricex1T);
| 37,350 |
20 | // Returns the attribute's value (from 0 to 15) of an attestationsCollection collectionId Collection Id of the targeted attestationsCollection index Index of the attribute. Can go from 0 to 63. / | function getAttributeValueForAttestationsCollection(
uint256 collectionId,
uint8 index
| function getAttributeValueForAttestationsCollection(
uint256 collectionId,
uint8 index
| 25,483 |
190 | // A mapping from NFT ID to the bidding unit. / | mapping(uint256 => uint256) internal unit;
| mapping(uint256 => uint256) internal unit;
| 3,828 |
55 | // CG: Update previous vote | bytes32 previousDelegateLastProposal = lastVotedOn[previousDelegate];
bytes32 newDelegateLastProposal = lastVotedOn[stakerStake.delegate];
updateVoteIfNeeded(previousDelegateLastProposal, previousDelegate, previousStake, newDelegateLastProposal, stakerStake.delegate, stakerStake.amount);
| bytes32 previousDelegateLastProposal = lastVotedOn[previousDelegate];
bytes32 newDelegateLastProposal = lastVotedOn[stakerStake.delegate];
updateVoteIfNeeded(previousDelegateLastProposal, previousDelegate, previousStake, newDelegateLastProposal, stakerStake.delegate, stakerStake.amount);
| 43,505 |
10 | // Returns the question/// return the answer | function getQuestion() external view override returns(string memory) {
/* solhint-disable not-rely-on-time */
if (block.timestamp >= GENERATE_QUESTION_TIME) {
/* solhint-disable not-rely-on-time */
return question;
} else {
return "please wait for the supercom... | function getQuestion() external view override returns(string memory) {
/* solhint-disable not-rely-on-time */
if (block.timestamp >= GENERATE_QUESTION_TIME) {
/* solhint-disable not-rely-on-time */
return question;
} else {
return "please wait for the supercom... | 27,605 |
5 | // sendFees(); | uint fnftId = getRevest().mintAddressLock(address(this), '', recipients, quantities, fnftConfig);
uint interestRate = getInterestRate(monthsMaturity);
uint allocPoint = amount * interestRate;
StakingData memory cfg = StakingData(monthsMaturity, block.timestamp);
stakingConfigs[... | uint fnftId = getRevest().mintAddressLock(address(this), '', recipients, quantities, fnftConfig);
uint interestRate = getInterestRate(monthsMaturity);
uint allocPoint = amount * interestRate;
StakingData memory cfg = StakingData(monthsMaturity, block.timestamp);
stakingConfigs[... | 30,236 |
150 | // 变更可升级 | upgrade = true;
upgradeContractAddress = upgradeContract;
| upgrade = true;
upgradeContractAddress = upgradeContract;
| 37,165 |
43 | // Receivable Fallback | event Received(address from, uint amount);
| event Received(address from, uint amount);
| 10,391 |
262 | // AFI Distribution Admin // Set the amount of AFI distributed per block afiRate_ The amount of AFI wei per block to distribute / | function _setAFIRate(uint256 afiRate_) public {
require(adminOrInitializing(), "only admin can change afi rate");
uint256 oldRate = afiRate;
afiRate = afiRate_;
emit NewAFIRate(oldRate, afiRate_);
refreshAFISpeedsInternal();
}
| function _setAFIRate(uint256 afiRate_) public {
require(adminOrInitializing(), "only admin can change afi rate");
uint256 oldRate = afiRate;
afiRate = afiRate_;
emit NewAFIRate(oldRate, afiRate_);
refreshAFISpeedsInternal();
}
| 11,114 |
51 | // Returns the current rental balance.return The current rental balance. / | function getRentalBalance() public view returns (uint256) {
return _currentRentalId;
}
| function getRentalBalance() public view returns (uint256) {
return _currentRentalId;
}
| 27,387 |
45 | // initial state, when not set | return underlyingBalanceInVault();
| return underlyingBalanceInVault();
| 9,676 |
1 | // Burns a specific amount of the sender's tokens _value The amount of tokens to be burned / | function burn(uint256 _amount) public {
// Must not burn more than the sender owns
require(_amount <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_amount);
totalSupply = totalSupply.sub(_amount);
Burn(burner, _amount);... | function burn(uint256 _amount) public {
// Must not burn more than the sender owns
require(_amount <= balances[msg.sender]);
address burner = msg.sender;
balances[burner] = balances[burner].sub(_amount);
totalSupply = totalSupply.sub(_amount);
Burn(burner, _amount);... | 21,898 |
101 | // end liquidity lock mechanism. carry on now... |
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
|
if (_isExcluded[sender] && !_isExcluded[recipient]) {
_transferFromExcluded(sender, recipient, amount);
} else if (!_isExcluded[sender] && _isExcluded[recipient]) {
| 2,986 |
80 | // The minimum amount of output tokens that must be received for the transaction not to revert. 0 = accept any amount (slippage is inevitable) | 0,
path,
address(this),
block.timestamp
);
| 0,
path,
address(this),
block.timestamp
);
| 23,709 |
55 | // Gets delta debt generated (Total Safe debt minus available safeHandler COIN balance)/safeEngine address/taxCollector address/safeHandler address/collateralType bytes32/ return deltaDebt | function _getGeneratedDeltaDebt(
address safeEngine,
address taxCollector,
address safeHandler,
bytes32 collateralType,
uint wad
| function _getGeneratedDeltaDebt(
address safeEngine,
address taxCollector,
address safeHandler,
bytes32 collateralType,
uint wad
| 13,036 |
23 | // BENEFICIARY METHODS | /* modifier restrict({
require(msg.sender == reciever);
_;
}) */
| /* modifier restrict({
require(msg.sender == reciever);
_;
}) */
| 6,525 |
141 | // Get more tokens we need | IUpgradableExchange(twoKeyUpgradableExchange).getMore2KeyTokensForRebalancingV1(tokensToTakeFromExchange);
| IUpgradableExchange(twoKeyUpgradableExchange).getMore2KeyTokensForRebalancingV1(tokensToTakeFromExchange);
| 35,467 |
13 | // minimum supply for cutoff | uint32 cutoffSupply;
| uint32 cutoffSupply;
| 25,786 |
95 | // Calculate the auctioneer&39;s cut, so this subtraction can&39;t go negative | uint256 auctioneerCut = _computeCut(price);
sellerProceeds = price - auctioneerCut;
| uint256 auctioneerCut = _computeCut(price);
sellerProceeds = price - auctioneerCut;
| 36,494 |
19 | // Change parcel's receivedTimestamp/parcelId the id of the parcel to set/newTimestamp the new timestamp | function setParcelReceivedTimestamp(bytes32 parcelId, uint newTimestamp) public onlyOwner returns (bool) {
if(newTimestamp == 0){
newTimestamp == now;
}
parcels[parcelId].receivedTimeStamp = newTimestamp;
emit SetParcelReceivedTimestamp(msg.sender, parcelId, parcels[parcelId].id, newTimestamp);
... | function setParcelReceivedTimestamp(bytes32 parcelId, uint newTimestamp) public onlyOwner returns (bool) {
if(newTimestamp == 0){
newTimestamp == now;
}
parcels[parcelId].receivedTimeStamp = newTimestamp;
emit SetParcelReceivedTimestamp(msg.sender, parcelId, parcels[parcelId].id, newTimestamp);
... | 4,562 |
19 | // range: [0, 2112 - 1] resolution: 1 / 2112 | struct uq112x112 {
uint224 _x;
}
| struct uq112x112 {
uint224 _x;
}
| 3,030 |
99 | // update val and suit counts, and if it&39;s a flush | _val = _card % 13;
_valCounts[_val]++;
_suitCounts[_card/13]++;
if (_suitCounts[_card/13] == 5) _hasFlush = true;
| _val = _card % 13;
_valCounts[_val]++;
_suitCounts[_card/13]++;
if (_suitCounts[_card/13] == 5) _hasFlush = true;
| 57,058 |
172 | // See `_checkContractStorageLoad` for more information. | if (gasleft() < MIN_GAS_FOR_INVALID_STATE_ACCESS) {
_revertWithFlag(RevertFlag.OUT_OF_GAS);
}
| if (gasleft() < MIN_GAS_FOR_INVALID_STATE_ACCESS) {
_revertWithFlag(RevertFlag.OUT_OF_GAS);
}
| 79,396 |
14 | // End rewards emission earlier | function updatePeriodFinish(uint timestamp) external onlyOwner updateReward(address(0)) {
periodFinish = timestamp;
}
| function updatePeriodFinish(uint timestamp) external onlyOwner updateReward(address(0)) {
periodFinish = timestamp;
}
| 3,014 |
7 | // add event | RequestPosted(owner, requestClientIndex, _requestName, _requestDescriptionAddr, _testCodeAddr, _reward, _threshold, _requestPostTime, false);
| RequestPosted(owner, requestClientIndex, _requestName, _requestDescriptionAddr, _testCodeAddr, _reward, _threshold, _requestPostTime, false);
| 12,859 |
60 | // BitGuildCrowdsaleCapped crowdsale with a stard/end date / | contract BitGuildCrowdsale {
using SafeMath for uint256;
// Token being sold
BitGuildToken public token;
// Whitelist being used
BitGuildWhitelist public whitelist;
// start and end timestamps where investments are allowed (both inclusive)
uint256 public startTime;
uint256 public endTime;
// Crowd... | contract BitGuildCrowdsale {
using SafeMath for uint256;
// Token being sold
BitGuildToken public token;
// Whitelist being used
BitGuildWhitelist public whitelist;
// start and end timestamps where investments are allowed (both inclusive)
uint256 public startTime;
uint256 public endTime;
// Crowd... | 20,420 |
2 | // Sets the image URL for a specific token. tokenId The ID of the token. imageUrl The new image URL to be set for the specified token.Requirements:- The token with the given tokenId must exist.- Only addresses with the admin role can call this function. / | function setImageUrl(
uint256 tokenId,
string memory imageUrl
| function setImageUrl(
uint256 tokenId,
string memory imageUrl
| 22,947 |
20 | // 放弃所有权 仅所有者可访问 | function renounceOwnership() public onlyOwner {
// 触发转移所有权事件(访问者,合约用户列表第一个人)
emit OwnershipTransferred(_owner, address(0));
// 临时修改当前实例的用户对象为新的继承者 以保证当前合约继续执行
_owner = address(0);
}
| function renounceOwnership() public onlyOwner {
// 触发转移所有权事件(访问者,合约用户列表第一个人)
emit OwnershipTransferred(_owner, address(0));
// 临时修改当前实例的用户对象为新的继承者 以保证当前合约继续执行
_owner = address(0);
}
| 29,697 |
3 | // pluck function - pluck a random item from the array | function pluck(uint256 _tokenId, string memory _keyPrefix, string[] memory _sourceArray) internal pure returns(string memory) {
uint256 randomNumber = random(string(abi.encodePacked(_keyPrefix, Strings.toString(_tokenId))));
string memory output = _sourceArray[randomNumber % _sourceArray.length];
... | function pluck(uint256 _tokenId, string memory _keyPrefix, string[] memory _sourceArray) internal pure returns(string memory) {
uint256 randomNumber = random(string(abi.encodePacked(_keyPrefix, Strings.toString(_tokenId))));
string memory output = _sourceArray[randomNumber % _sourceArray.length];
... | 10,270 |
39 | // 移除黑名单 | function setPersonalStop(address _who) public onlyOwner returns (bool) {
personalStopped[_who] = true;
return true;
}
| function setPersonalStop(address _who) public onlyOwner returns (bool) {
personalStopped[_who] = true;
return true;
}
| 26,200 |
13 | // Returns if the account has the payment token price setter role or/ is the manager/account Account address/ return If the account has the payment token price setter or is the/ manager | function hasPaymentTokenPriceSetterRoleOrIsManager(address account)
internal
view
returns (bool)
| function hasPaymentTokenPriceSetterRoleOrIsManager(address account)
internal
view
returns (bool)
| 34,494 |
104 | // https:etherscan.io/address/0x76884cAFeCf1f7d4146DA6C4053B18B76bf6ED14 | address internal constant CRV_INTEREST_RATE_STRATEGY = 0x76884cAFeCf1f7d4146DA6C4053B18B76bf6ED14;
| address internal constant CRV_INTEREST_RATE_STRATEGY = 0x76884cAFeCf1f7d4146DA6C4053B18B76bf6ED14;
| 15,798 |
113 | // See {IERC721-transferFrom}. / | function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
| function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
| 205 |
3 | // Staking options === | function setMinimumStakeTime(uint256 minTime) public onlyOwner {
minStakeTime = minTime;
}
| function setMinimumStakeTime(uint256 minTime) public onlyOwner {
minStakeTime = minTime;
}
| 17,789 |
7 | // check cap | checkCap(amount);
| checkCap(amount);
| 43,733 |
11 | // See {ITrustedIssuersRegistry-getTrustedIssuerClaimTopics}. / | function getTrustedIssuerClaimTopics(IClaimIssuer _trustedIssuer) external view override returns (uint256[] memory) {
require(trustedIssuerClaimTopics[address(_trustedIssuer)].length != 0, 'trusted Issuer doesn\'t exist');
return trustedIssuerClaimTopics[address(_trustedIssuer)];
}
| function getTrustedIssuerClaimTopics(IClaimIssuer _trustedIssuer) external view override returns (uint256[] memory) {
require(trustedIssuerClaimTopics[address(_trustedIssuer)].length != 0, 'trusted Issuer doesn\'t exist');
return trustedIssuerClaimTopics[address(_trustedIssuer)];
}
| 36,241 |
5 | // Function allows Dapp Creator call to get price / | function getPrice(
| function getPrice(
| 35,254 |
192 | // We invoke doTransferOut for the borrower and the borrowAmount. Note: The aToken must handle variations between ERC-20 and ETH underlying. On success, the aToken borrowAmount less of cash. doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred. / | doTransferOut(borrower, borrowAmount);
| doTransferOut(borrower, borrowAmount);
| 21,469 |
97 | // Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. / | function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = alphabet[value & 0xf];
val... | function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = alphabet[value & 0xf];
val... | 927 |
38 | // Whether or not the proxy should upgrade./ return If the proxy can be upgraded and the new implementation address. | function shouldUpgrade() external view override returns (bool, address) {
return (
nextImplementationTimestamp() != 0
&& block.timestamp > nextImplementationTimestamp()
&& nextImplementation() != address(0),
nextImplementation()
);
}
| function shouldUpgrade() external view override returns (bool, address) {
return (
nextImplementationTimestamp() != 0
&& block.timestamp > nextImplementationTimestamp()
&& nextImplementation() != address(0),
nextImplementation()
);
}
| 71,669 |
0 | // Deploy a Pool./ Make sure that the fyToken follows ERC20 standards with regards to name, symbol and decimals | constructor(IERC20 base_, IFYToken fyToken_, int128 ts_, int128 g1_, int128 g2_)
ERC20Permit(
string(abi.encodePacked(IERC20Metadata(address(fyToken_)).name(), " LP")),
string(abi.encodePacked(IERC20Metadata(address(fyToken_)).symbol(), "LP")),
IERC20Metadata(address(fyTo... | constructor(IERC20 base_, IFYToken fyToken_, int128 ts_, int128 g1_, int128 g2_)
ERC20Permit(
string(abi.encodePacked(IERC20Metadata(address(fyToken_)).name(), " LP")),
string(abi.encodePacked(IERC20Metadata(address(fyToken_)).symbol(), "LP")),
IERC20Metadata(address(fyTo... | 67,981 |
10 | // if sell | if(pair[to] && sellTax > 0) {
amount -= SellFees;
super._transfer(from, address(this), SellFees);
super._transfer(from, to, amount);
}
| if(pair[to] && sellTax > 0) {
amount -= SellFees;
super._transfer(from, address(this), SellFees);
super._transfer(from, to, amount);
}
| 21,676 |
8 | // An ETH backed implementation of the IWasabiErrors. / | contract ETHWasabiPool is AbstractWasabiPool {
receive() external payable override {
emit ETHReceived(msg.value);
}
/**
* @dev Initializes this pool with the given parameters.
*/
function initialize(
IWasabiPoolFactory _factory,
IERC721 _nft,
address _optionNFT... | contract ETHWasabiPool is AbstractWasabiPool {
receive() external payable override {
emit ETHReceived(msg.value);
}
/**
* @dev Initializes this pool with the given parameters.
*/
function initialize(
IWasabiPoolFactory _factory,
IERC721 _nft,
address _optionNFT... | 26,139 |
1,446 | // Constraining the range of funding rates limits the PfC for any dishonest proposer and enhances the perpetual's security. For example, let's examine the case where the max and min funding rates are equivalent to +/- 500%/year. This 1000% funding rate range allows a 8.6% profit from corruption for a proposer who can d... | function _validateFundingRate(FixedPoint.Signed memory rate) internal {
require(
rate.isLessThanOrEqual(_getConfig().maxFundingRate) &&
rate.isGreaterThanOrEqual(_getConfig().minFundingRate)
);
}
| function _validateFundingRate(FixedPoint.Signed memory rate) internal {
require(
rate.isLessThanOrEqual(_getConfig().maxFundingRate) &&
rate.isGreaterThanOrEqual(_getConfig().minFundingRate)
);
}
| 10,487 |
41 | // Increase the dispute count by 1 | uint256 disputeId = self.uintVars[keccak256("disputeCount")] + 1;
self.uintVars[keccak256("disputeCount")] = disputeId;
| uint256 disputeId = self.uintVars[keccak256("disputeCount")] + 1;
self.uintVars[keccak256("disputeCount")] = disputeId;
| 25,968 |
137 | // update reward vairables for a pool | function updatePoolDividend(uint256 _pid) public virtual {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastDividendHeight) {
return;
}
if (pool.tokenAmount == 0) {
pool.lastDividendHeight = block.number;
return;
}
... | function updatePoolDividend(uint256 _pid) public virtual {
PoolInfo storage pool = poolInfo[_pid];
if (block.number <= pool.lastDividendHeight) {
return;
}
if (pool.tokenAmount == 0) {
pool.lastDividendHeight = block.number;
return;
}
... | 17,956 |
99 | // Modifier with the conditions to be able to withdrawbased on exerciseType. / | modifier withdrawWindow() {
require(_isWithdrawWindow(), "PodOption: option has not expired yet");
_;
}
| modifier withdrawWindow() {
require(_isWithdrawWindow(), "PodOption: option has not expired yet");
_;
}
| 62,034 |
32 | // create a modifier that checks if the challenge winners is not set | modifier challengeWinnersIsNotSet {
require(isWinnersSet == false, "Challenge winners is set.");
_;
}
| modifier challengeWinnersIsNotSet {
require(isWinnersSet == false, "Challenge winners is set.");
_;
}
| 24,402 |
24 | // Storing info on the chain | function uploadBabiesImage(bytes calldata s) external onlyOwnerOrManager {}
| function uploadBabiesImage(bytes calldata s) external onlyOwnerOrManager {}
| 11,993 |
38 | // cancel user delegation/makes user his own delegate | function undelegate() public {
return _delegateTo(msg.sender, msg.sender);
}
| function undelegate() public {
return _delegateTo(msg.sender, msg.sender);
}
| 39,598 |
14 | // Logs the market into the registery. _vault: Address of the vault. _creator: Creator of the market. return uint256: Returns the index of market for looking up./ | function registerMarket(
address _marketAddress,
address _vault,
address _creator)
external
isRegisteredDeployer()
returns(uint256)
| function registerMarket(
address _marketAddress,
address _vault,
address _creator)
external
isRegisteredDeployer()
returns(uint256)
| 44,591 |
29 | // Decrease approval | function decreaseApproval (address _spender, uint _subtractedValue) public
| function decreaseApproval (address _spender, uint _subtractedValue) public
| 54,886 |
19 | // The initial COMP index for a market | uint224 public constant compInitialIndex = 1e36;
| uint224 public constant compInitialIndex = 1e36;
| 16,343 |
35 | // Insert node `_new` beside existing node `_node` in direction `_direction`./self stored linked list from contract/_node existing node/_newnew node to insert/_direction direction to insert node in | function insert(LinkedList storage self, uint256 _node, uint256 _new, bool _direction) internal returns (bool) {
if(!nodeExists(self,_new) && nodeExists(self,_node)) {
uint256 c = self.list[_node][_direction];
createLink(self, _node, _new, _direction);
createLink(self, _n... | function insert(LinkedList storage self, uint256 _node, uint256 _new, bool _direction) internal returns (bool) {
if(!nodeExists(self,_new) && nodeExists(self,_node)) {
uint256 c = self.list[_node][_direction];
createLink(self, _node, _new, _direction);
createLink(self, _n... | 25,500 |
6 | // Returns the resolver for the given market. The default is the contract owner_market Market contract address / | function getMarketResolver(address _market) public view returns (address) {
if (marketsToResolvers[_market] != NULL_ADDRESS) {
return marketsToResolvers[_market];
}
return owner();
}
| function getMarketResolver(address _market) public view returns (address) {
if (marketsToResolvers[_market] != NULL_ADDRESS) {
return marketsToResolvers[_market];
}
return owner();
}
| 38,248 |
77 | // be specified by overriding the virtual {_implementation} function.Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to adifferent contract through the {_delegate} function./ Delegates the current call to `implementation`. This function does not return to it... | function _delegate(address implementation) internal virtual {
| function _delegate(address implementation) internal virtual {
| 23,915 |
23 | // 初始化合约,并且把初始的所有的令牌都给这合约的创建者 initialSupply 所有币的总数 tokenName 代币名称 tokenSymbol 代币符号 / | function MyAdvancedToken(
uint256 initialSupply,
string tokenName,
string tokenSymbol
| function MyAdvancedToken(
uint256 initialSupply,
string tokenName,
string tokenSymbol
| 24,936 |
29 | // Set Props for the NFT of the champion | tokenId = currentId;
tokens[currentId].champion = champion;
tokens[currentId].price = price;
tokens[currentId].maxSupply = maxSupply;
tokens[currentId].sponsor = msg.sender;
tokens[currentId].apy = apy;
tokens[currentId].interestProportion = interestProportion;
... | tokenId = currentId;
tokens[currentId].champion = champion;
tokens[currentId].price = price;
tokens[currentId].maxSupply = maxSupply;
tokens[currentId].sponsor = msg.sender;
tokens[currentId].apy = apy;
tokens[currentId].interestProportion = interestProportion;
... | 26,353 |
0 | // 内部函数_msgSender,获取函数调用者地址 / | function _msgSender() internal view returns (address payable) {
return msg.sender;
}
| function _msgSender() internal view returns (address payable) {
return msg.sender;
}
| 14,951 |
4 | // Decrease the buy tax from 99% to normal rate within 3 minutes.Returns buy tax percentage / | function getDynamicBuyTax() public view returns (uint256) {
uint256 endingTime = launchTime + 3 minutes;
if (endingTime > block.timestamp) {
uint256 remainingTime = endingTime - block.timestamp;
return buyTax + 9100 * remainingTime / 3 minutes;
} else {
r... | function getDynamicBuyTax() public view returns (uint256) {
uint256 endingTime = launchTime + 3 minutes;
if (endingTime > block.timestamp) {
uint256 remainingTime = endingTime - block.timestamp;
return buyTax + 9100 * remainingTime / 3 minutes;
} else {
r... | 40,864 |
206 | // address of the aToken representing the asset//address of the interest rate strategy contract/ borrowingEnabled = true means users can borrow from this reserve | bool borrowingEnabled;
| bool borrowingEnabled;
| 24,258 |
37 | // allows Tellor to read data from the addressVars mapping _data is the keccak256("variable_name") of the variable that is being accessed.These are examples of how the variables are saved within other functions:addressVars[keccak256("_owner")]addressVars[keccak256("tellorContract")]return address / | function getAddressVars(bytes32 _data) external view returns (address);
| function getAddressVars(bytes32 _data) external view returns (address);
| 30,892 |
131 | // Max mints per transaction | uint256 private _maxTxMint;
| uint256 private _maxTxMint;
| 66,321 |
5 | // The fee to be charged for a given loan. token The loan currency. amount The amount of tokens lent.return The amount of `token` to be charged for the loan, on top of the returned principal. / | function flashFee(address token, uint256 amount) external view returns (uint256);
| function flashFee(address token, uint256 amount) external view returns (uint256);
| 16,205 |
282 | // Tracking affiliate sponsors | mapping(address => address) public sponsors; // 1 sponsor can have many affiliates, but only 1 sponsor, returns sponsor
| mapping(address => address) public sponsors; // 1 sponsor can have many affiliates, but only 1 sponsor, returns sponsor
| 1,784 |
122 | // Constructs the contract, approves each token inside of baseSwap to be used by baseSwap (needed for addLiquidity()) / | constructor(ISwap _baseSwap, ISynapseBridge _synapseBridge) public {
baseSwap = _baseSwap;
synapseBridge = _synapseBridge;
{
uint8 i;
for (; i < 32; i++) {
try _baseSwap.getToken(i) returns (IERC20 token) {
baseTokens.push(token);
token.safeApprove(address(_baseSwap... | constructor(ISwap _baseSwap, ISynapseBridge _synapseBridge) public {
baseSwap = _baseSwap;
synapseBridge = _synapseBridge;
{
uint8 i;
for (; i < 32; i++) {
try _baseSwap.getToken(i) returns (IERC20 token) {
baseTokens.push(token);
token.safeApprove(address(_baseSwap... | 71,903 |
64 | // Transfers funds from caller to offer maker, and from market to caller. | function buy(uint id, uint amount)
public
can_buy(id)
returns (bool)
| function buy(uint id, uint amount)
public
can_buy(id)
returns (bool)
| 5,110 |
109 | // can later be changed with {transferOwnership}./ Returns the current owner. / | function _getOwner() internal view returns (address) {
return StorageSlot.getAddressSlot(_OWNER_SLOT).value;
}
| function _getOwner() internal view returns (address) {
return StorageSlot.getAddressSlot(_OWNER_SLOT).value;
}
| 47,505 |
6 | // Multiplies two numbers, throws on overflow./ | function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
require(c / a == b);
return c;
}
| function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
if (a == 0) {
return 0;
}
c = a * b;
require(c / a == b);
return c;
}
| 8,831 |
45 | // SBTC Token | i = 2;
| i = 2;
| 79,901 |
82 | // Internal function to batch mint amounts of tokens with the given IDs to The address that will own the minted token ids IDs of the tokens to be minted values Amounts of the tokens to be minted data Data forwarded to `onERC1155Received` if `to` is a contract receiver / | function _batchMint(
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
| function _batchMint(
address to,
uint256[] memory ids,
uint256[] memory values,
bytes memory data
| 79,723 |
66 | // Sets the finalization block number delta in the contract. | /// See also {finalizationBlockNumberDelta}.
/// @param finalizationBlockNumberDelta_ The new finalization block number delta.
function setFinalizationBlockNumberDelta(uint256 finalizationBlockNumberDelta_)
external
onlyRole(ORACLE_MANAGER_ROLE)
{
if (
finalizationBlo... | /// See also {finalizationBlockNumberDelta}.
/// @param finalizationBlockNumberDelta_ The new finalization block number delta.
function setFinalizationBlockNumberDelta(uint256 finalizationBlockNumberDelta_)
external
onlyRole(ORACLE_MANAGER_ROLE)
{
if (
finalizationBlo... | 35,595 |
76 | // Presale constants | uint256 public constant PRESALE_DURATION = 14 days; // pressale duration
uint256 public constant PRESALE_MIN_CONTRIBUTION = 200 ether; // pressale min contribution
| uint256 public constant PRESALE_DURATION = 14 days; // pressale duration
uint256 public constant PRESALE_MIN_CONTRIBUTION = 200 ether; // pressale min contribution
| 40,635 |
56 | // 1531699200 - July, 16, 2018 00:00:00 && 1532563199 - July, 25, 2018 23:59:59 | if( 1531699200 <= _currentDate && _currentDate <= 1532563199){
return 2;
}
| if( 1531699200 <= _currentDate && _currentDate <= 1532563199){
return 2;
}
| 40,985 |
22 | // Transfers StableToken from one address to another on behalf of a user. from The address to transfer StableToken from. to The address to transfer StableToken to. value The amount of StableToken to transfer.return True if the transaction succeeds. / | function transferFrom(address from, address to, uint256 value)
external
updateInflationFactor
onlyWhenNotFrozen
returns (bool)
| function transferFrom(address from, address to, uint256 value)
external
updateInflationFactor
onlyWhenNotFrozen
returns (bool)
| 8,711 |
8 | // We don't use abi.decode for this because of the large amount of zero-padding bytes the circuit would also have to hash. |
deposit.depositType = data.toUint8Unsafe(_offset);
_offset += 1;
deposit.to = data.toAddressUnsafe(_offset);
_offset += 20;
deposit.toAccountID = data.toUint32Unsafe(_offset);
_offset += 4;
deposit.tokenID = data.toUint32Unsafe(_offset);
_offset += 4;
... |
deposit.depositType = data.toUint8Unsafe(_offset);
_offset += 1;
deposit.to = data.toAddressUnsafe(_offset);
_offset += 20;
deposit.toAccountID = data.toUint32Unsafe(_offset);
_offset += 4;
deposit.tokenID = data.toUint32Unsafe(_offset);
_offset += 4;
... | 27,568 |
26 | // Returns an address stored in an arbitrary storage slot./ These storage slots decouple the storage layout from/ solc's automation./_slot The storage slot to retrieve the address from. | function _getAddress(bytes32 _slot) internal view returns (address addr_) {
assembly {
addr_ := sload(_slot)
}
}
| function _getAddress(bytes32 _slot) internal view returns (address addr_) {
assembly {
addr_ := sload(_slot)
}
}
| 41,088 |
14 | // voto no período de tempo aceitável | require(!participations[_id_poll].participants[msg.sender]);// usuário não votou/apostou
VoteStorage storage vote_storage = votes[_id_poll];
uint idx = vote_storage.n_votes;
| require(!participations[_id_poll].participants[msg.sender]);// usuário não votou/apostou
VoteStorage storage vote_storage = votes[_id_poll];
uint idx = vote_storage.n_votes;
| 30,918 |
2 | // The expected owner of adopted animal is this contract | address expectedAnimalAdopter = address(this);
| address expectedAnimalAdopter = address(this);
| 17,831 |
85 | // Add amount to a kitties donation limit | kitties[_kittyId].donationAmount = SafeMath.add(kitties[_kittyId].donationAmount, totalAmount);
emit NewDonation(
id,
_kittyId,
_trustAmount,
_fosterAmount,
totalAmount
);
| kitties[_kittyId].donationAmount = SafeMath.add(kitties[_kittyId].donationAmount, totalAmount);
emit NewDonation(
id,
_kittyId,
_trustAmount,
_fosterAmount,
totalAmount
);
| 51,124 |
24 | // Based on the solidity docs for common patterns: https:solidity.readthedocs.io/en/v0.5.0/common-patterns.html?highlight=seller | contract Owned {
/**
* Constructor
* Sets the message sender as the seller
*/
constructor() public { seller = msg.sender; }
bool public contractRetracted = false;
uint public creationTime = now;
address payable public seller;
address payable public buyer;
address public interm... | contract Owned {
/**
* Constructor
* Sets the message sender as the seller
*/
constructor() public { seller = msg.sender; }
bool public contractRetracted = false;
uint public creationTime = now;
address payable public seller;
address payable public buyer;
address public interm... | 41,279 |
86 | // We emit ModifiedHoldings later |
_minterest(investor);
|
_minterest(investor);
| 7,529 |
11 | // calculate price based on affiliate usage and mint discounts | function computePrice(
uint256 price,
Discount storage discounts,
uint256 numTokens,
bool affiliateUsed
| function computePrice(
uint256 price,
Discount storage discounts,
uint256 numTokens,
bool affiliateUsed
| 19,796 |
199 | // adding seperate function setupContractId since initialize is already called with old implementation | function setupContractId()
external
only(DEFAULT_ADMIN_ROLE)
| function setupContractId()
external
only(DEFAULT_ADMIN_ROLE)
| 42,184 |
6 | // Sets a new series of stages, overwriting any existing stages and cancelling any stages after the last new stage.registrant the address of the registrant the schedule is managed by scheduleId the id of the schedule to update the stages for firstStageIndex the index from which to update stages stages array of new stag... | function setStages(
| function setStages(
| 28,495 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.