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 |
|---|---|---|---|---|
52 | // Returns the 32 byte value at the specified index of self. self The byte string. idx The index into the bytesreturn The specified 32 bytes of the string. / | function readBytes32(
bytes memory self,
uint256 idx
| function readBytes32(
bytes memory self,
uint256 idx
| 17,351 |
65 | // FailedMessagesProcessor Functionality for fixing failed bridging operations. / | abstract contract FailedMessagesProcessor is BasicAMBMediator, BridgeOperationsStorage {
event FailedMessageFixed(bytes32 indexed messageId, address token, address recipient, uint256 value);
/**
* @dev Method to be called when a bridged message execution failed. It will generate a new message requesting t... | abstract contract FailedMessagesProcessor is BasicAMBMediator, BridgeOperationsStorage {
event FailedMessageFixed(bytes32 indexed messageId, address token, address recipient, uint256 value);
/**
* @dev Method to be called when a bridged message execution failed. It will generate a new message requesting t... | 24,039 |
40 | // Unsettled principal from previous call request periods which will settle. | principalPaidSum += cl._waterfall.totalPrincipalReservedUpToTranche(
Math.min(trancheIndexAtGivenTimestamp, cl.uncalledCapitalTrancheIndex())
);
| principalPaidSum += cl._waterfall.totalPrincipalReservedUpToTranche(
Math.min(trancheIndexAtGivenTimestamp, cl.uncalledCapitalTrancheIndex())
);
| 39,892 |
179 | // retrieve farming position | FarmingPosition storage farmingPosition = _positions[positionId];
FarmingSetup storage chosenSetup = _setups[farmingPosition.setupIndex];
uint128 liquidityAmount = _addLiquidity(farmingPosition.setupIndex, request);
| FarmingPosition storage farmingPosition = _positions[positionId];
FarmingSetup storage chosenSetup = _setups[farmingPosition.setupIndex];
uint128 liquidityAmount = _addLiquidity(farmingPosition.setupIndex, request);
| 27,844 |
92 | // ======== INTERNAL HELPER FUNCTIONS ======== //makes incremental adjustment to control variable / | function adjust() internal {
uint blockCanAdjust = adjustment.lastBlock.add( adjustment.buffer );
if( adjustment.rate != 0 && block.number >= blockCanAdjust ) {
uint initial = terms.controlVariable;
if ( adjustment.add ) {
terms.controlVariable = terms.control... | function adjust() internal {
uint blockCanAdjust = adjustment.lastBlock.add( adjustment.buffer );
if( adjustment.rate != 0 && block.number >= blockCanAdjust ) {
uint initial = terms.controlVariable;
if ( adjustment.add ) {
terms.controlVariable = terms.control... | 10,698 |
15 | // Add a new technician address/_officeId The professional office id/_address The new technician address | function addTechnician(uint32 _officeId, address _address) external onlyAuthorizedForUpdate(_officeId) {
require(_address != address(0), "Invalid address");
require(officeIdByActivTechnicianAddress[_address] == 0, "Address already activ");
offices[_officeId].technicians[_address] = true;
... | function addTechnician(uint32 _officeId, address _address) external onlyAuthorizedForUpdate(_officeId) {
require(_address != address(0), "Invalid address");
require(officeIdByActivTechnicianAddress[_address] == 0, "Address already activ");
offices[_officeId].technicians[_address] = true;
... | 8,962 |
132 | // Calcualtes vestable amount for beneficiary for current time _index index of vestingSchedules array / | function getVestedAmount(uint256 _index)
public
view
returns (uint256)
| function getVestedAmount(uint256 _index)
public
view
returns (uint256)
| 23,991 |
178 | // lets the owner convert SCD SAI into MCD DAI._wallet The target wallet._amount The amount of SAI to convert/ | function swapSaiToDai(
BaseWallet _wallet,
uint256 _amount
)
public
onlyWalletOwner(_wallet)
onlyWhenUnlocked(_wallet)
| function swapSaiToDai(
BaseWallet _wallet,
uint256 _amount
)
public
onlyWalletOwner(_wallet)
onlyWhenUnlocked(_wallet)
| 690 |
59 | // This is an alternative to {approve} that can be used as a mitigation forproblems described in {BEP20-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 returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero"));
return true;
}
| function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].sub(subtractedValue, "BEP20: decreased allowance below zero"));
return true;
}
| 23,071 |
109 | // Percent of funds referrers receive. 20 = 2%. | uint128 public refPercent;
| uint128 public refPercent;
| 31,351 |
63 | // StandardERC20 Implementation of the StandardERC20 / | contract StandardERC20 is ERC20Decimals, ServicePayer {
constructor (
string memory name_,
string memory symbol_,
uint8 decimals_,
uint256 initialBalance_,
address payable feeReceiver_
)
ERC20(name_, symbol_)
ERC20Decimals(decimals_)
ServicePayer(... | contract StandardERC20 is ERC20Decimals, ServicePayer {
constructor (
string memory name_,
string memory symbol_,
uint8 decimals_,
uint256 initialBalance_,
address payable feeReceiver_
)
ERC20(name_, symbol_)
ERC20Decimals(decimals_)
ServicePayer(... | 8,710 |
6 | // If owner takes too long (does not respond in time and someone calls the player_declare_taking_too_long function), owner_took_too_long will be set to true and all players will be paid out. This represents the total sum that will be paid out in that case. | uint total_payout;
| uint total_payout;
| 30,590 |
0 | // permissions keyed by hash(user, worker, dapp) | mapping(bytes32 => bool) private permissions;
| mapping(bytes32 => bool) private permissions;
| 15,298 |
264 | // Mint | _safeMint(_target, _realIndex);
| _safeMint(_target, _realIndex);
| 14,773 |
269 | // First settle anything pending into sUSD as burning or issuing impacts the size of the debt pool | (, uint refunded, uint numEntriesSettled) = exchanger().settle(from, sUSD);
if (numEntriesSettled > 0) {
amount = exchanger().calculateAmountAfterSettlement(from, sUSD, amount, refunded);
}
| (, uint refunded, uint numEntriesSettled) = exchanger().settle(from, sUSD);
if (numEntriesSettled > 0) {
amount = exchanger().calculateAmountAfterSettlement(from, sUSD, amount, refunded);
}
| 7,290 |
31 | // Sets a new owner address/ | function _setOwner(address newOwner) internal {
require(newOwner != address(0));
emit OwnershipTransferred(owner(), newOwner);
addressStorage[OWNER] = newOwner;
}
| function _setOwner(address newOwner) internal {
require(newOwner != address(0));
emit OwnershipTransferred(owner(), newOwner);
addressStorage[OWNER] = newOwner;
}
| 42,461 |
174 | // CohortDeployment event | event CohortDeployment(
address indexed deployer,
address indexed cohort,
address poolAddress,
uint256 when
);
| event CohortDeployment(
address indexed deployer,
address indexed cohort,
address poolAddress,
uint256 when
);
| 76,101 |
28 | // Check various conditions to determine whether a purchase is currently valid/amount The amount of tokens to be purchased | function validPurchase(uint256 amount) public view returns (bool) {
bool nonZeroPurchase = amount != 0;
bool isMinPurchase = (amount >= minimumPurchase);
return saleActive && nonZeroPurchase && isMinPurchase;
}
| function validPurchase(uint256 amount) public view returns (bool) {
bool nonZeroPurchase = amount != 0;
bool isMinPurchase = (amount >= minimumPurchase);
return saleActive && nonZeroPurchase && isMinPurchase;
}
| 24,238 |
230 | // Get total supply leftover amount ------------------------------------------------------------------------ | function getUnsoldRemaining() external view returns (uint256) {
return maxSupply - totalSupply();
}
| function getUnsoldRemaining() external view returns (uint256) {
return maxSupply - totalSupply();
}
| 81,403 |
1 | // Get internal version number identifying an ArbOS buildreturn version number as int / | function arbOSVersion() external pure returns (uint256);
function arbChainID() external view returns (uint256);
| function arbOSVersion() external pure returns (uint256);
function arbChainID() external view returns (uint256);
| 39,316 |
18 | // Pay protocol fee | if (order.protocolFeeDiscounted != 0) {
uint256 protocolFeeAmount = (order.protocolFeeDiscounted * order.price) / 10000;
finalSellerAmount -= protocolFeeAmount;
}
| if (order.protocolFeeDiscounted != 0) {
uint256 protocolFeeAmount = (order.protocolFeeDiscounted * order.price) / 10000;
finalSellerAmount -= protocolFeeAmount;
}
| 29,085 |
103 | // Set AMO to Ether rate for round_round: Round to set _rate: AMO to Ether _rate / | function setRateForRound(
SaleRounds _round,
uint256 _rate
)
public
onlyOwner
atStage(Stages.SetUp)
| function setRateForRound(
SaleRounds _round,
uint256 _rate
)
public
onlyOwner
atStage(Stages.SetUp)
| 29,259 |
340 | // gives square. multiplies x by x / | function sq(uint256 x)
internal
pure
returns (uint256)
| function sq(uint256 x)
internal
pure
returns (uint256)
| 2,506 |
20 | // withdraw funds | function withdraw(address receiver) public onlyRole(DEFAULT_ADMIN_ROLE) {
uint256 balance = address(this).balance;
payable(receiver).transfer(balance);
}
| function withdraw(address receiver) public onlyRole(DEFAULT_ADMIN_ROLE) {
uint256 balance = address(this).balance;
payable(receiver).transfer(balance);
}
| 23,458 |
83 | // can't transfer parts to any of the battle contracts directly | for (uint j = 0; j < approvedBattles.length; j++) {
require(_to != approvedBattles[j]);
}
| for (uint j = 0; j < approvedBattles.length; j++) {
require(_to != approvedBattles[j]);
}
| 46,182 |
116 | // Rule CFA-2 https:github.com/superfluid-finance/protocol-monorepo/wiki/About-App-Credit Allow apps to take an additional amount of app credit (minimum deposit) | uint256 minimumDeposit = gov.getConfigAsUint256(
ISuperfluid(msg.sender), token, SUPERTOKEN_MINIMUM_DEPOSIT_KEY);
| uint256 minimumDeposit = gov.getConfigAsUint256(
ISuperfluid(msg.sender), token, SUPERTOKEN_MINIMUM_DEPOSIT_KEY);
| 16,811 |
19 | // Store the `msg.sender`. | mstore(0x3a, caller())
| mstore(0x3a, caller())
| 22,735 |
75 | // Check total supply cap reached, sell the all remaining tokens | if (tokensGenerated > leftForSale) {
tokensGenerated = leftForSale;
toFund = leftForSale.div(exchangeRate);
}
| if (tokensGenerated > leftForSale) {
tokensGenerated = leftForSale;
toFund = leftForSale.div(exchangeRate);
}
| 27,597 |
80 | // verify that the first token in the path is BNT | require(_path[0] == addressOf(BNT_TOKEN));
| require(_path[0] == addressOf(BNT_TOKEN));
| 40,915 |
27 | // Claim and send rewards | function claimSelfApeCoin() external {
claimApeCoin(msg.sender);
}
| function claimSelfApeCoin() external {
claimApeCoin(msg.sender);
}
| 11,168 |
23 | // transfer someone else's tokens, subject to approval | function transferFrom(address from, address to, uint value) public returns (bool success)
| function transferFrom(address from, address to, uint value) public returns (bool success)
| 17,125 |
0 | // Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,/ Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, andoptionally initialized with `_data` as explained in {ERC1967Proxy-constructor}. / | constructor(
address _logic,
address admin_,
bytes memory _data
) payable ERC1967Proxy(_logic, _data) {
_changeAdmin(admin_);
}
| constructor(
address _logic,
address admin_,
bytes memory _data
) payable ERC1967Proxy(_logic, _data) {
_changeAdmin(admin_);
}
| 6,630 |
3 | // index of the stack | mul(stackIndex_, 0x20)
)
)
switch opcode_
| mul(stackIndex_, 0x20)
)
)
switch opcode_
| 21,082 |
112 | // check for valid signatures | require(signer != address(0), "Invalid signature for signer.");
require(cosigner != address(0), "Invalid signature for cosigner.");
| require(signer != address(0), "Invalid signature for signer.");
require(cosigner != address(0), "Invalid signature for cosigner.");
| 36,618 |
14 | // change the lockTime | function changeChangeLockTimeSeconds(uint256 _newLockTime) public onlyOwner {
lockTime = _newLockTime;
}
| function changeChangeLockTimeSeconds(uint256 _newLockTime) public onlyOwner {
lockTime = _newLockTime;
}
| 37,844 |
32 | // Whether or not the voter supports the proposal | bool support;
| bool support;
| 18,031 |
123 | // Lets a contract admin update the default royalty recipient and bps. | function _setupDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) internal {
if (_royaltyBps > 10_000) {
revert("Exceeds max bps");
}
royaltyRecipient = _royaltyRecipient;
royaltyBps = uint16(_royaltyBps);
emit DefaultRoyalty(_royaltyRecipient, _... | function _setupDefaultRoyaltyInfo(address _royaltyRecipient, uint256 _royaltyBps) internal {
if (_royaltyBps > 10_000) {
revert("Exceeds max bps");
}
royaltyRecipient = _royaltyRecipient;
royaltyBps = uint16(_royaltyBps);
emit DefaultRoyalty(_royaltyRecipient, _... | 3,541 |
42 | // Number of authorities signatures required to withdraw the money.// Must be lesser than number of authorities. | uint256 public requiredSignatures;
| uint256 public requiredSignatures;
| 38,174 |
137 | // perk not valid if any ancestor not unlocked | for (uint8 i = _parent(_index); i > PRESTIGE_INDEX; i = _parent(i)) {
if (_perks[i] == 0) {
return false;
}
| for (uint8 i = _parent(_index); i > PRESTIGE_INDEX; i = _parent(i)) {
if (_perks[i] == 0) {
return false;
}
| 46,214 |
121 | // Called by the Chainlink node to fulfill requests with multi-word support Given params must hash back to the commitment stored from `oracleRequest`.Will call the callback address' callback function without bubbling up errorchecking in a `require` so that the node can get paid. requestId The fulfillment request ID tha... | function fulfillOracleRequest2(
bytes32 requestId,
uint256 payment,
address callbackAddress,
bytes4 callbackFunctionId,
uint256 expiration,
bytes calldata data
)
external
override
| function fulfillOracleRequest2(
bytes32 requestId,
uint256 payment,
address callbackAddress,
bytes4 callbackFunctionId,
uint256 expiration,
bytes calldata data
)
external
override
| 52,881 |
110 | // Returns the address where a contract will be stored if deployed via {deploy} from a contract located at`deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}. / | function computeAddress(
bytes32 salt,
bytes32 bytecodeHash,
address deployer
) internal pure returns (address) {
bytes32 _data = keccak256(
abi.encodePacked(bytes1(0xff), deployer, salt, bytecodeHash)
);
return address(uint160(uint256(_data)));
}
| function computeAddress(
bytes32 salt,
bytes32 bytecodeHash,
address deployer
) internal pure returns (address) {
bytes32 _data = keccak256(
abi.encodePacked(bytes1(0xff), deployer, salt, bytecodeHash)
);
return address(uint160(uint256(_data)));
}
| 13,765 |
5 | // struct to store the game details which include:gameId, currencyAddress, feeAmount, playersWalletAddresses[], winnerFund, adminFund | struct Game {
string colyseusGameRoomId;
string gameId;
uint256 feeAmount;
address[] playersWalletAddresses;
uint256 winnerFund;
uint256 adminFund;
}
| struct Game {
string colyseusGameRoomId;
string gameId;
uint256 feeAmount;
address[] playersWalletAddresses;
uint256 winnerFund;
uint256 adminFund;
}
| 736 |
320 | // flash loan to position | if(DyDxActive && position > 0){
doDyDxFlashLoan(deficit, position);
}
| if(DyDxActive && position > 0){
doDyDxFlashLoan(deficit, position);
}
| 51,962 |
31 | // Returns true if the caller is the current owner. / | function isOwner(address account) public view returns (bool) {
return account == _owner;
}
| function isOwner(address account) public view returns (bool) {
return account == _owner;
}
| 23,669 |
2 | // assert(b > 0);Solidity automatically throws when dividing by 0 uint256 c = a / b; assert(a == bc + a % b);There is no case in which this doesn't hold | return a / b;
| return a / b;
| 1,650 |
2 | // Emitted when pendingComptrollerImplementation is changed/ | event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);
| event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);
| 10,558 |
23 | // constructor the contract, get called in the first time deploy _acceptedToken the token that the pools will use as staking and reward token / | constructor(IERC20 _acceptedToken) Ownable() {
linearAcceptedToken = _acceptedToken;
}
| constructor(IERC20 _acceptedToken) Ownable() {
linearAcceptedToken = _acceptedToken;
}
| 18,293 |
400 | // Used by owner or other contracts | require(_msgSender() == owner || _msgSender() == address(this) || _msgSender() == _carAddress || _msgSender() == _auctionAddress, "Not allowed");
| require(_msgSender() == owner || _msgSender() == address(this) || _msgSender() == _carAddress || _msgSender() == _auctionAddress, "Not allowed");
| 4,096 |
8 | // Get the marketplace's trading commissions basis points.return bp - TradingCommissionsBasisPoints struct containing the individual basis points set for each marketplace commission receiver. / | function getTradingCommissionsBasisPoints() external view returns (TradingCommissionsBasisPoints memory bp);
| function getTradingCommissionsBasisPoints() external view returns (TradingCommissionsBasisPoints memory bp);
| 20,289 |
164 | // 挖矿结束时间 | uint256 public periodFinish = 0;
uint256 public periodStart = 0;
| uint256 public periodFinish = 0;
uint256 public periodStart = 0;
| 21,777 |
82 | // Executes airdrop. airdropContract The address of the airdrop contract airdropParams Third party airdrop abi data. You need to get this from the third party airdrop. / | ) external onlyPoolAdmin {
MintableERC721Logic.executeAirdrop(airdropContract, airdropParams);
}
| ) external onlyPoolAdmin {
MintableERC721Logic.executeAirdrop(airdropContract, airdropParams);
}
| 32,856 |
377 | // bytes4(keccak256("Uint256DowncastError(uint8,uint256)")) | bytes4 internal constant UINT256_DOWNCAST_ERROR_SELECTOR =
0xc996af7b;
| bytes4 internal constant UINT256_DOWNCAST_ERROR_SELECTOR =
0xc996af7b;
| 1,668 |
2 | // COPIED AND MODIFIED FROM: Uniswap/v3-periphery/contracts/libraries/OracleLibrary.sol | function consult(
address pool,
uint32[] memory secondsAgos,
uint32[] memory windows,
uint256[] memory nowIdxs
)
external
view
returns (int24[] memory arithmeticMeanTicks_, uint128[] memory harmonicMeanLiquidities_);
| function consult(
address pool,
uint32[] memory secondsAgos,
uint32[] memory windows,
uint256[] memory nowIdxs
)
external
view
returns (int24[] memory arithmeticMeanTicks_, uint128[] memory harmonicMeanLiquidities_);
| 42,833 |
59 | // validate it is a valid flight | bytes32 flightId = _getFlightKey(airline, flight, timestamp);
require(flights[flightId].isOpen, 'the flight does not exists');
| bytes32 flightId = _getFlightKey(airline, flight, timestamp);
require(flights[flightId].isOpen, 'the flight does not exists');
| 48,192 |
2 | // public functions | function totalSupply() public view returns (uint256);
function balanceOf(address addr) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
| function totalSupply() public view returns (uint256);
function balanceOf(address addr) public view returns (uint256);
function transfer(address to, uint256 value) public returns (bool);
| 45,748 |
141 | // Transfer tokens to a specified address and then execute a callback on recipient. to The address to transfer to value The amount to be transferred data Additional data with no specified formatreturn A boolean that indicates if the operation was successful. / | function transferAndCall(address to, uint256 value, bytes memory data) public override returns (bool) {
transfer(to, value);
require(_checkAndCallTransfer(_msgSender(), to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
| function transferAndCall(address to, uint256 value, bytes memory data) public override returns (bool) {
transfer(to, value);
require(_checkAndCallTransfer(_msgSender(), to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
| 410 |
98 | // Setup unsold reserve address | UNSOLD_RESERVE = _unsoldReserve;
| UNSOLD_RESERVE = _unsoldReserve;
| 11,651 |
69 | // Throws if called by any account other than recharge eth address / | modifier onlyRechargeAddress() {
require(
msg.sender == rechargeAddress,
"UnwrapTokenV1: caller is not the RECHARGE_ADDRESS"
);
_;
}
| modifier onlyRechargeAddress() {
require(
msg.sender == rechargeAddress,
"UnwrapTokenV1: caller is not the RECHARGE_ADDRESS"
);
_;
}
| 29,718 |
140 | // if (tranche == Tranche.AA) {}v1: AA tranche disabled (S tranche is effectively AA) | if (tranche == Tranche.A) {
| if (tranche == Tranche.A) {
| 18,298 |
1 | // immutables | function ovl() external view returns (IOverlayV1Token);
function feed() external view returns (address);
function factory() external view returns (address);
| function ovl() external view returns (IOverlayV1Token);
function feed() external view returns (address);
function factory() external view returns (address);
| 25,749 |
7 | // Mapping of active trades. Key is a hash of the trade data | mapping (bytes32 => Escrow) public escrows;
| mapping (bytes32 => Escrow) public escrows;
| 45,704 |
216 | // this should be tightly linked | if (IcoState.SUCCEEDED == m_state) {
onSuccess();
} else if (IcoState.FAILED == m_state) {
| if (IcoState.SUCCEEDED == m_state) {
onSuccess();
} else if (IcoState.FAILED == m_state) {
| 6,647 |
144 | // if the stakedDays is less than the minimum, throw an error | require(stakedDays >= MIN_STAKE_DAYS, "stake days must be greater than 1");
uint256 curDay = _currentDay(); //ex. day 25
uint256 endOfStakeDay = startDay + stakedDays; //ex. Day 52
| require(stakedDays >= MIN_STAKE_DAYS, "stake days must be greater than 1");
uint256 curDay = _currentDay(); //ex. day 25
uint256 endOfStakeDay = startDay + stakedDays; //ex. Day 52
| 5,858 |
18 | // Check that the submitted block is extending the main chain | require(blockHeight > _heaviestHeight, ERR_NOT_MAIN_CHAIN);
| require(blockHeight > _heaviestHeight, ERR_NOT_MAIN_CHAIN);
| 8,163 |
887 | // Returns `sample`'s accumulator of the logarithm of the BPT price. / | function _accLogBptPrice(bytes32 sample) private pure returns (int256) {
return sample.decodeInt53(_ACC_LOG_BPT_PRICE_OFFSET);
}
| function _accLogBptPrice(bytes32 sample) private pure returns (int256) {
return sample.decodeInt53(_ACC_LOG_BPT_PRICE_OFFSET);
}
| 3,329 |
15 | // Mapping of addresses disbarred from holding any token. | mapping (address => bool) private _blacklistAddress;
| mapping (address => bool) private _blacklistAddress;
| 54,760 |
356 | // setting the msg.sender as the initial owner. | super.__Ownable_init();
| super.__Ownable_init();
| 26,053 |
94 | // Allows a Module to execute a Safe transaction without any further confirmations./to Destination address of module transaction./value Ether value of module transaction./data Data payload of module transaction./operation Operation type of module transaction. | function execTransactionFromModule(
address to,
uint256 value,
bytes memory data,
Enum.Operation operation
| function execTransactionFromModule(
address to,
uint256 value,
bytes memory data,
Enum.Operation operation
| 58,101 |
11 | // This emits when ownership of any NFT changes by any mechanism. /This event emits when NFTs are created (`from` == 0) and destroyed /(`to` == 0). Exception: during contract creation, any number of NFTs /may be created and assigned without emitting Transfer. At the time of /any transfer, the approved address for that ... | event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
| event Transfer(address indexed _from, address indexed _to, uint256 indexed _tokenId);
| 20,702 |
2 | // Only the contract creator can release funds from their HodlBox, and only after the defined number of blocks has passed. | if (msg.sender != hodler) throw;
if (block.number < hodlTillBlock) throw;
if (withdrawn) throw;
if (hodling <= 0) throw;
withdrawn = true;
hodling = 0;
| if (msg.sender != hodler) throw;
if (block.number < hodlTillBlock) throw;
if (withdrawn) throw;
if (hodling <= 0) throw;
withdrawn = true;
hodling = 0;
| 48,481 |
12 | // change base extension .json by _newBaseExtension/_newBaseExtension new base extension | function setBaseExtension(string memory _newBaseExtension) external onlyOwner {
baseExtension = _newBaseExtension;
}
| function setBaseExtension(string memory _newBaseExtension) external onlyOwner {
baseExtension = _newBaseExtension;
}
| 29,392 |
16 | // First, we allocate memory for `code` by retrieving the free memory pointer and then moving it ahead of `code` by the size of the creation code plus constructor arguments, and 32 bytes for the array length. | code := mload(0x40)
mstore(0x40, add(code, add(codeSize, 32)))
| code := mload(0x40)
mstore(0x40, add(code, add(codeSize, 32)))
| 24,436 |
2 | // @inheritdoc IFeeCollector | function distributeFees(address asset) public override onlyOwner returns (uint256 defaultFundsDelta, uint256 protocolFeesDelta) {
uint256 distributionAmount =
IERC20Minimal(asset).balanceOf(address(this)) - protocolFees[asset] - defaultFund[asset];
if ( defaultFundPaused ) {
... | function distributeFees(address asset) public override onlyOwner returns (uint256 defaultFundsDelta, uint256 protocolFeesDelta) {
uint256 distributionAmount =
IERC20Minimal(asset).balanceOf(address(this)) - protocolFees[asset] - defaultFund[asset];
if ( defaultFundPaused ) {
... | 36,590 |
691 | // Vote Delegation Functions _to address where message sender is assigning votesreturn success of message sender delegating votedelegate function does not allow assignment to burn / | function delegateVote(address _to) public returns (bool) {
return _delegateVote(_msgSender(), _to);
}
| function delegateVote(address _to) public returns (bool) {
return _delegateVote(_msgSender(), _to);
}
| 32,835 |
53 | // Functions required by IERC20Metadat // Functions required by IERC20Metadat - END // Functions required by IERC20 // Functions required by IERC20 - END / remove the amount from the sender's balance first | _reflectedBalances[sender] = _reflectedBalances[sender].sub(reflectedAmount);
if (_isExcludedFromRewards[sender])
_balances[sender] = _balances[sender].sub(amount);
_burnTokens( sender, amount, reflectedAmount );
| _reflectedBalances[sender] = _reflectedBalances[sender].sub(reflectedAmount);
if (_isExcludedFromRewards[sender])
_balances[sender] = _balances[sender].sub(amount);
_burnTokens( sender, amount, reflectedAmount );
| 23,692 |
116 | // AddressArrayUtils Set Protocol Utility functions to handle Address Arrays CHANGELOG:- 4/27/21: Added validatePairsWithArray methods / | library AddressArrayUtils {
/**
* Finds the index of the first occurrence of the given element.
* @param A The input array to search
* @param a The value to find
* @return Returns (index and isIn) for the first occurrence starting from index 0
*/
function indexOf(address[] memory A, ad... | library AddressArrayUtils {
/**
* Finds the index of the first occurrence of the given element.
* @param A The input array to search
* @param a The value to find
* @return Returns (index and isIn) for the first occurrence starting from index 0
*/
function indexOf(address[] memory A, ad... | 28,959 |
3 | // To be used for cross-chain RFQ-m trades, verified by the router. | bytes32 internal constant XCHAIN_QUOTE_TYPEHASH =
keccak256(
'XChainQuote(bytes32 txid,uint256 srcChainId,uint256 dstChainId,bytes32 dstTrader,address srcPool,address srcExternalAccount,bytes32 dstPool,bytes32 dstExternalAccount,address baseToken,bytes32 quoteToken,uint256 baseTokenAmount,uint25... | bytes32 internal constant XCHAIN_QUOTE_TYPEHASH =
keccak256(
'XChainQuote(bytes32 txid,uint256 srcChainId,uint256 dstChainId,bytes32 dstTrader,address srcPool,address srcExternalAccount,bytes32 dstPool,bytes32 dstExternalAccount,address baseToken,bytes32 quoteToken,uint256 baseTokenAmount,uint25... | 29,433 |
130 | // calculate new allocations given the total (not counting unlent balance) | _amountsFromAllocations(rebalancerLastAllocations, totalInUnderlying.sub(maxUnlentBalance))
);
| _amountsFromAllocations(rebalancerLastAllocations, totalInUnderlying.sub(maxUnlentBalance))
);
| 66,022 |
36 | // ERC20 | if (pool.exchange_addrs[i] != DEFAULT_ADDRESS)
transfer_token(pool.exchange_addrs[i], address(this), msg.sender, pool.exchanged_tokens[i]);
| if (pool.exchange_addrs[i] != DEFAULT_ADDRESS)
transfer_token(pool.exchange_addrs[i], address(this), msg.sender, pool.exchanged_tokens[i]);
| 5,955 |
17 | // Triggers stopped state. / | function pause() public whenNotPaused onlyOwner {
paused = true;
emit Paused(msg.sender);
}
| function pause() public whenNotPaused onlyOwner {
paused = true;
emit Paused(msg.sender);
}
| 15,583 |
87 | // add balance | _yamBalances[to] = _yamBalances[to].add(yamValue);
| _yamBalances[to] = _yamBalances[to].add(yamValue);
| 45,642 |
70 | // it will white list one member | // @param _user {address} of user to whitelist
// @return true if successful
function addToWhiteList(address _user) external onlyOwner() {
if (whiteList[_user] != true) {
whiteList[_user] = true;
totalWhiteListed++;
emit LogWhiteListed(_user, totalWhiteListed);
... | // @param _user {address} of user to whitelist
// @return true if successful
function addToWhiteList(address _user) external onlyOwner() {
if (whiteList[_user] != true) {
whiteList[_user] = true;
totalWhiteListed++;
emit LogWhiteListed(_user, totalWhiteListed);
... | 33,145 |
58 | // Returns whether the ownership slot at `index` is initialized.An uninitialized slot does not necessarily mean that the slot has no owner. / | function _ownershipIsInitialized(uint256 index) internal view virtual returns (bool) {
return _packedOwnerships[index] != 0;
}
| function _ownershipIsInitialized(uint256 index) internal view virtual returns (bool) {
return _packedOwnerships[index] != 0;
}
| 15,775 |
23 | // note : pass the owner address in _address in frontend to withdraw matic to owner address | function withdrawMaticToAddress(
uint256 _amount,
address _address
| function withdrawMaticToAddress(
uint256 _amount,
address _address
| 21,186 |
8 | // nft => tokenId => offerer address => offer struct | mapping(address => mapping(uint256 => mapping(address => OfferNFT)))
private offerNfts;
| mapping(address => mapping(uint256 => mapping(address => OfferNFT)))
private offerNfts;
| 23,749 |
49 | // slength can contain both the length and contents of the array if length < 32 bytes so let's prepare for that v. http:solidity.readthedocs.io/en/latest/miscellaneous.htmllayout-of-state-variables-in-storage | switch add(lt(slength, 32), lt(newlength, 32))
case 2 {
| switch add(lt(slength, 32), lt(newlength, 32))
case 2 {
| 47,675 |
92 | // Truncate bytes array if its size is more than 20 bytes.NOTE: This function does not perform any checks on the received parameter.Make sure that the _bytes argument has a correct length, not less than 20 bytes.A case when _bytes has length less than 20 will lead to the undefined behaviour,since assembly will read dat... | function bytesToAddress(bytes memory _bytes) internal pure returns (address addr) {
assembly {
addr := mload(add(_bytes, 20))
}
}
| function bytesToAddress(bytes memory _bytes) internal pure returns (address addr) {
assembly {
addr := mload(add(_bytes, 20))
}
}
| 8,927 |
11 | // clean up storage to save gas | userLocks[lock.owner].remove(lockId);
tokenLocksByAddress[lock.lpToken].remove(lockId);
delete tokenLocksById[lockId];
emit OnTokenUnlock(lockId);
| userLocks[lock.owner].remove(lockId);
tokenLocksByAddress[lock.lpToken].remove(lockId);
delete tokenLocksById[lockId];
emit OnTokenUnlock(lockId);
| 15,655 |
92 | // 1-of-1 Hou Yi | string public constant one9 = 'iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABwlBMVEUAAAD5VLT5VLT5aaX5ZGf5XI75uFL5ZGf5mHj5aaX5VLT5l2z563n5hYn52LT5VLT5VLT5aaX5ZGf5Y2f5mHj5fXr5X635ZYX5fW/5X635X635fpf5VLT5lWvt+Yv517X5fpf5VLT5aaX5aaX5p6r5em35uY350mX5hYn5uI351YX532j5vH/5aaX5dJ75XI75cX75dJ750aP563j5uYH5dJ75cH75kHz51Yb55... | string public constant one9 = 'iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABwlBMVEUAAAD5VLT5VLT5aaX5ZGf5XI75uFL5ZGf5mHj5aaX5VLT5l2z563n5hYn52LT5VLT5VLT5aaX5ZGf5Y2f5mHj5fXr5X635ZYX5fW/5X635X635fpf5VLT5lWvt+Yv517X5fpf5VLT5aaX5aaX5p6r5em35uY350mX5hYn5uI351YX532j5vH/5aaX5dJ75XI75cX75dJ750aP563j5uYH5dJ75cH75kHz51Yb55... | 5,794 |
63 | // A mapping of preSaleItem Type to Type Sequence Number to Collectible | mapping (uint256 => mapping (uint256 => mapping ( uint256 => uint256 ) ) ) public preSaleItemTypeToSequenceIdToCollectible;
| mapping (uint256 => mapping (uint256 => mapping ( uint256 => uint256 ) ) ) public preSaleItemTypeToSequenceIdToCollectible;
| 18,620 |
202 | // Approves tokens for the smart contract./ | /// @dev Reverts with a {CallFailed} error if execution of the approval fails or returns an unexpected value.
///
/// @param token The token to approve.
/// @param spender The contract to spend the tokens.
/// @param value The amount of tokens to approve.
function safeApprove(address token, ... | /// @dev Reverts with a {CallFailed} error if execution of the approval fails or returns an unexpected value.
///
/// @param token The token to approve.
/// @param spender The contract to spend the tokens.
/// @param value The amount of tokens to approve.
function safeApprove(address token, ... | 26,517 |
239 | // event ConditionalTransferProcessed( | {
// Read the transfer
Transfer memory transfer = readTx(data, offset);
TransferAuxiliaryData memory auxData = abi.decode(auxiliaryData, (TransferAuxiliaryData));
// Fill in withdrawal data missing from DA
transfer.validUntil = auxData.validUntil;
transfer.maxFee = a... | {
// Read the transfer
Transfer memory transfer = readTx(data, offset);
TransferAuxiliaryData memory auxData = abi.decode(auxiliaryData, (TransferAuxiliaryData));
// Fill in withdrawal data missing from DA
transfer.validUntil = auxData.validUntil;
transfer.maxFee = a... | 48,595 |
4 | // duration of a slice period for the vesting in seconds | uint256 slicePeriodSeconds;
| uint256 slicePeriodSeconds;
| 4,205 |
153 | // case 2: R>1 | payQuote = _RAboveBuyBaseToken(buyBaseAmount, _BASE_BALANCE_, newBaseTarget);
newRStatus = Types.RStatus.ABOVE_ONE;
| payQuote = _RAboveBuyBaseToken(buyBaseAmount, _BASE_BALANCE_, newBaseTarget);
newRStatus = Types.RStatus.ABOVE_ONE;
| 32,188 |
84 | // If there isn't enough in the allPrevInvestmentTotal for the subtracted amount | if (
usersLastAddedLiquidityEpochInvestmentDetails
.allPrevInvestmentTotals < _amount
) {
| if (
usersLastAddedLiquidityEpochInvestmentDetails
.allPrevInvestmentTotals < _amount
) {
| 19,371 |
19 | // Send a request from user to blockchain. Assumes price is including the cost for verification NOTE: use bytes memory as argument will increase the gas cost, one alternative will be uint type, may consifer in future. | function startRequest(bytes memory dataID) public payable returns (bool) {
require(msg.value >= price, 'Not enough ether');
if(requestList[msg.sender].blockNumber == 0){ //never submitted before
//register on List
requestList[msg.sender].blockNumber = block.number;
... | function startRequest(bytes memory dataID) public payable returns (bool) {
require(msg.value >= price, 'Not enough ether');
if(requestList[msg.sender].blockNumber == 0){ //never submitted before
//register on List
requestList[msg.sender].blockNumber = block.number;
... | 13,390 |
27 | // This implements an optional extension of {ERC721} defined in the EIP that addsenumerability of all the token ids in the contract as well as all token ids owned by eachaccount. / | abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
| abstract contract ERC721Enumerable is ERC721, IERC721Enumerable {
| 58,086 |
269 | // Update % lock for dev | function lockdevUpdate(uint _newdevlock) public onlyAuthorized {
PERCENT_FOR_DEV = _newdevlock;
}
| function lockdevUpdate(uint _newdevlock) public onlyAuthorized {
PERCENT_FOR_DEV = _newdevlock;
}
| 24,520 |
80 | // Returns all the relevant information about a specific collectible./_tokenId The tokenId of the collectible of interest. | function getCollectible(uint256 _tokenId) public view returns (uint256 tokenId,
uint256 sellingPrice,
address owner,
uint256 nextSellingPrice
| function getCollectible(uint256 _tokenId) public view returns (uint256 tokenId,
uint256 sellingPrice,
address owner,
uint256 nextSellingPrice
| 54,584 |
59 | // as wad wetWeaken + weStrengthen + dryWeaken - deadBranchGrowth | function weakBranchGrowth(uint256 newWetWeaken, uint256 newWetStrengthen, uint256 newDryWeaken, uint256 newDeadBranchGrowth, uint256 frailty) internal pure returns (int256) {
// growth can be negative
return Math.toInt256(PRBU.mul(frailty, newWetWeaken)) - Math.toInt256(newWetStrengthen) + Math.toIn... | function weakBranchGrowth(uint256 newWetWeaken, uint256 newWetStrengthen, uint256 newDryWeaken, uint256 newDeadBranchGrowth, uint256 frailty) internal pure returns (int256) {
// growth can be negative
return Math.toInt256(PRBU.mul(frailty, newWetWeaken)) - Math.toInt256(newWetStrengthen) + Math.toIn... | 5,997 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.