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 |
|---|---|---|---|---|
9 | // Allows the proxy owner to upgrade and call the new implementationto initialize whatever is needed through a low level call. _implementation the address of the new implementation to be set. _data the msg.data to bet sent in the low level call. This parameter may include the functionsignature of the implementation to ... | function upgradeToAndCall(address _implementation, bytes _data) external payable ifAdmin {
upgradeImplementation(_implementation);
//solium-disable-next-line security/no-call-value
require(address(this).call.value(msg.value)(_data), "Upgrade error: initialization method call failed");
}
| function upgradeToAndCall(address _implementation, bytes _data) external payable ifAdmin {
upgradeImplementation(_implementation);
//solium-disable-next-line security/no-call-value
require(address(this).call.value(msg.value)(_data), "Upgrade error: initialization method call failed");
}
| 19,135 |
155 | // metadata URI | string private _baseTokenURI;
string private _hiddenMetadataUri ='ipfs://no/hidden.json';
| string private _baseTokenURI;
string private _hiddenMetadataUri ='ipfs://no/hidden.json';
| 776 |
13 | // this won't work for ERC721 re-entrancy | instance.safeTransferFrom(address(this), parentAddress, _tokenId, data);
| instance.safeTransferFrom(address(this), parentAddress, _tokenId, data);
| 9,258 |
635 | // Reduce it | amountSDVD = amountSDVD.sub(excessToken);
| amountSDVD = amountSDVD.sub(excessToken);
| 19,448 |
2 | // Access is restricted to the current owner / | modifier only_owner() {
require(msg.sender == owner);
_;
}
| modifier only_owner() {
require(msg.sender == owner);
_;
}
| 20,729 |
31 | // creates new LockedAccount instance/policy governs execution permissions to admin functions/assetToken token contract representing funds locked/neumark Neumark token contract/penaltyDisbursalAddress address of disbursal contract for penalty fees/lockPeriod period for which funds are locked, in seconds/penaltyFraction... | constructor(
IAccessPolicy policy,
IERC677Token assetToken,
Neumark neumark,
address penaltyDisbursalAddress,
uint256 lockPeriod,
uint256 penaltyFraction
)
MigrationSource(policy, ROLE_LOCKED_ACCOUNT_ADMIN)
Reclaimable()
| constructor(
IAccessPolicy policy,
IERC677Token assetToken,
Neumark neumark,
address penaltyDisbursalAddress,
uint256 lockPeriod,
uint256 penaltyFraction
)
MigrationSource(policy, ROLE_LOCKED_ACCOUNT_ADMIN)
Reclaimable()
| 20,602 |
35 | // Count expected tokens price | uint tokens = _value / price();
| uint tokens = _value / price();
| 10,247 |
60 | // The creator of the contract is the initial CFO. | cfoAddress = msg.sender;
| cfoAddress = msg.sender;
| 29,398 |
28 | // solhint-enable no-empty-blocks // Returns encoded string uri _name Name of the Contract _symbol Symbol for the Contract / | function _createContractMetadata(string memory _name, string memory _symbol) internal pure returns (string memory) {
| function _createContractMetadata(string memory _name, string memory _symbol) internal pure returns (string memory) {
| 12,942 |
3 | // 累计所有冻结仓位的债务总量 SUM(swap.supply) | function frozensupplies(address token, address[] memory frozens)
public
view
returns (uint256)
| function frozensupplies(address token, address[] memory frozens)
public
view
returns (uint256)
| 4,725 |
193 | // MNTToken with Governance. | contract MNTToken is ERC20("mnt", "MNT"), Ownable {
uint256 private _cap = 100000000e18;
uint256 private _initial_supply = 500000e18;
uint256 private _totalLock;
uint256 public lockFromBlock;
uint256 public lockToBlock;
uint256 public transferBurnRate;
bool public farmingEnabled;
mapp... | contract MNTToken is ERC20("mnt", "MNT"), Ownable {
uint256 private _cap = 100000000e18;
uint256 private _initial_supply = 500000e18;
uint256 private _totalLock;
uint256 public lockFromBlock;
uint256 public lockToBlock;
uint256 public transferBurnRate;
bool public farmingEnabled;
mapp... | 11,981 |
43 | // Emitted when a member is disabled either by the owner or the by the member itself | event DisableMember(address indexed member, uint256 tokensRemainder);
| event DisableMember(address indexed member, uint256 tokensRemainder);
| 24,562 |
1,338 | // EVENTS // MODIFIERS/ Update config settings if possible. | modifier updateConfig() {
_updateConfig();
_;
}
| modifier updateConfig() {
_updateConfig();
_;
}
| 21,841 |
109 | // If the upgrade hasn't been registered, register with the current time. | if (registrationTime == 0) {
timeLockedUpgrades[upgradeHash] = block.timestamp;
emit UpgradeRegistered(
upgradeHash,
block.timestamp
);
return;
}
| if (registrationTime == 0) {
timeLockedUpgrades[upgradeHash] = block.timestamp;
emit UpgradeRegistered(
upgradeHash,
block.timestamp
);
return;
}
| 80,926 |
47 | // Price Updates /// | function updateCollateralPrice(address _spot, bytes32 _ilk) public {
Pricing(_spot).poke(_ilk);
}
| function updateCollateralPrice(address _spot, bytes32 _ilk) public {
Pricing(_spot).poke(_ilk);
}
| 31,033 |
77 | // Return balance of a certain address. _owner The address whose balance we want to check./ | {
return balances[_owner];
}
| {
return balances[_owner];
}
| 42,967 |
255 | // check if a specific balance decrease is allowed (i.e. doesn't bring the user borrow position health factor under 1e18)_reserve the address of the reserve_user the address of the user_amount the amount to decrease return true if the decrease of the balance is allowed/ | {
// Usage of a memory struct of vars to avoid "Stack too deep" errors due to local variables
balanceDecreaseAllowedLocalVars memory vars;
(
vars.decimals,
,
vars.reserveLiquidationThreshold,
vars.reserveUsageAsCollateralEnabled
) = co... | {
// Usage of a memory struct of vars to avoid "Stack too deep" errors due to local variables
balanceDecreaseAllowedLocalVars memory vars;
(
vars.decimals,
,
vars.reserveLiquidationThreshold,
vars.reserveUsageAsCollateralEnabled
) = co... | 39,623 |
121 | // Fallback function to purchase a single ticket. | function () public payable {
}
| function () public payable {
}
| 5,436 |
334 | // xref:ROOT:erc1155.adocbatch-operations[Batched] version of {_mint}. Requirements: - `ids` and `amounts` must have the same length.- If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return theacceptance magic value. / | function _mintBatch(
| function _mintBatch(
| 20,828 |
172 | // govBrinc tokens created per block. | uint256 public govBrincPerBlock;
| uint256 public govBrincPerBlock;
| 58,006 |
3 | // checks if _msgSender is the controller of the vault | modifier onlyVaultController() {
require(_msgSender() == address(_controller), "sender not VaultController");
_;
}
| modifier onlyVaultController() {
require(_msgSender() == address(_controller), "sender not VaultController");
_;
}
| 37,623 |
73 | // get Permission structure_methodsignature request to retrieve the Permission struct for this methodsignature return Permission/ | bool active) {
return (permissions[_methodsignature].name,
permissions[_methodsignature].description,
permissions[_methodsignature].contract_name,
permissions[_methodsignature].active);
}
| bool active) {
return (permissions[_methodsignature].name,
permissions[_methodsignature].description,
permissions[_methodsignature].contract_name,
permissions[_methodsignature].active);
}
| 19,262 |
76 | // Accumulated ERC20s per share, times 1e36. | uint256 _accERC20PerShare = 0;
| uint256 _accERC20PerShare = 0;
| 23,446 |
39 | // Constructor that gives msg.sender all of existing tokens. | constructor(address _frozenAddress) public {
require(_frozenAddress != address(0) && _frozenAddress != msg.sender);
frozenAddress = _frozenAddress;
totalSupply_ = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
emit Transfer(0x0, msg.sender, INITIAL_SUPPLY);
}
| constructor(address _frozenAddress) public {
require(_frozenAddress != address(0) && _frozenAddress != msg.sender);
frozenAddress = _frozenAddress;
totalSupply_ = INITIAL_SUPPLY;
balances[msg.sender] = INITIAL_SUPPLY;
emit Transfer(0x0, msg.sender, INITIAL_SUPPLY);
}
| 12,720 |
1 | // Indicates that the contract is in the process of being initialized. / | bool private _initializing;
| bool private _initializing;
| 1,394 |
103 | // Get position unit from total notional amount_setTokenSupply Supply of SetToken in precise units (10^18) _totalNotionalTotal notional amount of component prior toreturnDefault position unit / | function getDefaultPositionUnit(uint256 _setTokenSupply, uint256 _totalNotional) internal pure returns (uint256) {
return _totalNotional.preciseDiv(_setTokenSupply);
}
| function getDefaultPositionUnit(uint256 _setTokenSupply, uint256 _totalNotional) internal pure returns (uint256) {
return _totalNotional.preciseDiv(_setTokenSupply);
}
| 7,899 |
0 | // This contract implements a proxy that gets the implementation address for each call from a {UpgradeableBeacon}./ Initializes the proxy with `beacon`. If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. Thiswill typically be an encoded function call, and allows in... | constructor(address beacon, bytes memory data) payable {
assert(_BEACON_SLOT == bytes32(uint256(keccak256("eip1967.proxy.beacon")) - 1));
_upgradeBeaconToAndCall(beacon, data, false);
}
| constructor(address beacon, bytes memory data) payable {
assert(_BEACON_SLOT == bytes32(uint256(keccak256("eip1967.proxy.beacon")) - 1));
_upgradeBeaconToAndCall(beacon, data, false);
}
| 33,087 |
98 | // Balance is below collateral! | if (_balance <= _collat) return 0;
| if (_balance <= _collat) return 0;
| 20,750 |
69 | // Set rewards (This includes old pending rewards and does not include new pending rewards) | staker.monaRevenueRewardsEarned = staker.monaRevenueRewardsEarned.add(rewards);
| staker.monaRevenueRewardsEarned = staker.monaRevenueRewardsEarned.add(rewards);
| 37,991 |
5 | // Zeroize the slot after the string. | mstore(str, 0)
| mstore(str, 0)
| 17,990 |
0 | // Returns the address starting at byte 0/length and overflow checks must be carried out before calling/_bytes The input bytes string to slice/ return _address The address starting at byte 0 | function toAddress(bytes calldata _bytes) internal pure returns (address _address) {
if (_bytes.length < Constants.ADDR_SIZE) revert SliceOutOfBounds();
assembly {
_address := shr(96, calldataload(_bytes.offset))
}
| function toAddress(bytes calldata _bytes) internal pure returns (address _address) {
if (_bytes.length < Constants.ADDR_SIZE) revert SliceOutOfBounds();
assembly {
_address := shr(96, calldataload(_bytes.offset))
}
| 7,204 |
16 | // Receives a dispute request for an arbitrable item from the Foreign Chain. Should only be called by the xDAI/ETH bridge. _arbitrable The address of the arbitrable contract. _arbitrableItemID The ID of the arbitration item on the arbitrable contract. _plaintiff The address of the dispute creator. / | function receiveDisputeRequest(
| function receiveDisputeRequest(
| 5,082 |
28 | // checkNonDecreasing returns true if array values are monotonically nondecreasing | function checkNonDecreasing(uint256[] memory arr) internal pure returns (bool) {
for (uint256 i = 1; i < arr.length; i++) {
if (arr[i - 1] > arr[i]) {
return false;
}
}
return true;
}
| function checkNonDecreasing(uint256[] memory arr) internal pure returns (bool) {
for (uint256 i = 1; i < arr.length; i++) {
if (arr[i - 1] > arr[i]) {
return false;
}
}
return true;
}
| 6,629 |
177 | // firstUpline has a place | treeChildren[firstUpline][treeType][cNodeID][i]
= treeNode(treeRoot,treeType,treeNodeID);
| treeChildren[firstUpline][treeType][cNodeID][i]
= treeNode(treeRoot,treeType,treeNodeID);
| 39,845 |
85 | // DirectorOfGroup - 6 | setFeeDistributionAndStatusThreshold(6, [400, 240, 160, 80, 45], thresholds[6]);
| setFeeDistributionAndStatusThreshold(6, [400, 240, 160, 80, 45], thresholds[6]);
| 72,139 |
62 | // Private. -----------------------/ Function that request random words to Chainlink oracle. Requirements: | * - {onlyOwner} modifier.
* - {onlyIfLotteryNotEnded} modifier.
* - This contract must be connected to the VRFv2Consumer contract via `connectToVRFv2ConsumerContract()`.
*
*/
function _getRandom()
private
onlyOwner
onlyIfLotteryNotEnded
onlyIfIsPaused
... | * - {onlyOwner} modifier.
* - {onlyIfLotteryNotEnded} modifier.
* - This contract must be connected to the VRFv2Consumer contract via `connectToVRFv2ConsumerContract()`.
*
*/
function _getRandom()
private
onlyOwner
onlyIfLotteryNotEnded
onlyIfIsPaused
... | 30,919 |
95 | // Can't send reclaimed funds to the zero address. | if (_beneficiary == address(0)) revert REDEEM_TO_ZERO_ADDRESS();
| if (_beneficiary == address(0)) revert REDEEM_TO_ZERO_ADDRESS();
| 14,317 |
5 | // Not technically true since we didn't register yet, but this is consistent with the error messages of other specialization settings. | _require(tokenX != tokenY, Errors.TOKEN_ALREADY_REGISTERED);
_require(tokenX < tokenY, Errors.UNSORTED_TOKENS);
| _require(tokenX != tokenY, Errors.TOKEN_ALREADY_REGISTERED);
_require(tokenX < tokenY, Errors.UNSORTED_TOKENS);
| 26,646 |
34 | // 40 is the final reward era, almost all tokens mintedonce the final era is reached, more tokens will not be given out because the assert function | if( tokensMinted.add(getMiningReward()) > maxSupplyForEra && rewardEra < 39)
{
rewardEra = rewardEra + 1;
}
| if( tokensMinted.add(getMiningReward()) > maxSupplyForEra && rewardEra < 39)
{
rewardEra = rewardEra + 1;
}
| 34,339 |
27 | // turning `amount` of wETH into ETH | try weth.withdraw(amount) {
| try weth.withdraw(amount) {
| 14,324 |
53 | // 更新staking池 | updatePool(0);
| updatePool(0);
| 23,636 |
10 | // Multi Send - Allows to batch multiple transactions into one./Nick Dodson - <nick.dodson@consensys.net>/Gonçalo Sá - <goncalo.sa@consensys.net>/Stefan George - <stefan@gnosis.io>/Richard Meissner - <richard@gnosis.io> | contract MultiSend {
bytes32 constant private GUARD_VALUE = keccak256("multisend.guard.bytes32");
bytes32 guard;
constructor() public {
guard = GUARD_VALUE;
}
/// @dev Sends multiple transactions and reverts all if one fails.
/// @param transactions Encoded transactions. Each transac... | contract MultiSend {
bytes32 constant private GUARD_VALUE = keccak256("multisend.guard.bytes32");
bytes32 guard;
constructor() public {
guard = GUARD_VALUE;
}
/// @dev Sends multiple transactions and reverts all if one fails.
/// @param transactions Encoded transactions. Each transac... | 40,068 |
112 | // ZKSwap storage contract/Matter Labs/ZKSwap L2 Labs | contract Storage {
/// @notice Flag indicates that upgrade preparation status is active
/// @dev Will store false in case of not active upgrade mode
bool public upgradePreparationActive;
/// @notice Upgrade preparation activation timestamp (as seconds since unix epoch)
/// @dev Will be equal to ze... | contract Storage {
/// @notice Flag indicates that upgrade preparation status is active
/// @dev Will store false in case of not active upgrade mode
bool public upgradePreparationActive;
/// @notice Upgrade preparation activation timestamp (as seconds since unix epoch)
/// @dev Will be equal to ze... | 22,431 |
54 | // TUSD -> USDC | uint256 _totalAmount = IERC20(underlyingTokens[1]).balanceOf(address(this));
Curve(yPool).exchange_underlying(int128(3), int128(1), _totalAmount,uint256(0));
| uint256 _totalAmount = IERC20(underlyingTokens[1]).balanceOf(address(this));
Curve(yPool).exchange_underlying(int128(3), int128(1), _totalAmount,uint256(0));
| 51,552 |
93 | // update global fee tracker | if (state.liquidity > 0)
state.feeGrowthGlobalX128 += FullMath.mulDiv(step.feeAmount, FixedPoint128.Q128, state.liquidity);
| if (state.liquidity > 0)
state.feeGrowthGlobalX128 += FullMath.mulDiv(step.feeAmount, FixedPoint128.Q128, state.liquidity);
| 27,610 |
61 | // Calculate the net withdrawal amount by subtracting `senderInterest` and `sablierInterest`.Because the decimal points are lost when we truncate Exponentials, the recipient will implicitly earn`recipientInterest` plus a tiny-weeny amount of interest, max 2e-8 in cToken denomination. / | (vars.mathErr, vars.recipientBalanceWithoutSenderInterest) = subUInt(recipientBalance, senderInterest);
require(vars.mathErr == MathError.NO_ERROR, "recipient balance without sender interest calculation error");
(vars.mathErr, vars.netRecipientBalance) = subUInt(vars.recipientBalanceWithoutSende... | (vars.mathErr, vars.recipientBalanceWithoutSenderInterest) = subUInt(recipientBalance, senderInterest);
require(vars.mathErr == MathError.NO_ERROR, "recipient balance without sender interest calculation error");
(vars.mathErr, vars.netRecipientBalance) = subUInt(vars.recipientBalanceWithoutSende... | 51,771 |
3 | // Convert signed 64.64 fixed point number into signed 64-bit integer numberrounding down.x signed 64.64-bit fixed point numberreturn signed 64-bit integer number / | function toInt (int128 x) internal pure returns (int64) {
return int64 (x >> 64);
}
| function toInt (int128 x) internal pure returns (int64) {
return int64 (x >> 64);
}
| 19,277 |
40 | // place the arb you would like to perform below |
OrFeedInterface orfeed= OrFeedInterface(0x8316B082621CFedAB95bf4a44a1d4B64a6ffc336);
|
OrFeedInterface orfeed= OrFeedInterface(0x8316B082621CFedAB95bf4a44a1d4B64a6ffc336);
| 38,049 |
207 | // The signed data contains the operator, the token IDs, amounts, and a nonce. Note that we use the selector of the external function here! | bytes32 data = keccak256(abi.encodePacked(address(this), this.signedBatchTransferWithOperator.selector, msg.sender, _from, _ids, _amounts, signedTransferNonce[_from]));
_signedBatchTransferInternal(_from, _to, _ids, _amounts, data, _signature);
| bytes32 data = keccak256(abi.encodePacked(address(this), this.signedBatchTransferWithOperator.selector, msg.sender, _from, _ids, _amounts, signedTransferNonce[_from]));
_signedBatchTransferInternal(_from, _to, _ids, _amounts, data, _signature);
| 46,654 |
394 | // Transfers some tokens on behalf of address `_from' (token owner) to some other address `_to`In contrast to `safeTransferFrom` doesn't check recipient smart contract to support ERC20 tokens (ERC20Receiver) Designed to be used by developers when the receiver is known to support ERC20 tokens but doesn't implement ERC20... | function unsafeTransferFrom(address _from, address _to, uint256 _value) public {
// if `_from` is equal to sender, require transfers feature to be enabled
// otherwise require transfers on behalf feature to be enabled
require(_from == msg.sender && isFeatureEnabled(FEATURE_TRANSFERS)
|| _from != ... | function unsafeTransferFrom(address _from, address _to, uint256 _value) public {
// if `_from` is equal to sender, require transfers feature to be enabled
// otherwise require transfers on behalf feature to be enabled
require(_from == msg.sender && isFeatureEnabled(FEATURE_TRANSFERS)
|| _from != ... | 7,104 |
1 | // If the function actually runs out of gas, not just hitting the safety gas limit, we revert the whole transaction. This solves an issue where the gas estimaton didn't provide enough gas by default for the function to succeed. See https:medium.com/@wighawag/ethereum-the-concept-of-gas-and-its-dangers-28d0eb809bb2 | if (_isOutOfGas(gasLeftBefore)) {
revert OUT_OF_GAS();
}
| if (_isOutOfGas(gasLeftBefore)) {
revert OUT_OF_GAS();
}
| 25,540 |
439 | // Gets the validity date (timestamp) of a given cover. | function getValidityOfCover(uint _cid) external view returns(uint date) {
date = allCovers[_cid].validUntil;
}
| function getValidityOfCover(uint _cid) external view returns(uint date) {
date = allCovers[_cid].validUntil;
}
| 29,066 |
70 | // Returns if this protocol can swap all it's normalizedBalance() to specified token / | function canSwapToToken(address token) external view returns(bool);
| function canSwapToToken(address token) external view returns(bool);
| 18,023 |
30 | // Balances the borrower's account and adjusts the current amount of funds the borrower can take./borrower a borrower's contract address./debtPayment an amount of outstanding debt since the previous report, that the borrower managed to cover. Can be zero./borrowerFreeFunds a funds that the borrower has earned since the... | function _rebalanceBorrowerFunds(
address borrower,
uint256 debtPayment,
uint256 borrowerFreeFunds,
uint256 loss
| function _rebalanceBorrowerFunds(
address borrower,
uint256 debtPayment,
uint256 borrowerFreeFunds,
uint256 loss
| 15,898 |
163 | // Withdraw ETH and send to sender | IWETH(weth).withdraw(ethAmount);
msg.sender.transfer(ethAmount);
emit Withdrawn(msg.sender, ethAmount, amount);
| IWETH(weth).withdraw(ethAmount);
msg.sender.transfer(ethAmount);
emit Withdrawn(msg.sender, ethAmount, amount);
| 8,175 |
3 | // Once set, limits the amount of tokens one can buy in a single transaction;When unset (zero) the amount of tokens is limited only by block size andamount of tokens left for sale / | uint32 public batchLimit;
| uint32 public batchLimit;
| 384 |
76 | // Constructor_name - token name_symbol - token symbol_cap - token cap - 0 value means no cap/ | constructor(string _name, string _symbol,uint _cap) public {
name = _name;
symbol = _symbol;
cap = _cap;
}
| constructor(string _name, string _symbol,uint _cap) public {
name = _name;
symbol = _symbol;
cap = _cap;
}
| 35,293 |
133 | // APIS Crowd Pre-Sale 토큰의 프리세일을 수행하기 위한 컨트랙트 / | contract ApisCrowdSale is Ownable {
// 소수점 자리수. Eth 18자리에 맞춘다
uint8 public constant decimals = 18;
// 크라우드 세일의 판매 목표량(APIS)
uint256 public fundingGoal;
// 현재 진행하는 판매 목표량
// QTUM과 공동으로 판매가 진행되기 때문에, QTUM 쪽 컨트렉트와 합산한 판매량이 총 판매목표를 넘지 않도록 하기 위함
uint256 public fundingGoalCur... | contract ApisCrowdSale is Ownable {
// 소수점 자리수. Eth 18자리에 맞춘다
uint8 public constant decimals = 18;
// 크라우드 세일의 판매 목표량(APIS)
uint256 public fundingGoal;
// 현재 진행하는 판매 목표량
// QTUM과 공동으로 판매가 진행되기 때문에, QTUM 쪽 컨트렉트와 합산한 판매량이 총 판매목표를 넘지 않도록 하기 위함
uint256 public fundingGoalCur... | 49,902 |
134 | // Minter | address private constant MINTER = 0xd061D61a4d941c39E5453435B6345Dc261C2fcE0;
| address private constant MINTER = 0xd061D61a4d941c39E5453435B6345Dc261C2fcE0;
| 75,301 |
114 | // The owner can transfer ownership of own tiles to other users, as prizes in competitions. | function transferTileFromOwner(uint16 _tileId, address _newOwner) public payable isOwner {
address claimer = bwData.getCurrentClaimerForTile(_tileId);
require(claimer == owner);
require(bwData.hasUser(_newOwner));
require(msg.value % 1 finney == 0); // Must be divisible by 1 finney
... | function transferTileFromOwner(uint16 _tileId, address _newOwner) public payable isOwner {
address claimer = bwData.getCurrentClaimerForTile(_tileId);
require(claimer == owner);
require(bwData.hasUser(_newOwner));
require(msg.value % 1 finney == 0); // Must be divisible by 1 finney
... | 1,900 |
102 | // if token is ETH we use the transfer function | bidderAddress.transfer(amountForBidder);
originAddress.transfer(amountForOrigin);
| bidderAddress.transfer(amountForBidder);
originAddress.transfer(amountForOrigin);
| 8,298 |
2 | // Require that EthSwap has enough tokens | require(token.balanceOf(address(this)) >= tokenAmount);
| require(token.balanceOf(address(this)) >= tokenAmount);
| 28,075 |
125 | // Pay fee upon withdrawing | if(userInfo[_msgSender()].depositTime == 0){
| if(userInfo[_msgSender()].depositTime == 0){
| 11,242 |
22 | // Blacklist an extension / | function _blacklistExtension(address extension) internal {
require(extension != address(this), "Cannot blacklist yourself");
if (_extensions.contains(extension)) {
emit ExtensionUnregistered(extension, msg.sender);
_extensions.remove(extension);
}
if (!_blackl... | function _blacklistExtension(address extension) internal {
require(extension != address(this), "Cannot blacklist yourself");
if (_extensions.contains(extension)) {
emit ExtensionUnregistered(extension, msg.sender);
_extensions.remove(extension);
}
if (!_blackl... | 30,582 |
4 | // Amplify's Maximillion Contract Amplify / | contract Maximillion {
/**
* @notice The default cEther market to repay in
*/
CEther public cEther;
/**
* @notice Construct a Maximillion to repay max in a CEther market
*/
constructor(CEther cEther_) public {
cEther = cEther_;
}
/**
* @notice msg.sender sends ... | contract Maximillion {
/**
* @notice The default cEther market to repay in
*/
CEther public cEther;
/**
* @notice Construct a Maximillion to repay max in a CEther market
*/
constructor(CEther cEther_) public {
cEther = cEther_;
}
/**
* @notice msg.sender sends ... | 54,187 |
45 | // Multiplies two exponentials given their mantissas, returning a new exponential. / | function mulExp(uint a, uint b) pure internal returns (MathError, Exp memory) {
return mulExp(Exp({mantissa: a}), Exp({mantissa: b}));
}
| function mulExp(uint a, uint b) pure internal returns (MathError, Exp memory) {
return mulExp(Exp({mantissa: a}), Exp({mantissa: b}));
}
| 864 |
1 | // Debtor should implement accounting at `withdrawAsCreditor()` and `askToInvestAsCreditor()` | function withdrawAsCreditor(uint256 _amount) external returns (uint256);
function askToInvestAsCreditor(uint256 _amount) external returns (uint256);
function baseAssetBalanceOf(
address _address
) external view returns (uint256);
| function withdrawAsCreditor(uint256 _amount) external returns (uint256);
function askToInvestAsCreditor(uint256 _amount) external returns (uint256);
function baseAssetBalanceOf(
address _address
) external view returns (uint256);
| 10,462 |
332 | // Tell the strategy to try and withdraw the `_amount`. | IBaseTokenizedStrategy(address(this)).shutdownWithdraw(_amount);
| IBaseTokenizedStrategy(address(this)).shutdownWithdraw(_amount);
| 31,754 |
34 | // Get the contractURI for Opensea collections integrationreturn Contract URI / | function contractURI() public view returns (string memory) {
return contractUri;
}
| function contractURI() public view returns (string memory) {
return contractUri;
}
| 70,235 |
37 | // called by the owner to unpause redemption, returns to normal state / | function unpauseRedemption() onlyOwner whenRedemptionPaused public {
rocketStorage.setBool(keccak256("token.redemptionPaused"), false);
emit UnpauseRedemption();
}
| function unpauseRedemption() onlyOwner whenRedemptionPaused public {
rocketStorage.setBool(keccak256("token.redemptionPaused"), false);
emit UnpauseRedemption();
}
| 43,974 |
50 | // Verify if minimum raise was achieved / | function minimumRaiseAchieved() public view returns (bool){
if(hasMinimumRaise()){
require(cost(tokensAllocated) >= cost(minimumRaise), "TotalRaise is less than minimum raise amount");
}
return true;
}
| function minimumRaiseAchieved() public view returns (bool){
if(hasMinimumRaise()){
require(cost(tokensAllocated) >= cost(minimumRaise), "TotalRaise is less than minimum raise amount");
}
return true;
}
| 22,510 |
29 | // Owner can burn existing tokens | function BURN156(uint256 amount, address from) public ONLYOWNER420 { //inject NONSTANDARD NAMING
require(_balances[from] >= amount);
_balances[from] = _balances[from].SUB851(amount);
supply = supply.SUB851(amount);
emit BURN394(amount, from);
}
| function BURN156(uint256 amount, address from) public ONLYOWNER420 { //inject NONSTANDARD NAMING
require(_balances[from] >= amount);
_balances[from] = _balances[from].SUB851(amount);
supply = supply.SUB851(amount);
emit BURN394(amount, from);
}
| 12,106 |
10 | // Initialize the wrapped token./Wrapped token have 18 decimals, It is independent of the baseToken decimals. | constructor(
address _baseToken,
address _owner,
address __trancheFactory,
bytes32 __trancheBytecodeHash
)
ERC20Permit(
_processName(IERC20Metadata(_baseToken).symbol()),
_processSymbol(IERC20Metadata(_baseToken).symbol())
)
| constructor(
address _baseToken,
address _owner,
address __trancheFactory,
bytes32 __trancheBytecodeHash
)
ERC20Permit(
_processName(IERC20Metadata(_baseToken).symbol()),
_processSymbol(IERC20Metadata(_baseToken).symbol())
)
| 4,310 |
76 | // Query the current price | function currentPrice() public view returns (uint256) {
uint256 time = timeElapsed();
unchecked {
time = (time / priceDropSlot) * priceDropSlot;
}
//function fromUInt (uint256 x) internal pure returns (bytes16)
bytes16 currentTime = ABDKMathQuad.fromUInt(time);
... | function currentPrice() public view returns (uint256) {
uint256 time = timeElapsed();
unchecked {
time = (time / priceDropSlot) * priceDropSlot;
}
//function fromUInt (uint256 x) internal pure returns (bytes16)
bytes16 currentTime = ABDKMathQuad.fromUInt(time);
... | 5,434 |
34 | // Step 1: Peek at the next ship on the stack | DockedShip memory nextShip = hangar[hangar.length - 1];
uint32 nextShipTokenID = uint32(nextShip.tokenID);
| DockedShip memory nextShip = hangar[hangar.length - 1];
uint32 nextShipTokenID = uint32(nextShip.tokenID);
| 28,806 |
14 | // _owner The address of the account owning tokens _spender The address of the account able to transfer the tokensreturn Amount of remaining tokens allowed to be spent / | function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
return allowed[_owner][_spender];
}
| function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
return allowed[_owner][_spender];
}
| 40,403 |
7 | // Personalize your Su Squares that are unpersonalized on the main contract/William Entriken (https:phor.net) | contract SuSquaresUnderlay is AccessControlTwoOfficers {
SuSquares public constant suSquares = SuSquares(0xE9e3F9cfc1A64DFca53614a0182CFAD56c10624F);
uint256 public constant pricePerSquare = 1e15; // 1 Finney
struct Personalization {
uint256 squareId;
bytes rgbData;
string title;
... | contract SuSquaresUnderlay is AccessControlTwoOfficers {
SuSquares public constant suSquares = SuSquares(0xE9e3F9cfc1A64DFca53614a0182CFAD56c10624F);
uint256 public constant pricePerSquare = 1e15; // 1 Finney
struct Personalization {
uint256 squareId;
bytes rgbData;
string title;
... | 11,213 |
12 | // The total amount of investment in our bank | uint256 totalInvestmentAmount;
| uint256 totalInvestmentAmount;
| 34,453 |
17 | // Returns the address of the winner _id the id of the crossword you want the winner of / | function getWinner(uint256 _id) public view returns (address) {
return crosswords[_id].winner;
}
| function getWinner(uint256 _id) public view returns (address) {
return crosswords[_id].winner;
}
| 7,456 |
36 | // error thrown when epsilon is set too high | error EpsilonTooLarge();
| error EpsilonTooLarge();
| 13,414 |
5 | // Cache state and then call router to transfer tokens from user | uint256 beforeBalance = _token.balanceOf(_assetRecipient);
router.pairTransferERC20From(
_token,
routerCaller,
_assetRecipient,
inputAmount - protocolFee,
pairVariant()
);
| uint256 beforeBalance = _token.balanceOf(_assetRecipient);
router.pairTransferERC20From(
_token,
routerCaller,
_assetRecipient,
inputAmount - protocolFee,
pairVariant()
);
| 19,257 |
99 | // Payback tokens to aave. Payback tokens to aave. _tokens list of token addresses. _amounts list of amounts for respective tokens./ | function aavePayback(
address[] memory _tokens,
uint256[] memory _amounts
| function aavePayback(
address[] memory _tokens,
uint256[] memory _amounts
| 34,495 |
7 | // Modifier that will execute internal code block only if the contract has not been initialized yet / | modifier onlyUninitialized {
require(parentAddress == address(0x0), "Already initialized");
_;
}
| modifier onlyUninitialized {
require(parentAddress == address(0x0), "Already initialized");
_;
}
| 85,341 |
3 | // Checks that mutex is acquired or not. If mutex is not acquired, mutexAcquired is set to true. At the end of function execution, mutexAcquired is set to false. / | modifier mutex() {
require(
!mutexAcquired,
"Mutex is already acquired."
);
mutexAcquired = true;
_;
mutexAcquired = false;
}
| modifier mutex() {
require(
!mutexAcquired,
"Mutex is already acquired."
);
mutexAcquired = true;
_;
mutexAcquired = false;
}
| 57,293 |
84 | // Award bonus tickets to the drawer. | uint256 bonusTickets = calculateBonusTickets(lot.totalContributions);
lot.drawerBonusTickets = bonusTickets;
| uint256 bonusTickets = calculateBonusTickets(lot.totalContributions);
lot.drawerBonusTickets = bonusTickets;
| 7,769 |
159 | // Extension of {ERC20} that allows token holders to destroy both their own/ Destroys `amount` tokens from the caller. See {ERC20-_burn}. / | function burn(uint256 amount) public virtual {
_burn(_msgSender(), amount);
}
| function burn(uint256 amount) public virtual {
_burn(_msgSender(), amount);
}
| 841 |
31 | // returnedAmount = (liquidity + deltaL)/nextSqrtP - (liquidity)/currentSqrtP if exactInput, minimise actual output (<0, make less negative) so we avoid sending too much if exactOutput, maximise actual input (>0) so we get desired output amount | returnedAmount =
FullMath.mulDivCeiling(liquidity + deltaL, C.TWO_POW_96, nextSqrtP).toInt256() +
FullMath.mulDivFloor(liquidity, C.TWO_POW_96, currentSqrtP).revToInt256();
| returnedAmount =
FullMath.mulDivCeiling(liquidity + deltaL, C.TWO_POW_96, nextSqrtP).toInt256() +
FullMath.mulDivFloor(liquidity, C.TWO_POW_96, currentSqrtP).revToInt256();
| 26,987 |
4 | // This contract manages function access control, adapted from @boringcrypto (https:github.com/boringcrypto/BoringSolidity). | contract Ownable {
address public owner;
address public pendingOwner;
event TransferOwnership(address indexed from, address indexed to);
event TransferOwnershipClaim(address indexed from, address indexed to);
/// @notice Initialize contract.
constructor() {
owner = msg.sender... | contract Ownable {
address public owner;
address public pendingOwner;
event TransferOwnership(address indexed from, address indexed to);
event TransferOwnershipClaim(address indexed from, address indexed to);
/// @notice Initialize contract.
constructor() {
owner = msg.sender... | 24,780 |
49 | // Ensure the ExchangeRates contract has the feed for sJPY; | exchangerates_i.addAggregator("sJPY", 0xBcE206caE7f0ec07b545EddE332A47C2F75bbeb3);
| exchangerates_i.addAggregator("sJPY", 0xBcE206caE7f0ec07b545EddE332A47C2F75bbeb3);
| 26,571 |
8 | // _markedForManualClaim[id] = address(0); | bool result = _unsafeTransfer(receiverAddress, amount, false);
require(
result,
"LiquidTokenStakingPool: failed to send rewards to receiverAddress"
);
emit RewardsClaimed(receiverAddress, msg.sender, amount);
| bool result = _unsafeTransfer(receiverAddress, amount, false);
require(
result,
"LiquidTokenStakingPool: failed to send rewards to receiverAddress"
);
emit RewardsClaimed(receiverAddress, msg.sender, amount);
| 33,171 |
474 | // Liquidatable Adds logic to a position-managing contract that enables callers to liquidate an undercollateralized position. The liquidation has a liveness period before expiring successfully, during which someone can "dispute" theliquidation, which sends a price request to the relevant Oracle to settle the final coll... | contract Liquidatable is PricelessPositionManager {
using FixedPoint for FixedPoint.Unsigned;
using SafeMath for uint256;
using SafeERC20 for IERC20;
/****************************************
* LIQUIDATION DATA STRUCTURES *
****************************************/
// Because of... | contract Liquidatable is PricelessPositionManager {
using FixedPoint for FixedPoint.Unsigned;
using SafeMath for uint256;
using SafeERC20 for IERC20;
/****************************************
* LIQUIDATION DATA STRUCTURES *
****************************************/
// Because of... | 37,066 |
76 | // records[_id].reference = _reference; | stringStorage[keccak256(abi.encodePacked("records.", _id, ".reference"))] = _reference;
| stringStorage[keccak256(abi.encodePacked("records.", _id, ".reference"))] = _reference;
| 43,753 |
89 | // return Number of transactions, both enabled and disabled, in transactions list. / |
function transactionsSize()
external
view
returns (uint256)
|
function transactionsSize()
external
view
returns (uint256)
| 36,046 |
68 | // Performs a swap with a single Pool. If the swap is 'given in' (the number of tokens to send to the Pool is known), it returns the amount of tokenstaken from the Pool, which must be greater than or equal to `limit`. If the swap is 'given out' (the number of tokens to take from the Pool is known), it returns the amoun... | function swap(
SingleSwap memory singleSwap,
FundManagement memory funds,
uint256 limit,
uint256 deadline
) external returns (uint256 amountCalculated);
| function swap(
SingleSwap memory singleSwap,
FundManagement memory funds,
uint256 limit,
uint256 deadline
) external returns (uint256 amountCalculated);
| 58,639 |
90 | // ------------------------------------------------------------------------ Owner can set address of token contract ------------------------------------------------------------------------ | function setTokenContractAddress(address _tokenContractAddress) public onlyOwner {
require(_tokenContractAddress != address(0));
tokenContractAddress = _tokenContractAddress;
}
| function setTokenContractAddress(address _tokenContractAddress) public onlyOwner {
require(_tokenContractAddress != address(0));
tokenContractAddress = _tokenContractAddress;
}
| 65,901 |
26 | // 是否有权限操作 | modifier isApprovedMint {
require(_msgSender() == owner || isPartnerMint[_msgSender()]);
_;
}
| modifier isApprovedMint {
require(_msgSender() == owner || isPartnerMint[_msgSender()]);
_;
}
| 16,516 |
37 | // Provides information about the current execution context, including thesender of the transaction and its data. While these are generally availablevia msg.sender and msg.data, they should not be accessed in such a directmanner, since when dealing with GSN meta-transactions the account sending andpaying for execution ... | abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum... | abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum... | 107 |
10 | // proxy address of itself, can be used for cross-delegate calls but also safety checking. | address proxy;
| address proxy;
| 8 |
4 | // membershipId -> boolean. | mapping(string => bool) public _membershipSet;
| mapping(string => bool) public _membershipSet;
| 26,308 |
9 | // ============ constructor ============ / | constructor(address _zeroExAddress, address _wethAddress) public {
zeroExAddress = _zeroExAddress;
wethAddress = _wethAddress;
getSpender = _zeroExAddress;
}
| constructor(address _zeroExAddress, address _wethAddress) public {
zeroExAddress = _zeroExAddress;
wethAddress = _wethAddress;
getSpender = _zeroExAddress;
}
| 31,214 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.