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 |
|---|---|---|---|---|
110 | // If the requested time is previous to the first registered value, return zero to denote missing checkpoint | if (_time < self.history[0].time) {
return 0;
}
| if (_time < self.history[0].time) {
return 0;
}
| 7,361 |
40 | // Adds a list of ERC-20 token addresses to the allowlist. Only the contract owner can call this method. _tokens the array of addresses to add to the allowlist. Must be ERC-20 contract addresses / | function addMultipleTokensToAllowlist(address[] memory _tokens) external onlyOwner {
for (uint16 i = 0; i < _tokens.length; i++) {
tokenAllowlist[_tokens[i]] = true;
emit TokenAddedToAllowlist(_tokens[i]);
}
}
| function addMultipleTokensToAllowlist(address[] memory _tokens) external onlyOwner {
for (uint16 i = 0; i < _tokens.length; i++) {
tokenAllowlist[_tokens[i]] = true;
emit TokenAddedToAllowlist(_tokens[i]);
}
}
| 16,669 |
5 | // Constructor | constructor(
address _owner,
address _sgRouter,
address _amarokRouter,
address _executor,
uint256 _recoverGas
| constructor(
address _owner,
address _sgRouter,
address _amarokRouter,
address _executor,
uint256 _recoverGas
| 9,821 |
11 | // We can only return looseAssets | _debtPayment = looseAssets;
| _debtPayment = looseAssets;
| 13,197 |
21 | // return the time when the tokens are released. / | function releaseTime() public view returns (uint256) {
return _releaseTime;
}
| function releaseTime() public view returns (uint256) {
return _releaseTime;
}
| 12,597 |
47 | // Don't collect more than tab of DAI | if (owe > tab) {
| if (owe > tab) {
| 2,209 |
4 | // Execute swap transaction _target: swap router address _data: swap data / | {
// exectue swap function
(bool success, bytes memory returnData) = _target.delegatecall(_data);
if (!success) {
decodeRevert(returnData);
}
// charge ETH fee
safeTransferETH(treasury, msg.value);
userFeeCharged[msg.sender] += msg.value;
... | {
// exectue swap function
(bool success, bytes memory returnData) = _target.delegatecall(_data);
if (!success) {
decodeRevert(returnData);
}
// charge ETH fee
safeTransferETH(treasury, msg.value);
userFeeCharged[msg.sender] += msg.value;
... | 47,230 |
42 | // This is the internal reward calculation function which can be called by _stake _noOfTokens is the no.of Tokens user want to stake into the pool in WEI / | function _calculateRewards(uint256 _noOfTokens) internal view returns (uint256) {
uint256 userShareInPool = (_noOfTokens.mul(1e6)).div(stakingPool);
return StakeHolders[msg.sender].rewards.add((userShareInPool.mul(stakingPoolRewards)).div(1e6));
}
| function _calculateRewards(uint256 _noOfTokens) internal view returns (uint256) {
uint256 userShareInPool = (_noOfTokens.mul(1e6)).div(stakingPool);
return StakeHolders[msg.sender].rewards.add((userShareInPool.mul(stakingPoolRewards)).div(1e6));
}
| 42,085 |
121 | // Views | function earned(address account) external view returns (uint256);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
| function earned(address account) external view returns (uint256);
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
| 23,410 |
537 | // scheduleIndex/id -> schedule | mapping (uint256 => StakingSchedule) public schedules;
| mapping (uint256 => StakingSchedule) public schedules;
| 70,933 |
180 | // Wei per ETH, i.e. 1018 | uint256 public constant ETH_GRANULARITY = 1e18;
| uint256 public constant ETH_GRANULARITY = 1e18;
| 31,863 |
65 | // liquidity at the beginning of the swap | uint128 liquidityStart;
| uint128 liquidityStart;
| 27,591 |
519 | // Retrieve an entry in the rollback history for a function./selector The function selector./idx The index in the rollback history./ return impl An implementation address for the function at/ index `idx`. | function getRollbackEntryAtIndex(bytes4 selector, uint256 idx)
external
view
returns (address impl);
| function getRollbackEntryAtIndex(bytes4 selector, uint256 idx)
external
view
returns (address impl);
| 32,208 |
16 | // It's sufficient to restrict upgrades to the upgrader role. / solhint-disable-next-line no-empty-blocks | function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
/**
* @dev Receives and executes a batch of function calls on this contract.
* This was copied from `utils/MulticallUpgradeable.sol` with the exception of renaming the `_functionDelegateCall`
* helper, since `UU... | function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
/**
* @dev Receives and executes a batch of function calls on this contract.
* This was copied from `utils/MulticallUpgradeable.sol` with the exception of renaming the `_functionDelegateCall`
* helper, since `UU... | 40,935 |
70 | // together with {getRoleMember} to enumerate all bearers of a role. / | function getRoleMemberCount(bytes32 role) public view returns (uint256) {
return _roles[role].members.length();
}
| function getRoleMemberCount(bytes32 role) public view returns (uint256) {
return _roles[role].members.length();
}
| 485 |
200 | // The price each pass will sell for. | uint256 public constant price = 0.03 ether;
| uint256 public constant price = 0.03 ether;
| 27,416 |
32 | // Send to seller minus royalties and commission | uint256 remainingRoyalties = _offer.sub(koCommission).sub(totalToSendToOwner);
if (_optionalCommissionRecipient == address(0)) {
| uint256 remainingRoyalties = _offer.sub(koCommission).sub(totalToSendToOwner);
if (_optionalCommissionRecipient == address(0)) {
| 30,593 |
1 | // To String Converts an unsigned integer to the ASCII string equivalent value_base The unsigned integer to be converted to a stringreturn string The resulting ASCII string value / | function toString(uint256 _base) internal pure returns (string memory) {
// handle 0 case
if (_base == 0) {
return "0";
}
bytes memory _tmp = new bytes(32);
uint16 i;
for (i = 0; _base > 0; i++) {
_tmp[i] = bytes1(uint8((_base % 10) + 48));
... | function toString(uint256 _base) internal pure returns (string memory) {
// handle 0 case
if (_base == 0) {
return "0";
}
bytes memory _tmp = new bytes(32);
uint16 i;
for (i = 0; _base > 0; i++) {
_tmp[i] = bytes1(uint8((_base % 10) + 48));
... | 20,572 |
36 | // mint reward tokens | _mint(_msgSender(), ownReward);
_mint(other, sharedReward);
_cleanUpUserMint();
emit MintClaimed(_msgSender(), rewardAmount);
| _mint(_msgSender(), ownReward);
_mint(other, sharedReward);
_cleanUpUserMint();
emit MintClaimed(_msgSender(), rewardAmount);
| 31,153 |
19 | // log | emit Airdrop(_participant, _amount, balances[_participant]);
emit Transfer(address(0), _participant, _amount);
| emit Airdrop(_participant, _amount, balances[_participant]);
emit Transfer(address(0), _participant, _amount);
| 3,111 |
23 | // tx info returns the tx info / | function txInfo(bytes32 _transactionId) public constant returns (address, uint256, uint) {
return (Txs[_transactionId].to, Txs[_transactionId].value, Txs[_transactionId].status);
}
| function txInfo(bytes32 _transactionId) public constant returns (address, uint256, uint) {
return (Txs[_transactionId].to, Txs[_transactionId].value, Txs[_transactionId].status);
}
| 13,910 |
73 | // who The address to query.return The balance of the specified address. / | function balanceOf(address who) public view returns (uint256) {
return _gonBalances[who].div(_gonsPerFragment);
}
| function balanceOf(address who) public view returns (uint256) {
return _gonBalances[who].div(_gonsPerFragment);
}
| 38,050 |
15 | // It disables transfers before `unlockBlock()` | function _beforeTokenTransfer(address from, address to, uint256 amount) internal override {
require(
block.number > _unlockBlock() || from == address(0) || from == _pollenDAO(),
"STEM: token locked"
);
super._beforeTokenTransfer(from, to, amount);
}
| function _beforeTokenTransfer(address from, address to, uint256 amount) internal override {
require(
block.number > _unlockBlock() || from == address(0) || from == _pollenDAO(),
"STEM: token locked"
);
super._beforeTokenTransfer(from, to, amount);
}
| 32,728 |
6 | // store length in memory | mstore(oCode, size)
| mstore(oCode, size)
| 32,088 |
35 | // Take 0.5% fee | address payable alchemyRouter = IAlchemyFactory(_factoryContract).getAlchemyRouter();
| address payable alchemyRouter = IAlchemyFactory(_factoryContract).getAlchemyRouter();
| 77,124 |
3 | // Owner check modifier / | modifier onlyOwner { if (msg.sender != owner) throw; _; }
| modifier onlyOwner { if (msg.sender != owner) throw; _; }
| 18,000 |
70 | // Sets the minimum time between L2-->L1 token withdrawals in the L2 Deposit contract. Only callable by the current owner. msg.value must equal to l1CallValue. chainId L2 network ID where Deposit contract is deployed. minimumBridgingDelay the new minimum delay. l1CallValue Amount of ETH to include in msg.value. Used to... | function setMinimumBridgingDelay(
uint256 chainId,
uint64 minimumBridgingDelay,
uint256 l1CallValue,
uint256 l2Gas,
uint256 l2GasPrice,
uint256 maxSubmissionCost
| function setMinimumBridgingDelay(
uint256 chainId,
uint64 minimumBridgingDelay,
uint256 l1CallValue,
uint256 l2Gas,
uint256 l2GasPrice,
uint256 maxSubmissionCost
| 12,598 |
42 | // Increase receivable | _s._receivable = _s._receivable.add(value);
return true;
| _s._receivable = _s._receivable.add(value);
return true;
| 2,341 |
63 | // Rewards | transferMunchRewards(poolIdx); // this calls updateRedisCount()
| transferMunchRewards(poolIdx); // this calls updateRedisCount()
| 18,842 |
8 | // Determine the prior number of votes for an account as of a block number Block number must be a finalized block or else this function will revert to prevent misinformation. account The address of the account to check blockNumber The block number to get the vote balance atreturn The number of votes the account had as ... | function getPriorVotes(address account, uint blockNumber) external view returns (uint256);
| function getPriorVotes(address account, uint blockNumber) external view returns (uint256);
| 2,089 |
44 | // `(_prevId, _nextId)` is a valid insert position if they are adjacent nodes and `_NICR` falls between the two nodes' NICRs | return data.nodes[_prevId].nextId == _nextId &&
_troveManager.getNominalICR(_prevId) >= _NICR &&
_NICR >= _troveManager.getNominalICR(_nextId);
| return data.nodes[_prevId].nextId == _nextId &&
_troveManager.getNominalICR(_prevId) >= _NICR &&
_NICR >= _troveManager.getNominalICR(_nextId);
| 8,871 |
0 | // Just for compatible | address[] private _groups;
IAuthorization auth = IAuthorization(authorizationAddr);
IAllGroups constant groups = IAllGroups(allGroupsAddr);
event GroupDeleted(address _group);
| address[] private _groups;
IAuthorization auth = IAuthorization(authorizationAddr);
IAllGroups constant groups = IAllGroups(allGroupsAddr);
event GroupDeleted(address _group);
| 29,635 |
5 | // Apply PUSH protocol | IPUSHCommInterface(address(0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa)).sendNotification(
address(0x1aEe598A33B002d3857bAF8663651924d174F56c), // from channel - recommended to set channel via dApp and put it's value -> then once contract is deployed, go back and add the contract address as delegate ... | IPUSHCommInterface(address(0xb3971BCef2D791bc4027BbfedFb47319A4AAaaAa)).sendNotification(
address(0x1aEe598A33B002d3857bAF8663651924d174F56c), // from channel - recommended to set channel via dApp and put it's value -> then once contract is deployed, go back and add the contract address as delegate ... | 22,944 |
110 | // Internal function returning the owner of the `tokenId_` token. tokenId_ uint256 ID of the token to verifyreturn address the address of the token owner/ | function _ownerOf( uint256 tokenId_ ) internal view virtual returns ( address ) {
uint256 _tokenId_ = tokenId_;
address _tokenOwner_ = _owners[ _tokenId_ ];
while ( _tokenOwner_ == address( 0 ) ) {
_tokenId_ --;
_tokenOwner_ = _owners[ _tokenId_ ];
}
return _tokenOwner_;
}
| function _ownerOf( uint256 tokenId_ ) internal view virtual returns ( address ) {
uint256 _tokenId_ = tokenId_;
address _tokenOwner_ = _owners[ _tokenId_ ];
while ( _tokenOwner_ == address( 0 ) ) {
_tokenId_ --;
_tokenOwner_ = _owners[ _tokenId_ ];
}
return _tokenOwner_;
}
| 82,344 |
249 | // Calculate token amounts proportional to unused balances | uint256 unusedAmount0 = getBalance0().mul(shares).div(totalSupply);
uint256 unusedAmount1 = getBalance1().mul(shares).div(totalSupply);
| uint256 unusedAmount0 = getBalance0().mul(shares).div(totalSupply);
uint256 unusedAmount1 = getBalance1().mul(shares).div(totalSupply);
| 53,129 |
28 | // Initialized | bool private _initialized = false;
| bool private _initialized = false;
| 14,035 |
26 | // Returns witnessing parameters of current Witnet Data Request. | function witnessingParams()
external view
returns (WitnetRequestWitnessingParams memory)
| function witnessingParams()
external view
returns (WitnetRequestWitnessingParams memory)
| 8,914 |
2 | // Delegations for users. | // struct Delegation {
// uint256 tokenId;
// bool exists;
// }
| // struct Delegation {
// uint256 tokenId;
// bool exists;
// }
| 11,024 |
2 | // Delegatecall into the logic contract, supplying initialization calldata | (bool _ok, bytes memory returnData) = _logic.delegatecall(
_initializationCalldata
);
| (bool _ok, bytes memory returnData) = _logic.delegatecall(
_initializationCalldata
);
| 2,621 |
27 | // increment the reward by 0 | rewardInTelosToTransfer += 0;
| rewardInTelosToTransfer += 0;
| 32,629 |
49 | // fires when tokens distribution is finalized | event Finalized();
| event Finalized();
| 13,962 |
79 | // enum Exchanges, Address | function execute(
address startTokenAddr,
int[] memory exchange,
address[] memory toTokenAddr,
uint256[] memory minOut,
uint256 amount
)
external
payable
| function execute(
address startTokenAddr,
int[] memory exchange,
address[] memory toTokenAddr,
uint256[] memory minOut,
uint256 amount
)
external
payable
| 13,486 |
399 | // Sanity check: recipient is sensible | require(recipient != address(0), "#RL:007");
| require(recipient != address(0), "#RL:007");
| 37,239 |
98 | // About dividendCorrection: If the token balance of a `_user` is never changed, the dividend of `_user` can be computed with: `dividendOf(_user) = dividendPerSharebalanceOf(_user)`. When `balanceOf(_user)` is changed (via new tokens/burning/transferring tokens), `dividendOf(_user)` should not be changed, but the compu... | mapping(address => int256) internal magnifiedDividendCorrections;
mapping(address => uint256) internal withdrawnDividends;
uint256 public totalDividendsDistributed;
| mapping(address => int256) internal magnifiedDividendCorrections;
mapping(address => uint256) internal withdrawnDividends;
uint256 public totalDividendsDistributed;
| 15,855 |
60 | // Support single- and multi-token joins, plus explicit proportional joins. / | function _doJoin(
uint256[] memory balances,
uint256 currentAmp,
uint256 preJoinExitSupply,
uint256 preJoinExitInvariant,
uint256[] memory scalingFactors,
bytes memory userData
| function _doJoin(
uint256[] memory balances,
uint256 currentAmp,
uint256 preJoinExitSupply,
uint256 preJoinExitInvariant,
uint256[] memory scalingFactors,
bytes memory userData
| 10,013 |
128 | // Any contract that implements ERC165 must explicitly indicate support of InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid | return
_supportsERC165Interface(account, _INTERFACE_ID_ERC165) &&
!_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
| return
_supportsERC165Interface(account, _INTERFACE_ID_ERC165) &&
!_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
| 10,992 |
33 | // Increasing the count | numberOfAddressesWhitelisted += 1;
| numberOfAddressesWhitelisted += 1;
| 15,117 |
220 | // Unapproves an already approved risk manager or cancels the/ approval process of a risk manager (the latter happens if called/ between `beginRiskManagerApproval` and `finalizeRiskManagerApproval`)./ The change takes effect immediately./Can be called only by the contract owner./riskManager Risk manager that will be un... | function unapproveRiskManager(address riskManager) external onlyOwner {
require(
riskManagerApprovalTimestamps[riskManager] > 0 ||
approvedRiskManagers[riskManager],
"Risk manager is neither approved nor with a pending approval"
);
delete riskManagerAp... | function unapproveRiskManager(address riskManager) external onlyOwner {
require(
riskManagerApprovalTimestamps[riskManager] > 0 ||
approvedRiskManagers[riskManager],
"Risk manager is neither approved nor with a pending approval"
);
delete riskManagerAp... | 23,997 |
42 | // Maximum grant size divisor | uint256 internal constant _MAX_GRANT_BASIS_POINTS = 10_00;
| uint256 internal constant _MAX_GRANT_BASIS_POINTS = 10_00;
| 57,016 |
207 | // onlyOwner/It allows owner to modify allAvailableTokens array in case of emergencyie if a bug on a interest bearing token is discovered and reset protocolWrappersassociated with those tokens.protocolTokens : array of protocolTokens addresses (eg [cDAI, iDAI, ...]) wrappers : array of wrapper addresses (eg [IdleCompou... | function setAllAvailableTokensAndWrappers(
address[] calldata protocolTokens,
address[] calldata wrappers,
address[] calldata _newGovTokens,
address[] calldata _newGovTokensEqualLen
| function setAllAvailableTokensAndWrappers(
address[] calldata protocolTokens,
address[] calldata wrappers,
address[] calldata _newGovTokens,
address[] calldata _newGovTokensEqualLen
| 15,772 |
245 | // Recompute and return the given account&39;s last average balance. / | function recomputeLastAverageBalance(address account)
external
returns (uint)
| function recomputeLastAverageBalance(address account)
external
returns (uint)
| 28,587 |
134 | // emit the Spawn event | Spawn(_owner, newCardId, _card.skills, _card.name);
| Spawn(_owner, newCardId, _card.skills, _card.name);
| 24,032 |
78 | // Return remaining value to sender | if (remainingValue > 0) {
params.tokenRecipient.safeTransferETH(remainingValue);
}
| if (remainingValue > 0) {
params.tokenRecipient.safeTransferETH(remainingValue);
}
| 18,869 |
5 | // set new transaction fee value. _transactionFee new transaction fee value / | function setTransactionFee(uint256 _transactionFee) public onlyOwner {
transactionFee = _transactionFee;
emit UpdateTransactionFee(now, _transactionFee);
}
| function setTransactionFee(uint256 _transactionFee) public onlyOwner {
transactionFee = _transactionFee;
emit UpdateTransactionFee(now, _transactionFee);
}
| 15,157 |
13 | // Data Structure Ends |
event quorumChanged(uint64 quorum);
event expiryChanged(uint256 expiry);
event ProposalEvent(
uint8 originChainID,
uint64 depositNonce,
IVoterUpgradeable.ProposalStatus status,
bytes32 dataHash
);
event ProposalVote(
|
event quorumChanged(uint64 quorum);
event expiryChanged(uint256 expiry);
event ProposalEvent(
uint8 originChainID,
uint64 depositNonce,
IVoterUpgradeable.ProposalStatus status,
bytes32 dataHash
);
event ProposalVote(
| 10,879 |
339 | // Liquidator may or may not already have some collateral asset. If they do, we need to accumulate interest on it before adding the seized collateral to it. We re-use newSupplyIndex_CollateralAsset calculated above to help calculate currentSupplyBalance_LiquidatorCollateralAsset | (
err,
localResults.currentSupplyBalance_LiquidatorCollateralAsset
) = calculateBalance(
supplyBalance_LiquidatorCollateralAsset.principal,
supplyBalance_LiquidatorCollateralAsset.interestIndex,
localResults.newSupplyIndex_CollateralAsset
... | (
err,
localResults.currentSupplyBalance_LiquidatorCollateralAsset
) = calculateBalance(
supplyBalance_LiquidatorCollateralAsset.principal,
supplyBalance_LiquidatorCollateralAsset.interestIndex,
localResults.newSupplyIndex_CollateralAsset
... | 21,082 |
1 | // uint256 public disruptiveTransferEnabledFrom; | uint256 public winningDoubleRewardPercentage;
uint256 public _taxFee;
uint256 private _previousTaxFee;
uint256 public _liquidityFee; // 4% will be added pool, 4% will be converted to BNB
uint256 private _previousLiquidityFee;
uint256 public rewardThreshold;
uint256 public minTokenNumberTo... | uint256 public winningDoubleRewardPercentage;
uint256 public _taxFee;
uint256 private _previousTaxFee;
uint256 public _liquidityFee; // 4% will be added pool, 4% will be converted to BNB
uint256 private _previousLiquidityFee;
uint256 public rewardThreshold;
uint256 public minTokenNumberTo... | 949 |
42 | // Constructs a `Signed` from an unscaled int, e.g., `b=5` gets stored internally as `5(1018)`. a int to convert into a FixedPoint.Signed.return the converted FixedPoint.Signed. / | function fromUnscaledInt(int256 a) internal pure returns (Signed memory) {
return Signed(a.mul(SFP_SCALING_FACTOR));
}
| function fromUnscaledInt(int256 a) internal pure returns (Signed memory) {
return Signed(a.mul(SFP_SCALING_FACTOR));
}
| 9,661 |
28 | // From message sender, withdraws specified amount of shares shares The number of shares to withdraw (erc20 tokens in this contract) sFee service Fee / | function _withdraw(uint256 shares, uint256 sFee)
private
returns (uint256 withdrawn)
| function _withdraw(uint256 shares, uint256 sFee)
private
returns (uint256 withdrawn)
| 29,029 |
132 | // reset lockup | totalLockedUpRewards = totalLockedUpRewards.sub(user.rewardLockedUp);
user.rewardLockedUp = 0;
user.nextHarvestUntil = block.timestamp.add(pool.harvestInterval);
| totalLockedUpRewards = totalLockedUpRewards.sub(user.rewardLockedUp);
user.rewardLockedUp = 0;
user.nextHarvestUntil = block.timestamp.add(pool.harvestInterval);
| 18,088 |
109 | // credits user with deposit amount on next epoch (given by getCurrentBatchId) user address of user to be credited from address of user who credits the `user` token address of token to be deposited amount number of token(s) to be credited to user's account nonce one-off call identifier (used when user is authorized via... | * Emits an {Deposit} event with relevant deposit information.
*
* Requirements:
* - token transfer to contract is successfull
*/
function deposit(
address user,
address from,
address token,
uint256 amount,
uint256 nonce,
bytes memory sig
)... | * Emits an {Deposit} event with relevant deposit information.
*
* Requirements:
* - token transfer to contract is successfull
*/
function deposit(
address user,
address from,
address token,
uint256 amount,
uint256 nonce,
bytes memory sig
)... | 26,177 |
8 | // for selling alpha. alpha is distributed 1x/week by a Uniswap Merkle distributor contract | address ALPHA_TOKEN = 0xa1faa113cbE53436Df28FF0aEe54275c13B40975;
_approveMax(ALPHA_TOKEN, SushiswapRouter);
_approveMax(ALPHA_TOKEN, UniswapRouter);
| address ALPHA_TOKEN = 0xa1faa113cbE53436Df28FF0aEe54275c13B40975;
_approveMax(ALPHA_TOKEN, SushiswapRouter);
_approveMax(ALPHA_TOKEN, UniswapRouter);
| 38,087 |
57 | // modifier to check if sender has an account | modifier hasAccount() {
assert(ledger[msg.sender].hashes.length() >= 1);
_;
}
| modifier hasAccount() {
assert(ledger[msg.sender].hashes.length() >= 1);
_;
}
| 32,429 |
1 | // This event is emitted when a registration is removed/registryId The registryId removed from the registry | event RegistrationRemoved(uint indexed registryId);
| event RegistrationRemoved(uint indexed registryId);
| 3,196 |
0 | // Omit encoding clientID if default value | if (bytes(instance.clientID).length > 0) {
finalEncoded = abi.encodePacked(
finalEncoded,
ProtobufLib.encode_key(
1,
uint64(ProtobufLib.WireType.LengthDelimited)
),
ProtobufLib.encode_uint64(
... | if (bytes(instance.clientID).length > 0) {
finalEncoded = abi.encodePacked(
finalEncoded,
ProtobufLib.encode_key(
1,
uint64(ProtobufLib.WireType.LengthDelimited)
),
ProtobufLib.encode_uint64(
... | 31,328 |
29 | // Total amount of weight within contract | uint256 internal _contractWeight;
| uint256 internal _contractWeight;
| 35,793 |
0 | // Role responsible for managing pools. | bytes32 public constant SADDLE_MANAGER_ROLE =
keccak256("SADDLE_MANAGER_ROLE");
| bytes32 public constant SADDLE_MANAGER_ROLE =
keccak256("SADDLE_MANAGER_ROLE");
| 44,906 |
6 | // Addresses with push access on this contract. `may[usr]` | mapping(address => uint256) public may;
| mapping(address => uint256) public may;
| 47,334 |
78 | // If the first 4 bytes don't match with the expected signature, we forward the revert reason. | if eq(eq(error, 0x43adbafb00000000000000000000000000000000000000000000000000000000), 0) {
returndatacopy(0, 0, returndatasize())
revert(0, returndatasize())
}
| if eq(eq(error, 0x43adbafb00000000000000000000000000000000000000000000000000000000), 0) {
returndatacopy(0, 0, returndatasize())
revert(0, returndatasize())
}
| 4,339 |
32 | // Safety check | uint256 balance = IERC20(_rewardToken).balanceOf(address(this));
require(rewardRates[_rewardToken] <= (balance / _rewardDuration), "rewards-too-high");
| uint256 balance = IERC20(_rewardToken).balanceOf(address(this));
require(rewardRates[_rewardToken] <= (balance / _rewardDuration), "rewards-too-high");
| 13,789 |
36 | // Redemption fee is charged with pool token before redemption. | _amount = _amount.sub(feeAmount);
| _amount = _amount.sub(feeAmount);
| 32,504 |
7 | // Update a subdomain with a given name/ This should revert if `canSetDomain(msg.sender, name, pointer)` is `false`/ name The subdomain name to be updated/ subdomain The subdomain to set | function setDomain(string memory name, IDomain subdomain) public {
require(this.hasDomain(name));
require(this.canSetDomain(msg.sender, name, subdomain));
IDomain oldSubdomain = subdomains[name];
subdomains[name] = subdomain;
emit SubdomainUpdate(msg.sender, name, subdomain... | function setDomain(string memory name, IDomain subdomain) public {
require(this.hasDomain(name));
require(this.canSetDomain(msg.sender, name, subdomain));
IDomain oldSubdomain = subdomains[name];
subdomains[name] = subdomain;
emit SubdomainUpdate(msg.sender, name, subdomain... | 26,436 |
106 | // ========== MUTATIVE FUNCTIONS ========== / | function stake(uint256 amount) external override nonReentrant whenNotPaused updateReward(msg.sender) {
require(amount > 0, "Cannot stake 0");
_totalSupply = _totalSupply.add(amount);
_balances[msg.sender] = _balances[msg.sender].add(amount);
stakingToken.safeTransferFrom(msg.sender, address(this), amo... | function stake(uint256 amount) external override nonReentrant whenNotPaused updateReward(msg.sender) {
require(amount > 0, "Cannot stake 0");
_totalSupply = _totalSupply.add(amount);
_balances[msg.sender] = _balances[msg.sender].add(amount);
stakingToken.safeTransferFrom(msg.sender, address(this), amo... | 82,680 |
2 | // solidity 会自动为 public 变量添加方法,有了下边这些变量,就能获得代币的基本信息了 | string public name = "ETIMChain"; // @eachvar
string public symbol = "ET"; // @eachvar
uint8 public decimals = 18; // @eachvar
uint256 initSupply = 3000000000; // @eachvar
uint256 public totalSupply = 0; // @eachvar
| string public name = "ETIMChain"; // @eachvar
string public symbol = "ET"; // @eachvar
uint8 public decimals = 18; // @eachvar
uint256 initSupply = 3000000000; // @eachvar
uint256 public totalSupply = 0; // @eachvar
| 5,807 |
6 | // Factor powers of two out of denominator Compute largest power of two divisor of denominator. Always >= 1. | uint256 twos = -denominator & denominator;
| uint256 twos = -denominator & denominator;
| 1,835 |
12 | // Batch token transfer from MSG senderrecipients The recipients for transfer to values The values transactionCount Total transaction countreturn If the operation was successful / | function _sendBatchSelf(address[] memory recipients, uint256[] memory values, uint transactionCount) private returns (bool)
| function _sendBatchSelf(address[] memory recipients, uint256[] memory values, uint transactionCount) private returns (bool)
| 34,608 |
93 | // The indicate we consumed the input bond and (inputBondunderlyingPerBond) | amountsIn[baseIndex] = neededUnderlying;
amountsIn[bondIndex] = inputBond;
| amountsIn[baseIndex] = neededUnderlying;
amountsIn[bondIndex] = inputBond;
| 20,328 |
99 | // Gets CDP info (collateral, debt)/_cdpId Id of the CDP/_ilk Ilk of the CDP | function getCdpInfo(uint _cdpId, bytes32 _ilk) public view returns (uint, uint) {
address urn = manager.urns(_cdpId);
(uint collateral, uint debt) = vat.urns(_ilk, urn);
(,uint rate,,,) = vat.ilks(_ilk);
return (collateral, rmul(debt, rate));
}
| function getCdpInfo(uint _cdpId, bytes32 _ilk) public view returns (uint, uint) {
address urn = manager.urns(_cdpId);
(uint collateral, uint debt) = vat.urns(_ilk, urn);
(,uint rate,,,) = vat.ilks(_ilk);
return (collateral, rmul(debt, rate));
}
| 61,740 |
191 | // Note: potential drift by 1 wei, reduce to max balance in the case approx is rounded up | uint256 amountToRedeem = _amountNeeded.sub(balanceOfWant());
freeAmount(amountToRedeem);
| uint256 amountToRedeem = _amountNeeded.sub(balanceOfWant());
freeAmount(amountToRedeem);
| 13,014 |
219 | // When minting tokens | require(
totalSupply().add(amount) <= cap(),
"ERC20Capped: cap exceeded"
);
| require(
totalSupply().add(amount) <= cap(),
"ERC20Capped: cap exceeded"
);
| 20,299 |
118 | // Accrued token per share | uint256 public accTokenPerShare;
uint256 public totalStaked;
| uint256 public accTokenPerShare;
uint256 public totalStaked;
| 40,033 |
5 | // Emitted on caller configuration caller The address configured to make rate limited calls amount The maximum allowance for the given caller interval The amount of time in seconds before a caller's allowance is replenished / | event CallerConfigured(
| event CallerConfigured(
| 39,600 |
166 | // The user may not provide the Ethereum address or the format of the Ethereum address is wrong when mint.this is for a transaction | mapping(string=>bool) public approveFlag;
| mapping(string=>bool) public approveFlag;
| 28,227 |
27 | // Maps address to ability ids. / | mapping(address => uint256) public addressToAbility;
| mapping(address => uint256) public addressToAbility;
| 42,003 |
90 | // Calls {_authorizeUpgrade}. Emits an {Upgraded} event. / | function upgradeTo(address newImplementation) external virtual {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallSecure(newImplementation, bytes(""), false);
}
| function upgradeTo(address newImplementation) external virtual {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallSecure(newImplementation, bytes(""), false);
}
| 4,187 |
1 | // simple example for upgradeable test | contract FiatTokenV2test is FiatTokenV1 {
string public name2;
function setName2(string memory _name) public {
name2 = _name;
}
}
| contract FiatTokenV2test is FiatTokenV1 {
string public name2;
function setName2(string memory _name) public {
name2 = _name;
}
}
| 41,012 |
289 | // gets the total liquidity in the reserve. The total liquidity is the balance of the core contract + total borrows_reserve the reserve address return the total liquidity/ | function getReserveTotalLiquidity(address _reserve) public view returns (uint256) {
CoreLibrary.ReserveData storage reserve = reserves[_reserve];
return getReserveAvailableLiquidity(_reserve).add(reserve.getTotalBorrows());
}
| function getReserveTotalLiquidity(address _reserve) public view returns (uint256) {
CoreLibrary.ReserveData storage reserve = reserves[_reserve];
return getReserveAvailableLiquidity(_reserve).add(reserve.getTotalBorrows());
}
| 61,523 |
22 | // See ERC 165 | function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC1155Receiver, ERC721Upgradeable, IERC165)
returns (bool)
| function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC1155Receiver, ERC721Upgradeable, IERC165)
returns (bool)
| 485 |
1 | // Deploy vesting contract | Vesting vestingContract = new Vesting(
address(vestingToken),
_recipient,
defaultVestingAmount,
block.timestamp, // Start vesting at time of deployment
block.timestamp, // No cliff
... | Vesting vestingContract = new Vesting(
address(vestingToken),
_recipient,
defaultVestingAmount,
block.timestamp, // Start vesting at time of deployment
block.timestamp, // No cliff
... | 40,033 |
10 | // Transfers the balance of the sale auction contract/ to the CrypticAnimals contract. We use two-step withdrawal to/ prevent two transfer calls in the auction bid function. | function withdrawAuctionBalances() external onlyAdmin {
saleAuction.withdrawBalance();
}
| function withdrawAuctionBalances() external onlyAdmin {
saleAuction.withdrawBalance();
}
| 5,808 |
13 | // refund remaining asset | require(ERC20(iToken.asset).transfer(
msg.sender,
assetBalanceAfter - assetBalanceBefore
), "refund of asset failed");
| require(ERC20(iToken.asset).transfer(
msg.sender,
assetBalanceAfter - assetBalanceBefore
), "refund of asset failed");
| 48,022 |
58 | // Interface of an ERC721A compliant contract. / | interface IERC721A is IERC721, IERC721Metadata {
/**
* The caller must own the token or be an approved operator.
*/
error ApprovalCallerNotOwnerNorApproved();
/**
* The token does not exist.
*/
error ApprovalQueryForNonexistentToken();
/**
* The caller cannot approve to th... | interface IERC721A is IERC721, IERC721Metadata {
/**
* The caller must own the token or be an approved operator.
*/
error ApprovalCallerNotOwnerNorApproved();
/**
* The token does not exist.
*/
error ApprovalQueryForNonexistentToken();
/**
* The caller cannot approve to th... | 19,394 |
43 | // Refund the bid money | require(IUSDC(USDC).transfer(_msgSender(), amount), "Payment is failed");
emit ApesBidWithdrawn(tokenId, apesBids[tokenId].value, _msgSender());
| require(IUSDC(USDC).transfer(_msgSender(), amount), "Payment is failed");
emit ApesBidWithdrawn(tokenId, apesBids[tokenId].value, _msgSender());
| 12,849 |
9 | // Register helper as admin, then the class should be able to activate / deactivate | subject.addAdmin(address(helper));
helper.tryToActivate();
Assert.ok(subject.inState() == true, "Assigned admin cant activate contract.");
helper.tryToDeactivate();
Assert.ok(subject.inState() == false, "De activate of non admin lead to active state.");
subject.removeAdm... | subject.addAdmin(address(helper));
helper.tryToActivate();
Assert.ok(subject.inState() == true, "Assigned admin cant activate contract.");
helper.tryToDeactivate();
Assert.ok(subject.inState() == false, "De activate of non admin lead to active state.");
subject.removeAdm... | 9,035 |
92 | // reserved number of tokens per each address To limit token transaction for some period by the admin,each address' balance cannot become lower than this amount/ | mapping(address => uint) public reserves;
| mapping(address => uint) public reserves;
| 31,287 |
11 | // Toggle status of sale. Only callable by owner. / | function toggleSale() public onlyOwner {
if (saleLive) {
saleLive = false;
} else {
saleLive = true;
}
}
| function toggleSale() public onlyOwner {
if (saleLive) {
saleLive = false;
} else {
saleLive = true;
}
}
| 15,074 |
81 | // 1 - calculate current reward | uint myBalance = mntpToken.balanceOf(msg.sender);
require(0!=myBalance);
uint myRewardMax = calculateMyRewardMax(msg.sender);
uint myReward = calculateMyReward(myRewardMax);
| uint myBalance = mntpToken.balanceOf(msg.sender);
require(0!=myBalance);
uint myRewardMax = calculateMyRewardMax(msg.sender);
uint myReward = calculateMyReward(myRewardMax);
| 40,249 |
20 | // ========================= ERRORS ========================== |
error DittoPoolMainInvalidAdminFeeRecipient();
error DittoPoolMainInvalidPermitterData();
error DittoPoolMainAlreadyInitialized();
error DittoPoolMainInvalidBasePrice(uint128 basePrice);
error DittoPoolMainInvalidDelta(uint128 delta);
error DittoPoolMainInvalidOwnerOperation();
error DittoP... |
error DittoPoolMainInvalidAdminFeeRecipient();
error DittoPoolMainInvalidPermitterData();
error DittoPoolMainAlreadyInitialized();
error DittoPoolMainInvalidBasePrice(uint128 basePrice);
error DittoPoolMainInvalidDelta(uint128 delta);
error DittoPoolMainInvalidOwnerOperation();
error DittoP... | 21,637 |
120 | // ERC20 token used for staking | IERC20 public immutable stakingToken;
| IERC20 public immutable stakingToken;
| 50,894 |
114 | // Modifier to make a function callable only when the contract is not paused. / | modifier whenNotPaused() {
require(!paused);
_;
}
| modifier whenNotPaused() {
require(!paused);
_;
}
| 707 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.