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 |
|---|---|---|---|---|
5 | // Solidity only automatically asserts when dividing by 0 | require(b > 0);
uint256 c = a / b;
| require(b > 0);
uint256 c = a / b;
| 41,060 |
4 | // 设定初始值 |
mapping (address => mapping (address => uint256)) public allowance;
event FrozenFunds(address target, bool frozen);
event Transfer(address indexed from, address indexed to, uint256 value);
string public name;
string public symbol;
uint8 public decimals = 2;
|
mapping (address => mapping (address => uint256)) public allowance;
event FrozenFunds(address target, bool frozen);
event Transfer(address indexed from, address indexed to, uint256 value);
string public name;
string public symbol;
uint8 public decimals = 2;
| 49,621 |
3 | // Deposit all Balancer Pool Tokens (BPT) in this strategy contractto the Aura rewards pool. / | function _lpDepositAll() internal virtual override {
uint256 bptBalance = IERC20(platformAddress).balanceOf(address(this));
uint256 auraLp = IERC4626(auraRewardPoolAddress).deposit(
bptBalance,
address(this)
);
require(bptBalance == auraLp, "Aura LP != BPT");
... | function _lpDepositAll() internal virtual override {
uint256 bptBalance = IERC20(platformAddress).balanceOf(address(this));
uint256 auraLp = IERC4626(auraRewardPoolAddress).deposit(
bptBalance,
address(this)
);
require(bptBalance == auraLp, "Aura LP != BPT");
... | 10,530 |
73 | // Verify the address was actually on a whitelist | require(previousWhitelist != NO_WHITELIST, "Address cannot be removed from invalid whitelist.");
| require(previousWhitelist != NO_WHITELIST, "Address cannot be removed from invalid whitelist.");
| 1,437 |
2 | // We load and return the result | return testString;
| return testString;
| 31,006 |
8 | // thrown when a withdraw request amount does not cover the withdraw fee at processing time | error AvoDepositManager__FeeNotCovered();
| error AvoDepositManager__FeeNotCovered();
| 10,762 |
334 | // The COMP market supply state for each market | mapping(address => CompMarketState) public compSupplyState;
| mapping(address => CompMarketState) public compSupplyState;
| 7,320 |
123 | // Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first... | function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
| function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
| 3,291 |
1 | // 候选者 | struct Candidate {
uint number; //候选者编号
string name; //名字
uint count; //票数
}
| struct Candidate {
uint number; //候选者编号
string name; //名字
uint count; //票数
}
| 25,056 |
5 | // Allow a user to deposit underlying tokens and mint the corresponding number of wrapped tokens. / | function depositFor(address account, uint256 value) public virtual returns (bool) {
address sender = _msgSender();
if (sender == address(this)) {
revert ERC20InvalidSender(address(this));
}
if (account == address(this)) {
revert ERC20InvalidReceiver(account);
... | function depositFor(address account, uint256 value) public virtual returns (bool) {
address sender = _msgSender();
if (sender == address(this)) {
revert ERC20InvalidSender(address(this));
}
if (account == address(this)) {
revert ERC20InvalidReceiver(account);
... | 551 |
10 | // MINT set slot 0 to lock duration + block.timestamp | if (from == address(0)) {
uint256 lock_duration = default_lock_duration;
if (lock_duration > 0) _lock(to, lock_duration);
}
| if (from == address(0)) {
uint256 lock_duration = default_lock_duration;
if (lock_duration > 0) _lock(to, lock_duration);
}
| 16,589 |
56 | // Inheritancea | interface IStakingRewards {
// Views
function lastTimeRewardApplicable() external view returns (uint256);
function rewardPerToken() external view returns (uint256);
function earned(address account) external view returns (uint256);
function getRewardForDuration() external view returns (uint256);
... | interface IStakingRewards {
// Views
function lastTimeRewardApplicable() external view returns (uint256);
function rewardPerToken() external view returns (uint256);
function earned(address account) external view returns (uint256);
function getRewardForDuration() external view returns (uint256);
... | 6,798 |
2,016 | // 1009 | entry "unauctioned" : ENG_ADJECTIVE
| entry "unauctioned" : ENG_ADJECTIVE
| 17,621 |
208 | // Stake CAKE tokens to MasterChef | function enterStaking(uint256 _amount) public {
PoolInfo storage pool = poolInfo[0];
UserInfo storage user = userInfo[0][msg.sender];
updatePool(0);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accCakePerShare).div(1e12).sub(user.rewardDebt);
... | function enterStaking(uint256 _amount) public {
PoolInfo storage pool = poolInfo[0];
UserInfo storage user = userInfo[0][msg.sender];
updatePool(0);
if (user.amount > 0) {
uint256 pending = user.amount.mul(pool.accCakePerShare).div(1e12).sub(user.rewardDebt);
... | 2,330 |
33 | // call event from transaction means | emit LogFundingReceived(msg.sender, msg.value, amountRaised, id);
if (amountRaised >= softcap) {
if (amountRaised >= hardcap) {
completeAt = now;
| emit LogFundingReceived(msg.sender, msg.value, amountRaised, id);
if (amountRaised >= softcap) {
if (amountRaised >= hardcap) {
completeAt = now;
| 52,892 |
897 | // Reads the int248 at `mPtr` in memory. | function readInt248(MemoryPointer mPtr) internal pure returns (int248 value) {
assembly {
value := mload(mPtr)
}
}
| function readInt248(MemoryPointer mPtr) internal pure returns (int248 value) {
assembly {
value := mload(mPtr)
}
}
| 40,528 |
41 | // overflow/underflow not possible bc governmentFeeUnits < 20000 | unchecked {
uint256 governmentFee = (rMintQty * cache.governmentFeeUnits) / C.FEE_UNITS;
uint256 dexFee = rMintQty/cache.dexFraction;
cache.governmentFee += governmentFee;
cache.dexFee += dexFee;
uint256 lpFee = rMintQty - governmentFee;
lpFee = lpFee-... | unchecked {
uint256 governmentFee = (rMintQty * cache.governmentFeeUnits) / C.FEE_UNITS;
uint256 dexFee = rMintQty/cache.dexFraction;
cache.governmentFee += governmentFee;
cache.dexFee += dexFee;
uint256 lpFee = rMintQty - governmentFee;
lpFee = lpFee-... | 27,239 |
23 | // Sys Privileges | bytes4 internal constant DEFINE_ROLE_PRIV =
bytes4(keccak256("defineRole(bytes32,bytes4[])"));
bytes4 internal constant ASSIGN_OPERATORS_PRIV =
bytes4(keccak256("assignOperators(bytes32,address[])"));
bytes4 internal constant REVOKE_OPERATORS_PRIV =
bytes4(keccak256("revokeOperators(address[])"));
b... | bytes4 internal constant DEFINE_ROLE_PRIV =
bytes4(keccak256("defineRole(bytes32,bytes4[])"));
bytes4 internal constant ASSIGN_OPERATORS_PRIV =
bytes4(keccak256("assignOperators(bytes32,address[])"));
bytes4 internal constant REVOKE_OPERATORS_PRIV =
bytes4(keccak256("revokeOperators(address[])"));
b... | 39,932 |
3 | // The constructor sets the original `owner` of the contract to the sender account. / | constructor()
| constructor()
| 9,685 |
517 | // emitted when rate limit is updated | event IndividualRateLimitPerSecondUpdate(
address rateLimitedAddress,
uint256 oldRateLimitPerSecond,
uint256 newRateLimitPerSecond
);
| event IndividualRateLimitPerSecondUpdate(
address rateLimitedAddress,
uint256 oldRateLimitPerSecond,
uint256 newRateLimitPerSecond
);
| 48,316 |
0 | // The address interpreted as native token of the chain. | address public constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
| address public constant NATIVE_TOKEN = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
| 17,184 |
16 | // Returns a new slice containing the same data as the current slice. self The slice to copy.return A new slice containing the same data as `self`. / | function copy(slice self) internal pure returns (slice) {
return slice(self._len, self._ptr);
}
| function copy(slice self) internal pure returns (slice) {
return slice(self._len, self._ptr);
}
| 15,564 |
2 | // @inheritdoc IAuthorizeMints/reverts when signature is not valid or recovered signer is not trustedtodo consider using an ERC712 typed signature here/signedAuthorization contains encoded SignedMintAuthorization that a trusted signer has agreed upon | function authorizeMint(address minter, address to, bytes memory signedAuthorization) external view override returns (bool) {
SignedMintAuthorization memory auth = abi.decode(signedAuthorization, (SignedMintAuthorization));
bytes32 signedHash = ECDSA.toEthSignedMessageHash(keccak256(abi.encodePacked... | function authorizeMint(address minter, address to, bytes memory signedAuthorization) external view override returns (bool) {
SignedMintAuthorization memory auth = abi.decode(signedAuthorization, (SignedMintAuthorization));
bytes32 signedHash = ECDSA.toEthSignedMessageHash(keccak256(abi.encodePacked... | 3,128 |
11 | // Maintains a doubly linked list keyed by address. Following the `next` pointers will lead you to the head, rather than the tail. / | library AddressLinkedList {
using LinkedList for LinkedList.List;
function toBytes(address a) public pure returns (bytes32) {
return bytes32(uint256(a) << 96);
}
function toAddress(bytes32 b) public pure returns (address) {
return address(uint256(b) >> 96);
}
/**
* @notice Inserts an element i... | library AddressLinkedList {
using LinkedList for LinkedList.List;
function toBytes(address a) public pure returns (bytes32) {
return bytes32(uint256(a) << 96);
}
function toAddress(bytes32 b) public pure returns (address) {
return address(uint256(b) >> 96);
}
/**
* @notice Inserts an element i... | 38,363 |
25 | // (z - omega^{n-1}) for this part | PairingsBn254.Fr memory last_omega = vk.omega.pow(vk.domain_size - 1);
state.z_minus_last_omega = state.z.copy();
state.z_minus_last_omega.sub_assign(last_omega);
t.mul_assign(state.z_minus_last_omega);
result.add_assign(t);
| PairingsBn254.Fr memory last_omega = vk.omega.pow(vk.domain_size - 1);
state.z_minus_last_omega = state.z.copy();
state.z_minus_last_omega.sub_assign(last_omega);
t.mul_assign(state.z_minus_last_omega);
result.add_assign(t);
| 20,723 |
68 | // private function to claim rewards for multiple pids/_pids array pids, pools to claim | function _harvestMultiple(uint256[] memory _pids)
private
returns (
uint256,
uint256[] memory,
uint256[] memory
)
| function _harvestMultiple(uint256[] memory _pids)
private
returns (
uint256,
uint256[] memory,
uint256[] memory
)
| 15,783 |
42 | // this is specifically important for rootState that should update real balance only once | require(
stateHashBalances[stateHash][_user] == 0,
"stateHash already proved"
);
bytes32 leafHash = keccak256(abi.encode(_user, _balance));
bool isProofValid = checkProofOrdered(
_proof,
stateHash,
leafHash,
| require(
stateHashBalances[stateHash][_user] == 0,
"stateHash already proved"
);
bytes32 leafHash = keccak256(abi.encode(_user, _balance));
bool isProofValid = checkProofOrdered(
_proof,
stateHash,
leafHash,
| 79,623 |
4 | // flash loan | flashLoanerPool.functionCall(
abi.encodeWithSignature(
"flashLoan(uint256)",
amount
)
);
| flashLoanerPool.functionCall(
abi.encodeWithSignature(
"flashLoan(uint256)",
amount
)
);
| 2,856 |
7 | // remove a fee collectoronly callable by `owner()` / | function removeFeeCollector(address account) external override onlyOwner {
_removeFeeCollector(account);
}
| function removeFeeCollector(address account) external override onlyOwner {
_removeFeeCollector(account);
}
| 11,959 |
2 | // burns pool tokens and transfers underlying tokens _receiver the address of the receiver _amount the amount of pool tokens / | function burn(address _receiver, uint256 _amount) public returns (uint256 redeemedAmount){
require(balanceOf[msg.sender] >= _amount, "insufficient balance");
balanceOf[msg.sender] -= _amount;
IERC20Token(loanTokenAddress).transfer(address(_receiver), _amount);
return _amount;
}
| function burn(address _receiver, uint256 _amount) public returns (uint256 redeemedAmount){
require(balanceOf[msg.sender] >= _amount, "insufficient balance");
balanceOf[msg.sender] -= _amount;
IERC20Token(loanTokenAddress).transfer(address(_receiver), _amount);
return _amount;
}
| 26,955 |
73 | // _token should be address(0) or WBTC_ADDR, txid should be unique txs[_token][_txid] = _addressesAndAmountOfLPtoken; emit RecordOutcomingFloat(_token, _addressesAndAmountOfLPtoken, _txid); | require(
_burnLPTokensForFloat(_token, _addressesAndAmountOfLPtoken, _txid)
);
return true;
| require(
_burnLPTokensForFloat(_token, _addressesAndAmountOfLPtoken, _txid)
);
return true;
| 27,741 |
230 | // constants | uint256 immutable public MAX_LANDS;
uint256 immutable public MAX_LANDS_WITH_FUTURE;
uint256 immutable public MAX_ALPHA_NFT_AMOUNT;
uint256 immutable public MAX_BETA_NFT_AMOUNT;
uint256 immutable public MAX_PUBLIC_SALE_AMOUNT;
uint256 immutable public RESERVED_CONTRIBUTORS_AMOUNT;
uint256 imm... | uint256 immutable public MAX_LANDS;
uint256 immutable public MAX_LANDS_WITH_FUTURE;
uint256 immutable public MAX_ALPHA_NFT_AMOUNT;
uint256 immutable public MAX_BETA_NFT_AMOUNT;
uint256 immutable public MAX_PUBLIC_SALE_AMOUNT;
uint256 immutable public RESERVED_CONTRIBUTORS_AMOUNT;
uint256 imm... | 19,757 |
12 | // Returns the cost associated with placing a claim. claimed The name being claimed.return The cost in wei for this claim. / | function getClaimCost(string memory claimed) public view returns(uint) {
return priceOracle.price(claimed, 0, REGISTRATION_PERIOD);
}
| function getClaimCost(string memory claimed) public view returns(uint) {
return priceOracle.price(claimed, 0, REGISTRATION_PERIOD);
}
| 43,224 |
64 | // Transfers amount of deposit tokens from the caller on behalf of user. user User address who gains credit for this stake operation. amount Number of deposit tokens to stake. data Not used. / | function stakeFor(address user, uint256 amount, bytes calldata data) external {
_stakeFor(msg.sender, user, amount);
}
| function stakeFor(address user, uint256 amount, bytes calldata data) external {
_stakeFor(msg.sender, user, amount);
}
| 17,406 |
43 | // Recover the message signer from a DelegateAdd and a signature. v EIP-155 calculated Signature v value r ECDSA Signature r value s ECDSA Signature s value change DelegateRemove data containing nonce, delegate address, end blockreturn signer address (or some arbitrary address if signature is incorrect) / | function delegateRemoveSigner(
uint8 v,
bytes32 r,
bytes32 s,
DelegateRemove calldata change
| function delegateRemoveSigner(
uint8 v,
bytes32 r,
bytes32 s,
DelegateRemove calldata change
| 31,144 |
470 | // In Chainlink decimals | function getFPIPriceE18() public view returns (uint256) {
(uint80 roundID, int price, , uint256 updatedAt, uint80 answeredInRound) = priceFeedFPIUSD.latestRoundData();
require(price >= 0 && updatedAt!= 0 && answeredInRound >= roundID, "Invalid chainlink price");
return ((uint256(price) * 1e... | function getFPIPriceE18() public view returns (uint256) {
(uint80 roundID, int price, , uint256 updatedAt, uint80 answeredInRound) = priceFeedFPIUSD.latestRoundData();
require(price >= 0 && updatedAt!= 0 && answeredInRound >= roundID, "Invalid chainlink price");
return ((uint256(price) * 1e... | 37,336 |
278 | // Record the fee payment in our recentFeePeriods | feesPaid = _recordFeePayment(availableFees);
| feesPaid = _recordFeePayment(availableFees);
| 9,787 |
221 | // Mint unit back to investor | function _getNewFundUnits(uint256 totalFundB4, uint256 totalValueAfter, uint256 totalSupply)
| function _getNewFundUnits(uint256 totalFundB4, uint256 totalValueAfter, uint256 totalSupply)
| 16,775 |
14 | // Update refer info | function _updateReferInfo(address _user, uint256 _amount) private {
UserInfo storage user = userInfo[_user];
address upline = user.referrer;
for (uint256 i = 0; upline != address(0) && i < LEVEL_COUNT; i++) {
userInfo[upline].totalTeamStake = userInfo[upline].totalTeamStake.add(... | function _updateReferInfo(address _user, uint256 _amount) private {
UserInfo storage user = userInfo[_user];
address upline = user.referrer;
for (uint256 i = 0; upline != address(0) && i < LEVEL_COUNT; i++) {
userInfo[upline].totalTeamStake = userInfo[upline].totalTeamStake.add(... | 15,538 |
15 | // return if we can't claim anything | return 0;
| return 0;
| 10,646 |
255 | // increments the value of _currentTokenId / | function _incrementTokenId() private {
require(_currentTokenId < MAX_SUPPLY);
_currentTokenId++;
}
| function _incrementTokenId() private {
require(_currentTokenId < MAX_SUPPLY);
_currentTokenId++;
}
| 3,173 |
110 | // Transfer ownership of data contract to _addr _addr address / | function transferDataOwnership(address _addr) onlyOwner public {
data.transferOwnership(_addr);
}
| function transferDataOwnership(address _addr) onlyOwner public {
data.transferOwnership(_addr);
}
| 80,684 |
8 | // Signals that part of the locked AVAX balance has been cleared to a given address | event AVAXTransferred(uint256 amount, address recipient);
| event AVAXTransferred(uint256 amount, address recipient);
| 20,624 |
74 | // Mapping owner address to token count | mapping (address => uint256) private _balances;
| mapping (address => uint256) private _balances;
| 1,660 |
4 | // check the msg.sender | require(presidential[msg.sender], "Sorry! You don't have presidential to mint!");
_mint(account, amount);
| require(presidential[msg.sender], "Sorry! You don't have presidential to mint!");
_mint(account, amount);
| 56,165 |
52 | // Destructible Base contract that can be destroyed by owner. All funds in contract will be sent to the owner. / | contract Destructible is Ownable {
function Destructible() public payable { }
/**
* @dev Transfers the current balance to the owner and terminates the contract.
*/
function destroy() onlyOwner public {
selfdestruct(owner);
}
function destroyAndSend(address _recipient) onlyOwner public {
selfd... | contract Destructible is Ownable {
function Destructible() public payable { }
/**
* @dev Transfers the current balance to the owner and terminates the contract.
*/
function destroy() onlyOwner public {
selfdestruct(owner);
}
function destroyAndSend(address _recipient) onlyOwner public {
selfd... | 8,539 |
87 | // If _opPokeData is in state 3, emit event to indicate a possibly valid opPoke was dropped. | if (!opPokeDataFinalized) {
emit OpPokeDataDropped(msg.sender, opPokeData);
}
| if (!opPokeDataFinalized) {
emit OpPokeDataDropped(msg.sender, opPokeData);
}
| 2,295 |
67 | // Anyone can purchase a road as long as the sale exists/_x The x coordinate of the road/_y The y coordinate of the road/_direction The direction of the road | function purchaseRoad(uint _x, uint _y, uint8 _direction)
public
payable
notPaused
existingRoadSale(_x, _y, _direction)
| function purchaseRoad(uint _x, uint _y, uint8 _direction)
public
payable
notPaused
existingRoadSale(_x, _y, _direction)
| 21,110 |
12 | // / |
mapping(uint256 => uint256) tokensG2L; // globalId => packed
mapping(uint256 => mapping (uint256 => uint256)) tokensL2G; // typeId => localTokenId => globalId
function getGlobalId(uint typeId, uint localTokenId) public view returns ( uint tokenId )
|
mapping(uint256 => uint256) tokensG2L; // globalId => packed
mapping(uint256 => mapping (uint256 => uint256)) tokensL2G; // typeId => localTokenId => globalId
function getGlobalId(uint typeId, uint localTokenId) public view returns ( uint tokenId )
| 961 |
69 | // [ TAL -> Bridge -> Tokens ] Check Bridge Fee | require(msg.value >= BRIDGE_FEE, 'XSwapBridge: INSUFFICIENT_BRIDGE_FEE');
| require(msg.value >= BRIDGE_FEE, 'XSwapBridge: INSUFFICIENT_BRIDGE_FEE');
| 17,084 |
95 | // This is an alternative to {approve} that can be used as a mitigation forproblems described in {IBEP20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address.- `spender` must have allowance for the caller of at least`subtractedValue`. / | function decreaseAllowance(address spender, uint256 subtractedValue) public virtual onlyOwner returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "BEP20: decreased allowance below zero");
_approve(_msgSender(), spender,... | function decreaseAllowance(address spender, uint256 subtractedValue) public virtual onlyOwner returns (bool) {
uint256 currentAllowance = _allowances[_msgSender()][spender];
require(currentAllowance >= subtractedValue, "BEP20: decreased allowance below zero");
_approve(_msgSender(), spender,... | 6,351 |
243 | // This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. implement alternative mechanisms to perform token transfer, such as signature-based. Requirements: - `from` cannot be the zero address. - `to` cannot be the zero address. - `tokenId` token must exist and be owned by `from`. - If `to`... | function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
| function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
| 4,369 |
503 | // calculate the number of intervals that have passed | uint256 timeDiff = block.timestamp.sub(nextRebaseTime);
uint256 intervals = timeDiff.div(rebaseInterval).add(1);
| uint256 timeDiff = block.timestamp.sub(nextRebaseTime);
uint256 intervals = timeDiff.div(rebaseInterval).add(1);
| 13,260 |
62 | // Pause contract operations, if contract is not paused. | function _pause() internal virtual whenNotPaused {
paused = true;
emit Paused(_msgSender());
}
| function _pause() internal virtual whenNotPaused {
paused = true;
emit Paused(_msgSender());
}
| 37,876 |
20 | // SignExtImm | rt = SE(insn&0xFFFF, 16);
| rt = SE(insn&0xFFFF, 16);
| 41,461 |
34 | // Standard function transfer similar to ERC20 transfer with no _data. Added due to backwards compatibility reasons. | function transfer(address _to, uint _value) isUnlocked isUnfreezed(_to) returns (bool success) {
bytes memory empty;
if(isContract(_to)) {
return transferToContract(_to, _value, empty);
}
else {
return transferToAddress(_to, _value, empty);
}
}
| function transfer(address _to, uint _value) isUnlocked isUnfreezed(_to) returns (bool success) {
bytes memory empty;
if(isContract(_to)) {
return transferToContract(_to, _value, empty);
}
else {
return transferToAddress(_to, _value, empty);
}
}
| 29,440 |
43 | // Returns a newly allocated string containing the concatenation of `self` and `other`. self The first slice to concatenate. other The second slice to concatenate.return The concatenation of the two strings. / | function concat(slice memory self, slice memory other) internal pure returns (string memory) {
string memory ret = new string(self._len + other._len);
uint retptr;
assembly { retptr := add(ret, 32) }
memcpy(retptr, self._ptr, self._len);
memcpy(retptr + self._len, other._ptr,... | function concat(slice memory self, slice memory other) internal pure returns (string memory) {
string memory ret = new string(self._len + other._len);
uint retptr;
assembly { retptr := add(ret, 32) }
memcpy(retptr, self._ptr, self._len);
memcpy(retptr + self._len, other._ptr,... | 36,868 |
77 | // Claim pending rewards | claimRewards(stakeId, stakedAmount);
| claimRewards(stakeId, stakedAmount);
| 39,495 |
60 | // given an input amount of an asset and pair reserves, returns the maximum output amount of the other asset | function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = am... | function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut) {
require(amountIn > 0, 'UniswapV2Library: INSUFFICIENT_INPUT_AMOUNT');
require(reserveIn > 0 && reserveOut > 0, 'UniswapV2Library: INSUFFICIENT_LIQUIDITY');
uint amountInWithFee = am... | 4,172 |
99 | // Applies accrued interest to total borrows and reserves.This calculates interest accrued from the last checkpointed blockup to the current block and writes new checkpoint to storage./ | function accrueInterest() public returns (uint) {
delegateAndReturn();
}
| function accrueInterest() public returns (uint) {
delegateAndReturn();
}
| 18,983 |
0 | // store a proof of existence in the contract state | function storeProof(bytes32 proof) {
proofs[proof] = true;
}
| function storeProof(bytes32 proof) {
proofs[proof] = true;
}
| 40,209 |
20 | // CALCULATE 50% PARTECIPANT ALL | uint consensusLimit = countAirlines.div(CONSENSUS_50);
if (multiCalls[owner].length >= consensusLimit) {
success = true;
flightSuretyData.registerAirline(_addressAirline, msg.sender);
emit RegisterAirlineEvent(_addressAirline);
mult... | uint consensusLimit = countAirlines.div(CONSENSUS_50);
if (multiCalls[owner].length >= consensusLimit) {
success = true;
flightSuretyData.registerAirline(_addressAirline, msg.sender);
emit RegisterAirlineEvent(_addressAirline);
mult... | 31,187 |
9 | // Mint a crypto treasure from a type id This will transferFrom() tokens to the contract Allowance of the erc20 to lock must be done before Throw if the minting start is not yet passed Throw if there is no more crypto treasure available for this typeto address of reception typeId id of the type data array bytes contain... | function safeMintByType(
address to,
uint256 typeId,
bytes memory data
| function safeMintByType(
address to,
uint256 typeId,
bytes memory data
| 52,054 |
203 | // Equivalent to `safeTransferFrom(from, to, tokenId, '')`. / | function safeTransferFrom(
address from,
address to,
uint256 tokenId
| function safeTransferFrom(
address from,
address to,
uint256 tokenId
| 8,224 |
69 | // As per the EIP-165 spec, no interface should ever match 0xffffffff | bytes4 private constant _InterfaceId_Invalid = 0xffffffff;
bytes4 private constant _InterfaceId_ERC165 = 0x01ffc9a7;
| bytes4 private constant _InterfaceId_Invalid = 0xffffffff;
bytes4 private constant _InterfaceId_ERC165 = 0x01ffc9a7;
| 30,081 |
309 | // Shift in bits from prod1 into prod0. For this we need to flip `twos` such that it is 2256 / twos. If twos is zero, then it becomes one | assembly {
twos := add(div(sub(0, twos), twos), 1)
}
| assembly {
twos := add(div(sub(0, twos), twos), 1)
}
| 61,530 |
21 | // This is the entrypoint for the frontend, as well as third-party Revest integrations. / | contract RevestRemap is IRevest, AccessControlEnumerable, RevestAccessControl, RevestReentrancyGuard {
using SafeERC20 for IERC20;
using ERC165Checker for address;
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
bytes4 public constant ADDRESS_LOCK_INTERFACE_ID = type(IAddressLock).inter... | contract RevestRemap is IRevest, AccessControlEnumerable, RevestAccessControl, RevestReentrancyGuard {
using SafeERC20 for IERC20;
using ERC165Checker for address;
bytes32 public constant PAUSER_ROLE = keccak256("PAUSER_ROLE");
bytes4 public constant ADDRESS_LOCK_INTERFACE_ID = type(IAddressLock).inter... | 6,829 |
80 | // set the rest of the contract variables | uniswapV2Router = _uniswapV2Router;
| uniswapV2Router = _uniswapV2Router;
| 603 |
234 | // Transfer asset to Strategy and call deposit method to mint or take required action | asset.safeTransfer(address(strategy), allocateAmount);
strategy.deposit(address(asset), allocateAmount);
| asset.safeTransfer(address(strategy), allocateAmount);
strategy.deposit(address(asset), allocateAmount);
| 25,539 |
189 | // Token symbol. / | string internal tokenSymbol;
| string internal tokenSymbol;
| 22,084 |
7 | // Set the base live win probability of a ticket. Only callable bythe contract owner. _baseLiveWinProb The probability represented as a valuebetween 0 to 2128 - 1. / | function setBaseLiveWinProb(uint128 _baseLiveWinProb) external onlyOwner {
baseLiveWinProb = _baseLiveWinProb;
emit BaseLiveWinProbUpdated(_baseLiveWinProb);
}
| function setBaseLiveWinProb(uint128 _baseLiveWinProb) external onlyOwner {
baseLiveWinProb = _baseLiveWinProb;
emit BaseLiveWinProbUpdated(_baseLiveWinProb);
}
| 16,442 |
205 | // We've created a new subtree at this level, update | filledSubTrees[level] = _leafHashes[insertionElement];
| filledSubTrees[level] = _leafHashes[insertionElement];
| 62,931 |
19 | // Emitted when the liquidate borrow permission is updated./owner The address of the contract owner./bond The related HToken./state True if liquidating borrow is allowed. | event SetLiquidateBorrowAllowed(address indexed owner, IHToken indexed bond, bool state);
| event SetLiquidateBorrowAllowed(address indexed owner, IHToken indexed bond, bool state);
| 51,608 |
20 | // Returns the amount which _spender is still allowed to withdraw from _owner | function allowance(address _owner, address _spender) constant returns(uint256){
return allowed[_owner][_spender];
}
| function allowance(address _owner, address _spender) constant returns(uint256){
return allowed[_owner][_spender];
}
| 696 |
20 | // reverts if addr does not have role addr address roleName the name of the role / | function checkRole(address addr, string roleName)
view
public
| function checkRole(address addr, string roleName)
view
public
| 18,812 |
279 | // See {ERC20-_beforeTokenTransfer}. See {ERC20Capped-_beforeTokenTransfer}. / | function _beforeTokenTransfer(address from, address to, uint256 amount) internal override(ERC20, ERC20Capped) {
super._beforeTokenTransfer(from, to, amount);
}
| function _beforeTokenTransfer(address from, address to, uint256 amount) internal override(ERC20, ERC20Capped) {
super._beforeTokenTransfer(from, to, amount);
}
| 33,500 |
57 | // override | function burn(uint256 _value) onlyOwner public {
super.burn(_value);
}
| function burn(uint256 _value) onlyOwner public {
super.burn(_value);
}
| 44,600 |
120 | // View function to see pending KIMCHIs on frontend. | function pendingKimchi(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accKimchiPerShare = pool.accKimchiPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
... | function pendingKimchi(uint256 _pid, address _user) external view returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accKimchiPerShare = pool.accKimchiPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
... | 37,941 |
10 | // The duration of time after proposal passed with absolute majority before it can be executed | uint256 public fastQueuePeriod; //1 days/8 = 3hours
| uint256 public fastQueuePeriod; //1 days/8 = 3hours
| 18,071 |
10 | // Mentors | uint256 public MENTORS = 80000000 * 10**uint256(decimals);
| uint256 public MENTORS = 80000000 * 10**uint256(decimals);
| 11,765 |
19 | // @inheritdoc IRaffle This function can still be called when the contract is paused because the raffle creator would not be able to deposit prizes and open the raffle anyway. The restriction to disallow raffles creation when the contract is paused will be enforced in the frontend. / | function createRaffle(
CreateRaffleCalldata calldata params
| function createRaffle(
CreateRaffleCalldata calldata params
| 16,678 |
4 | // access to a non-existing index will throw an exception | m_pairsOfFlags[index][0] = flagA;
m_pairsOfFlags[index][1] = flagB;
| m_pairsOfFlags[index][0] = flagA;
m_pairsOfFlags[index][1] = flagB;
| 41,085 |
6 | // Handler for dealing with assets when minting multiple at once./from The original address that signed the transaction./gemsQuantities An array listing the quantity of each type of gem./catalystsQuantities An array listing the quantity of each type of catalyst./assets An array of AssetData structs to define how the to... | function _handleMultipleAssetRequirements(
address from,
uint256[] memory gemsQuantities,
uint256[] memory catalystsQuantities,
AssetData[] memory assets
| function _handleMultipleAssetRequirements(
address from,
uint256[] memory gemsQuantities,
uint256[] memory catalystsQuantities,
AssetData[] memory assets
| 8,286 |
191 | // get past rounds answers overridden funcion to add the checkAccess() modifier _roundId the round number to retrieve the answer for deprecated. Use getRoundData instead. / | function getAnswer(uint256 _roundId)
public
view
override
checkAccess()
returns (int256)
| function getAnswer(uint256 _roundId)
public
view
override
checkAccess()
returns (int256)
| 40,910 |
131 | // accrueInterest emits logs on errors, but on top of that we want to log the fact that an attempted reserve factor change failed. | return fail(Error(error), FailureInfo.SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED);
| return fail(Error(error), FailureInfo.SET_RESERVE_FACTOR_ACCRUE_INTEREST_FAILED);
| 11,804 |
151 | // Should not withdraw less than requested amount | _share = _amount > ((_share * _pricePerShare) / 1e18) ? _share + 1 : _share;
IVesperPool(receiptToken).whitelistedWithdraw(_share);
| _share = _amount > ((_share * _pricePerShare) / 1e18) ? _share + 1 : _share;
IVesperPool(receiptToken).whitelistedWithdraw(_share);
| 61,653 |
22 | // Oracle: Indicate the game `gameId` as canceled.gameId the current game ID / | function cancelGame(uint256 gameId) external onlyOracle {
Game storage game = games[gameId];
if (game.startsAt == 0) revert GameNotExists();
if (game.canceled) revert GameAlreadyCanceled();
lockedLiquidity -= game.lockedLiquidity;
game.canceled = true;
emit GameCanc... | function cancelGame(uint256 gameId) external onlyOracle {
Game storage game = games[gameId];
if (game.startsAt == 0) revert GameNotExists();
if (game.canceled) revert GameAlreadyCanceled();
lockedLiquidity -= game.lockedLiquidity;
game.canceled = true;
emit GameCanc... | 23,065 |
174 | // Emits a {DepositCollateral} event. Requirements: - The vault must be open.- The amount to deposit cannot be zero.- The Fintroller must allow this action to be performed.- The caller must have allowed this contract to spend `collateralAmount` tokens.fyToken The address of the fyToken contract. collateralAmount The am... |
function depositCollateral(FyTokenInterface fyToken, uint256 collateralAmount)
external
override
isVaultOpenForMsgSender(fyToken)
nonReentrant
|
function depositCollateral(FyTokenInterface fyToken, uint256 collateralAmount)
external
override
isVaultOpenForMsgSender(fyToken)
nonReentrant
| 6,014 |
860 | // approve iDai to that contract | ERC20(NEW_IDAI_ADDRESS).approve(NEW_IDAI_ADDRESS, uint(-1));
uint tokenPrice = ITokenInterface(NEW_IDAI_ADDRESS).tokenPrice();
| ERC20(NEW_IDAI_ADDRESS).approve(NEW_IDAI_ADDRESS, uint(-1));
uint tokenPrice = ITokenInterface(NEW_IDAI_ADDRESS).tokenPrice();
| 63,336 |
3 | // This function allows users to withdraw their stake after a 7 day waiting period from request/ | function withdrawStake(TellorStorage.TellorStorageStruct storage self) public {
TellorStorage.StakeInfo storage stakes = self.stakerDetails[msg.sender];
//Require the staker has locked for withdraw(currentStatus ==2) and that 7 days have
//passed by since they locked for withdraw
req... | function withdrawStake(TellorStorage.TellorStorageStruct storage self) public {
TellorStorage.StakeInfo storage stakes = self.stakerDetails[msg.sender];
//Require the staker has locked for withdraw(currentStatus ==2) and that 7 days have
//passed by since they locked for withdraw
req... | 41,689 |
20 | // set a reasonable maximum here so we don't run out of gas | if (numTokens > 100) {
revert TooManyTokens();
}
| if (numTokens > 100) {
revert TooManyTokens();
}
| 28,878 |
429 | // round 5 | ark(i, q, 17933600965499023212689924809448543050840131883187652471064418452962948061619);
sbox_partial(i, q);
mix(i, q);
| ark(i, q, 17933600965499023212689924809448543050840131883187652471064418452962948061619);
sbox_partial(i, q);
mix(i, q);
| 81,083 |
268 | // update fees for inclusion in total pool amounts | (uint128 baseLiquidity, , ) = _position(baseLower, baseUpper);
if (baseLiquidity > 0) {
(uint burn0, uint burn1) = IUniswapV3Pool(pool).burn(baseLower, baseUpper, 0);
require(burn0 == 0 && burn1 == 0, "IV.deposit: unexpected burn (1)");
}
| (uint128 baseLiquidity, , ) = _position(baseLower, baseUpper);
if (baseLiquidity > 0) {
(uint burn0, uint burn1) = IUniswapV3Pool(pool).burn(baseLower, baseUpper, 0);
require(burn0 == 0 && burn1 == 0, "IV.deposit: unexpected burn (1)");
}
| 25,729 |
102 | // If this adapter is being added for the first time | if (isOn && am.id == 0) {
am.id = ++adapterCounter;
adapterAddresses[am.id] = adapter;
}
| if (isOn && am.id == 0) {
am.id = ++adapterCounter;
adapterAddresses[am.id] = adapter;
}
| 11,179 |
8 | // We can divide by magnitude Remainder is removed so we only get the actual number we want | uint actualDiv = divRate;
if (actualDiv >= 30){
return 6;
} else if (actualDiv >= 25){
| uint actualDiv = divRate;
if (actualDiv >= 30){
return 6;
} else if (actualDiv >= 25){
| 8,191 |
11 | // Pause minting flag / | bool public isPaused;
| bool public isPaused;
| 23,067 |
4 | // cage by reading the last value from the feed for the price | function cage() public note auth {
cage(rdiv(uint(tub.pip().read()), vox.par()));
}
| function cage() public note auth {
cage(rdiv(uint(tub.pip().read()), vox.par()));
}
| 20,439 |
16 | // Removes an address from the list of agents authorizedto make 'insert' mutations to the registry. / | function revokeInsertAgentAuthorization(address agent)
public
onlyOwner
| function revokeInsertAgentAuthorization(address agent)
public
onlyOwner
| 15,754 |
34 | // Minus 1y locked tokens | remainingTokens = remainingTokens.sub(totalSupplyLocked1Y);
| remainingTokens = remainingTokens.sub(totalSupplyLocked1Y);
| 8,320 |
99 | // -- Enums -- | enum BlockType
| enum BlockType
| 9,818 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.