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
19
// extend the auction for the ticker if someone is outbidding near the end
if (isNearEndOfBidding) { auction.biddingEnd = auction.biddingEnd + BID_EXTENSION_IN_BLOCKS; emit AuctionForTickerExtended(lowerBrandTicker, auction.biddingEnd); }
if (isNearEndOfBidding) { auction.biddingEnd = auction.biddingEnd + BID_EXTENSION_IN_BLOCKS; emit AuctionForTickerExtended(lowerBrandTicker, auction.biddingEnd); }
11,630
35
// Used for cash settlement excerise for an active option _optionId Option id /
function exercise(uint256 _optionId) external override { Option storage option = options[_optionId]; require(option.expiration >= block.timestamp, "Option has expired"); require(option.holder == msg.sender, "Invalid Caller"); require(option.state == State.Active, "Invalid state"); ...
function exercise(uint256 _optionId) external override { Option storage option = options[_optionId]; require(option.expiration >= block.timestamp, "Option has expired"); require(option.holder == msg.sender, "Invalid Caller"); require(option.state == State.Active, "Invalid state"); ...
4,182
163
// Accrue interest
uint128 extraAmount = uint128((uint256(_totalBorrow.elastic) * cloneInfo.interestPerSecond * elapsedTime) / 1e18); _totalBorrow.elastic = _totalBorrow.elastic + extraAmount; _accrueInfo.feesEarned = _accrueInfo.feesEarned + extraAmount; totalBorrow = _totalBorrow; accrueInfo = _...
uint128 extraAmount = uint128((uint256(_totalBorrow.elastic) * cloneInfo.interestPerSecond * elapsedTime) / 1e18); _totalBorrow.elastic = _totalBorrow.elastic + extraAmount; _accrueInfo.feesEarned = _accrueInfo.feesEarned + extraAmount; totalBorrow = _totalBorrow; accrueInfo = _...
32,877
87
// A mapping of each investor address to a specific amount
mapping(address => uint256) public userTotalAmount;
mapping(address => uint256) public userTotalAmount;
33,270
45
// Has balance and is NOT broken
if (isBrokenToken[tokens[i]] == false && amounts[tokens[i]] > 0 ) {length++;}
if (isBrokenToken[tokens[i]] == false && amounts[tokens[i]] > 0 ) {length++;}
36,586
47
// Emits an {InvestorListUpdated} event indicating the update. Requirements: - `sender` must be admin. /
function updateInvestorStatus(address _investorAddress,bool updateType) public onlyOwner { if(usersList[_investorAddress].userAddress == address(0)){ usersList[_investorAddress] = User(_investorAddress,0,true); }
function updateInvestorStatus(address _investorAddress,bool updateType) public onlyOwner { if(usersList[_investorAddress].userAddress == address(0)){ usersList[_investorAddress] = User(_investorAddress,0,true); }
27,362
19
// Set base URI for computing {tokenURI}. _baseUri The new baseUri. /
function setBaseUri( string memory _baseUri ) external onlyOwner { super._setBaseUri(_baseUri); }
function setBaseUri( string memory _baseUri ) external onlyOwner { super._setBaseUri(_baseUri); }
8,688
196
// Minting with metadata received from L2 i.e. emitted by event `TransferWithMetadata` during burning
bytes memory logData = logRLPList[2].toBytes(); bytes memory metaData = abi.decode(logData, (bytes)); token.mint(withdrawer, tokenId, metaData);
bytes memory logData = logRLPList[2].toBytes(); bytes memory metaData = abi.decode(logData, (bytes)); token.mint(withdrawer, tokenId, metaData);
56,890
27
// Returns whether the given spender can transfer a given token ID to holder _spender address of the spender to query _to uint256 ID of the holder to receive the token ID _toOrigin address of the holder's origin _tokenId uint256 ID of the token to be transferredreturn bool whether the msg.sender is approved for the giv...
function isHolderApprovedFor(address _spender, uint256 _to, address _toOrigin, uint256 _tokenId) internal view returns (bool)
function isHolderApprovedFor(address _spender, uint256 _to, address _toOrigin, uint256 _tokenId) internal view returns (bool)
49,284
74
// Transfer a token between 2 addresses letting the receiver knows of the transfer from The sender of the token to The recipient of the token id The id of the token data Additional data /
function safeTransferFrom(address from, address to, uint256 id, bytes memory data) public { bool metaTx = _checkTransfer(from, to, id); _transferFrom(from, to, id); if (to.isContract()) { require( _checkOnERC721Received(metaTx ? from : msg.sender, from, to, id, da...
function safeTransferFrom(address from, address to, uint256 id, bytes memory data) public { bool metaTx = _checkTransfer(from, to, id); _transferFrom(from, to, id); if (to.isContract()) { require( _checkOnERC721Received(metaTx ? from : msg.sender, from, to, id, da...
16,586
141
// An event emitted when a proposal has been queued in the Timelock
event ProposalQueued(uint256 id, uint256 eta);
event ProposalQueued(uint256 id, uint256 eta);
7,534
22
// Set the current user's favorite album information
function setUsersFavoriteAlbum(string memory _artist, string memory _albumTitle, uint _tracks) public { userAlbums[msg.sender].artist = _artist; userAlbums[msg.sender].albumTitle = _albumTitle; userAlbums[msg.sender].tracks = _tracks; // Raise the albumEvent to let any event...
function setUsersFavoriteAlbum(string memory _artist, string memory _albumTitle, uint _tracks) public { userAlbums[msg.sender].artist = _artist; userAlbums[msg.sender].albumTitle = _albumTitle; userAlbums[msg.sender].tracks = _tracks; // Raise the albumEvent to let any event...
20,676
8
// ipfs id for this file
string ipfshash; FileState state;
string ipfshash; FileState state;
63,601
3
// Public Functions /
function resolveContract( string memory _name ) public view returns (address)
function resolveContract( string memory _name ) public view returns (address)
3,751
100
// Modifies a slot at an index for a given branch. _branch Branch node to modify. _index Slot index to modify. _value Value to insert into the slot.return _updatedNode Modified branch node. /
function _editBranchIndex( TrieNode memory _branch, uint8 _index, bytes memory _value ) private pure returns ( TrieNode memory _updatedNode )
function _editBranchIndex( TrieNode memory _branch, uint8 _index, bytes memory _value ) private pure returns ( TrieNode memory _updatedNode )
37,960
51
// The value is stored at length-1, but we add 1 to all indexes and use 0 as a sentinel value
set._indexes[value] = set._values.length; return true;
set._indexes[value] = set._values.length; return true;
4,190
21
// _executor Address of the executor (e.g. a Safe)/_oracle Address of the oracle (e.g. Realitio)/timeout Timeout in seconds that should be required for the oracle/cooldown Cooldown in seconds that should be required after a oracle provided answer/expiration Duration that a positive answer of the oracle is valid in seco...
constructor(Executor _executor, Realitio _oracle, uint32 timeout, uint32 cooldown, uint32 expiration, uint256 bond, uint256 templateId) { require(timeout > 0, "Timeout has to be greater 0"); require(expiration == 0 || expiration - cooldown >= 60 , "There need to be at least 60s between end of cooldo...
constructor(Executor _executor, Realitio _oracle, uint32 timeout, uint32 cooldown, uint32 expiration, uint256 bond, uint256 templateId) { require(timeout > 0, "Timeout has to be greater 0"); require(expiration == 0 || expiration - cooldown >= 60 , "There need to be at least 60s between end of cooldo...
9,683
53
// Loop through and initialize isModule, isFactory, and isResource mapping
for (uint256 i = 0; i < _factories.length; i++) { require(_factories[i] != address(0), "Zero address submitted."); isFactory[_factories[i]] = true; }
for (uint256 i = 0; i < _factories.length; i++) { require(_factories[i] != address(0), "Zero address submitted."); isFactory[_factories[i]] = true; }
46,688
6
// If no bids were made, so the status never transitioned from OPT_OUT to AUCTIONS_OPEN, then bestBid.bidder is 0, which will trigger a require later
require(settlePeriodStart <= now && now < settlePeriodEnd, "Error: not within rebalancing period"); status = Status.OPEN;
require(settlePeriodStart <= now && now < settlePeriodEnd, "Error: not within rebalancing period"); status = Status.OPEN;
44,718
5
// callback from oraclize with the result, let the storage contract know
function __callback(bytes32 myid, string result, bytes proof) { if (msg.sender != oraclize_cbAddress()) throw; // this is basically a bytes32 to hexstring piece string memory expected = iudexIdToString(expectedId[myid]); bool asExpected = indexOf(result, expected) > -1; Storage(lookup.addrStorage...
function __callback(bytes32 myid, string result, bytes proof) { if (msg.sender != oraclize_cbAddress()) throw; // this is basically a bytes32 to hexstring piece string memory expected = iudexIdToString(expectedId[myid]); bool asExpected = indexOf(result, expected) > -1; Storage(lookup.addrStorage...
35,882
70
// Picks out the ID for a node. Node ID is referred to as the"hash" within the specification, but nodes < 32 bytes are not actuallyhashed. _node Node to pull an ID for.return _nodeID ID for the node, depending on the size of its contents. /
function _getNodeID( Lib_RLPReader.RLPItem memory _node ) private pure returns ( bytes32 _nodeID )
function _getNodeID( Lib_RLPReader.RLPItem memory _node ) private pure returns ( bytes32 _nodeID )
37,944
38
// 36 = 4-byte selector 0x4e487b71 + 32 bytes integer
else if (data.length == 36 && data[0] == "\x4e" && data[1] == "\x48" && data[2] == "\x7b" && data[3] == "\x71") { uint256 code;
else if (data.length == 36 && data[0] == "\x4e" && data[1] == "\x48" && data[2] == "\x7b" && data[3] == "\x71") { uint256 code;
10,324
13
// Convert to 18 decimals
premium = premium.mul(assetOracleMultiplier);
premium = premium.mul(assetOracleMultiplier);
63,115
27
// Oracle Settings
{ IFraxlendWhitelist _fraxlendWhitelist = IFraxlendWhitelist(FRAXLEND_WHITELIST_ADDRESS);
{ IFraxlendWhitelist _fraxlendWhitelist = IFraxlendWhitelist(FRAXLEND_WHITELIST_ADDRESS);
24,464
2
// Returns the amount of tokens owned by `account`. /
function balanceOf(address tokenOwner) virtual public view returns (uint balance);
function balanceOf(address tokenOwner) virtual public view returns (uint balance);
6,297
21
// Returns true if `operator` is approved to transfer ``account``'s tokens. See {setApprovalForAll}. /
function isApprovedForAll(address account, address operator) external view returns (bool);
function isApprovedForAll(address account, address operator) external view returns (bool);
6,880
19
// ...in which case `anotherSandwich` will simply be a copy of thedata in memory, and...
anotherSandwich.status = "Eaten!";
anotherSandwich.status = "Eaten!";
3,720
17
// onlyRole(DEPOSITOR_ROLE)
{ ChildERC20GaslessUpgradeable._mint(account, amount); }
{ ChildERC20GaslessUpgradeable._mint(account, amount); }
24,768
11
// Donates DUST Costs more to claim dust than it's worth /IERC20(frax).safeTransfer(Send performance fee to strategist
uint256 _want = IERC20(want).balanceOf(address(this)); if (_want > 0) { uint256 performanceFee = _want.mul(keepFXS).div(keepFXSmax); IERC20(want).safeTransfer( strategist, performanceFee ); }
uint256 _want = IERC20(want).balanceOf(address(this)); if (_want > 0) { uint256 performanceFee = _want.mul(keepFXS).div(keepFXSmax); IERC20(want).safeTransfer( strategist, performanceFee ); }
68,141
36
// set a mintFeeRecipient for a specific address/address_ The address of the account/mintFeeRecipient_ The address of the mint fee recipient
function setMintFeeRecipientForAddress(address address_, address mintFeeRecipient_) external onlyOwner { mintFeeRecipientList[address_] = mintFeeRecipient_; }
function setMintFeeRecipientForAddress(address address_, address mintFeeRecipient_) external onlyOwner { mintFeeRecipientList[address_] = mintFeeRecipient_; }
9,518
87
// Send ether to the fund collection wallet
function forwardFunds() internal { MULTISIG_ETH.transfer(address(this).balance); }
function forwardFunds() internal { MULTISIG_ETH.transfer(address(this).balance); }
8,976
29
// Add the same to the recipient
balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true;
balanceOf[_to] = (balanceOf[_to] + _value); allowed[_from][msg.sender] = (allowed[_from][msg.sender] - _value); Transfer(_from, _to, _value); return true;
22,074
8
// Implementations The set of implementation contracts to be used for proxies in the Deployer /
struct Implementations { IMain main; Components components; ITrade trade; }
struct Implementations { IMain main; Components components; ITrade trade; }
38,621
627
// Deposits tokens into the vault.//_amount the amount of tokens to deposit into the vault.
function deposit(uint256 _amount) external override { vault.deposit(_amount); }
function deposit(uint256 _amount) external override { vault.deposit(_amount); }
15,681
84
// Withdraw indexer tokens once the thawing period has passed. /
function withdraw() external override notPaused { _withdraw(msg.sender); }
function withdraw() external override notPaused { _withdraw(msg.sender); }
12,518
29
// ---------------------------------------------------------------------------- WUMI ERC20 Token----------------------------------------------------------------------------
contract WUMI is ERC20Interface, Owned { using SafeMath for uint; bool public running = true; string public symbol; string public name; uint8 public decimals; uint _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // -----------...
contract WUMI is ERC20Interface, Owned { using SafeMath for uint; bool public running = true; string public symbol; string public name; uint8 public decimals; uint _totalSupply; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; // -----------...
24,676
3
// The EGG TOKEN!
EggToken public egg;
EggToken public egg;
14,093
22
// Constructor function - init core params on deploy timestampts are uint64s to give us plenty of room for millennia flags are [_useEncryption, enableTesting]
function SVLightBallotBox(bytes32 _specHash, uint64[2] openPeriod, bool[2] flags) public { owner = msg.sender; // take the max of the start time provided and the blocks timestamp to avoid a DoS against recent token holders // (which someone might be able to do if they could set the timestam...
function SVLightBallotBox(bytes32 _specHash, uint64[2] openPeriod, bool[2] flags) public { owner = msg.sender; // take the max of the start time provided and the blocks timestamp to avoid a DoS against recent token holders // (which someone might be able to do if they could set the timestam...
80,914
17
// 1. desireY(rg.sqrtRate_96 - 2^96)< 2^1282^96= 2 ^ 224 < 2 ^ 256 2. desireY < maxY = rg.liquidity(rg.sqrtPriceR_96 - rg.sqrtPriceL_96) / (rg.sqrtRate_96 - 2^96) here, '/' means div of int desireY < rg.liquidity(rg.sqrtPriceR_96 - rg.sqrtPriceL_96) / (rg.sqrtRate_96 - 2^96) => desireY(rg.sqrtRate_96 - TwoPower.Pow96) ...
uint160 cl = uint160(uint256(rg.sqrtPriceR_96) - uint256(desireY) * (rg.sqrtRate_96 - TwoPower.Pow96) / rg.liquidity); ret.locPt = LogPowMath.getLogSqrtPriceFloor(cl) + 1; ret.locPt = MaxMinMath.min(ret.locPt, rg.rightPt); ret.locPt = MaxMinMath.max(ret.locPt, rg.leftPt...
uint160 cl = uint160(uint256(rg.sqrtPriceR_96) - uint256(desireY) * (rg.sqrtRate_96 - TwoPower.Pow96) / rg.liquidity); ret.locPt = LogPowMath.getLogSqrtPriceFloor(cl) + 1; ret.locPt = MaxMinMath.min(ret.locPt, rg.rightPt); ret.locPt = MaxMinMath.max(ret.locPt, rg.leftPt...
30,603
0
// roles
address public immutable owner; address payable public immutable beneficiary;
address public immutable owner; address payable public immutable beneficiary;
18,285
521
// The ChainlinkClient contract Contract writers can inherit this contract in order to create requests for theChainlink network /
contract ChainlinkClient { using Chainlink for Chainlink.Request; using SafeMath_Chainlink for uint256; uint256 constant internal LINK = 10**18; uint256 constant private AMOUNT_OVERRIDE = 0; address constant private SENDER_OVERRIDE = address(0); uint256 constant private ARGS_VERSION = 1; bytes32 constant...
contract ChainlinkClient { using Chainlink for Chainlink.Request; using SafeMath_Chainlink for uint256; uint256 constant internal LINK = 10**18; uint256 constant private AMOUNT_OVERRIDE = 0; address constant private SENDER_OVERRIDE = address(0); uint256 constant private ARGS_VERSION = 1; bytes32 constant...
16,215
245
// Converts a uint256 to its ASCII string decimal representation. /
function _toString(uint256 value) internal pure virtual returns (string memory str) { assembly { // The maximum value of a uint256 contains 78 digits (1 byte per digit), but // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned. ...
function _toString(uint256 value) internal pure virtual returns (string memory str) { assembly { // The maximum value of a uint256 contains 78 digits (1 byte per digit), but // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned. ...
31,493
131
// transfer toTokens to sender
if (toTokenAddress == address(0)) { totalGoodwillPortion = _subtractGoodwill( ETHAddress, tokensRec, affiliate, true ); payable(msg.sender).transfer(tokensRec - totalGoodwillPortion); } else {
if (toTokenAddress == address(0)) { totalGoodwillPortion = _subtractGoodwill( ETHAddress, tokensRec, affiliate, true ); payable(msg.sender).transfer(tokensRec - totalGoodwillPortion); } else {
16,271
17
// Mints the assets accrued through the reserve factor to the treasury in the form of aTokens assets The list of reserves for which the minting needs to be executed // Rescue and transfer tokens locked in this contract token The address of the token to The address of the recipient amount The amount of token to transfer...
function rescueTokens(
function rescueTokens(
20,355
237
// uint256 _p3d = (_pot.mul(potSplit_[_winTID].p3d)) / 100;
uint256 _fee = ((round_[_rID].pot) / 50).add(((round_[_rID].pot).mul(potSplit_[round_[_rID].team].p3d)) / 100); uint256 _res = ((((round_[_rID].pot).sub(_win)).sub(_fee)).sub(_gen));
uint256 _fee = ((round_[_rID].pot) / 50).add(((round_[_rID].pot).mul(potSplit_[round_[_rID].team].p3d)) / 100); uint256 _res = ((((round_[_rID].pot).sub(_win)).sub(_fee)).sub(_gen));
24,224
11
// creating new array campaign using new keyword; we can also create new address ( new address() ) [{}, {}, {}]
Campaign[] memory allCampaigns = new Campaign[](numberOfCampaigns); for (uint i = 0; i < allCampaigns.length; i++) { Campaign storage item = campaigns[i]; allCampaigns[i] = item; }
Campaign[] memory allCampaigns = new Campaign[](numberOfCampaigns); for (uint i = 0; i < allCampaigns.length; i++) { Campaign storage item = campaigns[i]; allCampaigns[i] = item; }
27,523
72
// Multiplier on the marginRatio for this market
Decimal.D256 marginPremium;
Decimal.D256 marginPremium;
7,886
4
// Check if the address has minted
require(!_hasMinted[msg.sender], "This address already minted an Anky");
require(!_hasMinted[msg.sender], "This address already minted an Anky");
6,564
17
// 通过Unix时间戳获取年份
function getYear(uint timestamp) public pure returns (uint16) { uint secondsAccountedFor = 0; // 用于累计已解析的秒数 uint16 year; // 年份变量 uint numLeapYears; // 闰年个数 ...
function getYear(uint timestamp) public pure returns (uint16) { uint secondsAccountedFor = 0; // 用于累计已解析的秒数 uint16 year; // 年份变量 uint numLeapYears; // 闰年个数 ...
15,283
107
// risk group: 17 - APR: 7.81%
file("riskGroup", 17, ONE, 85*10**25, uint(1000000002477168949771689497), 99.79*10**25);
file("riskGroup", 17, ONE, 85*10**25, uint(1000000002477168949771689497), 99.79*10**25);
40,288
26
// distribute profit between all users
function _callbackFinRes(uint16 index, uint256 ltAmount, uint256 receivedAmountB, bool isProfit, uint256 finResB) internal override { //apply operation fin res to totalcap and calculate commissions if(isProfit){ uint256 externalCommission = finResB.mul(externalCommissionPercentNom).div(...
function _callbackFinRes(uint16 index, uint256 ltAmount, uint256 receivedAmountB, bool isProfit, uint256 finResB) internal override { //apply operation fin res to totalcap and calculate commissions if(isProfit){ uint256 externalCommission = finResB.mul(externalCommissionPercentNom).div(...
28,701
211
// bytes4(keccak256('name()')) == 0x06fdde03bytes4(keccak256('symbol()')) == 0x95d89b41bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f /
bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;
bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;
706
422
// solhint-disable-next-line not-rely-on-time
return (getCurrentTime(), now);
return (getCurrentTime(), now);
1,731
5
// : logic overview 1) Coupons just purchased will fail at 1 epoch check. 2) Valid coupons redeemed during contraction will suffer 5% penalty fee plus forgo rewarded amount 3) Valid coupons without sufficient redeemable will fail at redeemToAccount.
function redeemCoupons(uint256 couponEpoch, uint256 amount) external { require(epoch().sub(couponEpoch) >= 1, "Market: Too early to redeem"); require(amount != 0, "Market: Amount too low"); // early redemption penalty. Coupon premium stays if (eraStatus() != Era.Status.EXPANSION) { ...
function redeemCoupons(uint256 couponEpoch, uint256 amount) external { require(epoch().sub(couponEpoch) >= 1, "Market: Too early to redeem"); require(amount != 0, "Market: Amount too low"); // early redemption penalty. Coupon premium stays if (eraStatus() != Era.Status.EXPANSION) { ...
16,104
230
// transfer tokens to this contract
IERC20(token).safeTransferFrom(msg.sender, address(this), _amount); if (!_skipRebalance) {
IERC20(token).safeTransferFrom(msg.sender, address(this), _amount); if (!_skipRebalance) {
10,468
297
// orderEpoch is initialized to 0, so to cancelUpTo we need salt + 1
uint256 newOrderEpoch = targetOrderEpoch + 1; uint256 oldOrderEpoch = orderEpoch[makerAddress][orderSenderAddress];
uint256 newOrderEpoch = targetOrderEpoch + 1; uint256 oldOrderEpoch = orderEpoch[makerAddress][orderSenderAddress];
14,366
120
// Add funds to the allocation
alloc.collectedFees = alloc.collectedFees.add(queryFees);
alloc.collectedFees = alloc.collectedFees.add(queryFees);
20,640
32
// Performs a Solidity function call using a low level `call`. A plain`call` is an unsafe replacement for a function call: use this function instead. If `target` reverts with a revert reason, it is bubbled up by this function (like regular Solidity function calls). Returns the raw returned data. To convert to the expec...
function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); }
function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); }
3,341
11
// uint32 id;
int64 lowerBidId; // if this outbids an older bid, otherwise -1 address payable addr; uint amount; string request;
int64 lowerBidId; // if this outbids an older bid, otherwise -1 address payable addr; uint amount; string request;
9,384
16
// Multi reject_addresses agreements addresses array/
function batchRejectAgreements(address[] calldata _addresses) external onlyAdmin() { require(_addresses.length <= 256, "FRF3"); for (uint256 i = 0; i < _addresses.length; i++) { if (IAgreement(_addresses[i]).isBeforeStatus(IAgreement.Statuses.Active)) { IAgreement(_addres...
function batchRejectAgreements(address[] calldata _addresses) external onlyAdmin() { require(_addresses.length <= 256, "FRF3"); for (uint256 i = 0; i < _addresses.length; i++) { if (IAgreement(_addresses[i]).isBeforeStatus(IAgreement.Statuses.Active)) { IAgreement(_addres...
4,890
86
// Claim AAVE rewards from the Safety Module & stake them to receive stkAAVE/
function _getStkAaveRewards() internal { IStakedAave _stkAave = IStakedAave(STK_AAVE); // Get pending rewards amount uint256 pendingRewards = _stkAave.getTotalRewardsBalance(address(this)); if (pendingRewards > 0) { // Claim the AAVE tokens _stkAave.claimRew...
function _getStkAaveRewards() internal { IStakedAave _stkAave = IStakedAave(STK_AAVE); // Get pending rewards amount uint256 pendingRewards = _stkAave.getTotalRewardsBalance(address(this)); if (pendingRewards > 0) { // Claim the AAVE tokens _stkAave.claimRew...
38,082
28
// We assume that all the tradings can be done on Sushiswap
function _liquidateReward() internal { if (!sell()) { // Profits can be disabled for possible simplified and rapoolId exit emit ProfitsNotCollected(sell(), false); return; } for(uint256 i = 0; i < rewardTokens.length; i++){ address token = rewardTokens[i]; uint256 rewardBala...
function _liquidateReward() internal { if (!sell()) { // Profits can be disabled for possible simplified and rapoolId exit emit ProfitsNotCollected(sell(), false); return; } for(uint256 i = 0; i < rewardTokens.length; i++){ address token = rewardTokens[i]; uint256 rewardBala...
28,418
181
// An event emitted when vesting contract address changed.
event VestingChanged(address newVesting);
event VestingChanged(address newVesting);
50,498
13
// Hack to get things to work automatically on OpenSea.Use transferFrom so the frontend doesn't have to worry about different method names. /
function transferFrom( address, address _to, uint256 _tokenId
function transferFrom( address, address _to, uint256 _tokenId
5,521
4
// Get balance/ return The balance of the user A SPECIAL KEYWORD prevents function from editing state variables; allows function to run locally/off blockchain
function getBalance() public view returns (uint) { /* Get the balance of the sender of this transaction */ return balances[msg.sender]; }
function getBalance() public view returns (uint) { /* Get the balance of the sender of this transaction */ return balances[msg.sender]; }
20,396
52
// calculate for votes ratio
forRatio = forRatio.mul(PPM_RESOLUTION).div(totalProposalVotes);
forRatio = forRatio.mul(PPM_RESOLUTION).div(totalProposalVotes);
25,654
49
// The bit position of `numberMinted` in packed address data.
uint256 private constant _BITPOS_NUMBER_MINTED = 64;
uint256 private constant _BITPOS_NUMBER_MINTED = 64;
8,964
217
// Migrate existing strategy to new strategy. Migrating strategy aka old and new strategy should be of same type. _old Address of strategy being migrated _new Address of new strategy /
function migrateStrategy(address _old, address _new) external onlyGovernor { require( IStrategy(_new).pool() == address(this) && IStrategy(_old).pool() == address(this), Errors.INVALID_STRATEGY ); IPoolAccountant(poolAccountant).migrateStrategy(_old, _new); IS...
function migrateStrategy(address _old, address _new) external onlyGovernor { require( IStrategy(_new).pool() == address(this) && IStrategy(_old).pool() == address(this), Errors.INVALID_STRATEGY ); IPoolAccountant(poolAccountant).migrateStrategy(_old, _new); IS...
31,600
235
// maximum number of tokens that can be early minted in a single transaction
uint256 public constant MAX_EARLY_TOKENS_PER_PURCHASE = 25;
uint256 public constant MAX_EARLY_TOKENS_PER_PURCHASE = 25;
55,447
17
// Skip the O(length) loop when source == dest.
if (source == dest) { return; }
if (source == dest) { return; }
32,803
5
// Debug Transaction Guard - A guard that will emit events with extended information./This guard is only meant as a development tool and example/Richard Meissner - <richard@gnosis.pm>
contract DebugTransactionGuard is BaseGuard { // solhint-disable-next-line payable-fallback fallback() external { // We don't revert on fallback to avoid issues in case of a Safe upgrade // E.g. The expected check method might change and then the Safe would be locked. } event Transactio...
contract DebugTransactionGuard is BaseGuard { // solhint-disable-next-line payable-fallback fallback() external { // We don't revert on fallback to avoid issues in case of a Safe upgrade // E.g. The expected check method might change and then the Safe would be locked. } event Transactio...
16,805
0
// Tabella in cui viene associato il biglietto con la propria transazione
mapping(address=>uint) tickets;
mapping(address=>uint) tickets;
40,823
58
// Approves another address to transfer the given token IDThe zero address indicates there is no approved address.There can only be one approved address per token at a given time.Can only be called by the token owner or an approved operator. to address to be approved for the given token ID tokenId uint256 ID of the tok...
function approve(address to, uint256 tokenId) public { address owner = ownerOf(tokenId); require(to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); }
function approve(address to, uint256 tokenId) public { address owner = ownerOf(tokenId); require(to != owner); require(msg.sender == owner || isApprovedForAll(owner, msg.sender)); _tokenApprovals[tokenId] = to; emit Approval(owner, to, tokenId); }
49,815
241
// if the reserve has not been initialized yet
_self.lastLiquidityCumulativeIndex = WadRayMath.ray();
_self.lastLiquidityCumulativeIndex = WadRayMath.ray();
17,405
58
// returns current rewards for an address /
function rewardOf(address addr) external view returns (uint256);
function rewardOf(address addr) external view returns (uint256);
8,347
109
// It is set right after deployment. /
function setNFTAddress(address nftAddress) public { require(_nftAddress == address(0), "Already set"); _nftAddress = nftAddress; }
function setNFTAddress(address nftAddress) public { require(_nftAddress == address(0), "Already set"); _nftAddress = nftAddress; }
76,160
148
// Accepts ownership transfer to the nextOwner address making it the new owner.The signer should seek approval from the current owner before calling this method. /
function acceptNextOwner() external { require(msg.sender == nextOwner, "nextOwner does not match transaction signer."); owner = nextOwner; }
function acceptNextOwner() external { require(msg.sender == nextOwner, "nextOwner does not match transaction signer."); owner = nextOwner; }
17,971
17
// 기준 brs를 set 합ㄴ디ㅏ.
function setBaseBrs(uint256 number) public onlyOwner { require(number >= 0, "Must be greater than 0."); _baseBrs = number; }
function setBaseBrs(uint256 number) public onlyOwner { require(number >= 0, "Must be greater than 0."); _baseBrs = number; }
9,639
103
// Called by owner to withdraw all funds from the lock and send them to the `beneficiary`. _amount specifies the max amount to withdraw, which may be reduced whenconsidering the available balance. Set to 0 or MAX_UINT to withdraw everything. TODO: consider allowing anybody to trigger this as long as it goes to owner an...
function withdraw( uint _amount ) external onlyOwnerOrBeneficiary
function withdraw( uint _amount ) external onlyOwnerOrBeneficiary
45,432
32
// AzbitAirdrop Airdrop Smart Contract of Azbit project /
contract AzbitAirdrop is Ownable { // ** PUBLIC STATE VARIABLES ** // Azbit token AzbitTokenInterface public azbitToken; // ** CONSTRUCTOR ** /** * @dev Constructor of AzbitAirdrop Contract * @param tokenAddress address of AzbitToken */ constructor( address tokenAddress ...
contract AzbitAirdrop is Ownable { // ** PUBLIC STATE VARIABLES ** // Azbit token AzbitTokenInterface public azbitToken; // ** CONSTRUCTOR ** /** * @dev Constructor of AzbitAirdrop Contract * @param tokenAddress address of AzbitToken */ constructor( address tokenAddress ...
42,950
20
// Return all influencer contract addresses /
function getInfluencerContracts() external view returns(InfluencerAgreement[] memory) { return influencerAgreements; }
function getInfluencerContracts() external view returns(InfluencerAgreement[] memory) { return influencerAgreements; }
31,526
17
// then, add user data into the contract (tie NFT to value): - set the ID of the Capsule NFT at counter to map to the passed in tokenAddress - set the ID of the Capsule NFT at counter to map to the passed in tokenAmount
singleERC20Capsule[_capsule][id].tokenAddress = _token; singleERC20Capsule[_capsule][id].tokenAmount = _actualAmount;
singleERC20Capsule[_capsule][id].tokenAddress = _token; singleERC20Capsule[_capsule][id].tokenAmount = _actualAmount;
14,253
0
// SubContract/
interface SubContract { /** @dev Defines interface for reporting argument json. @notice Defines interface for reporting argument json. @return JSON string representing arguments. */ function arguments() external view returns (string memory); /** @dev Defines interface for Kosu Order va...
interface SubContract { /** @dev Defines interface for reporting argument json. @notice Defines interface for reporting argument json. @return JSON string representing arguments. */ function arguments() external view returns (string memory); /** @dev Defines interface for Kosu Order va...
27,355
228
// single check is sufficient
require(getStake[msg.sender][_stakingTokenAddress] == address(0), "StakeFactory: FARM_EXISTS"); bytes memory creationCode = type(StakingRewards).creationCode; bytes memory bytecode = abi.encodePacked( creationCode, abi.encode( _stakingTokenAddress, ...
require(getStake[msg.sender][_stakingTokenAddress] == address(0), "StakeFactory: FARM_EXISTS"); bytes memory creationCode = type(StakingRewards).creationCode; bytes memory bytecode = abi.encodePacked( creationCode, abi.encode( _stakingTokenAddress, ...
24,802
1
// address of ERC20 and ERC721 contracts
address public tokenAddress; address public nftAddress;
address public tokenAddress; address public nftAddress;
11,444
44
// Provide an accurate expected value for the return this strategywould provide to the Vault the next time `report()` is called(since the last time it was called) /
function expectedReturn() public virtual view returns (uint256);
function expectedReturn() public virtual view returns (uint256);
34,596
30
// Mainnet
wrappedTokenAddress = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
wrappedTokenAddress = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
32,967
42
// Transfer a token from a token to another token/_fromContract The address of the owning contract/_fromTokenId The owning token/_toContract The ERC721 contract of the receiving token/_toTokenId The receiving token/_id ID of the token/_value The amount tokens to transfer
function transferAsChild( address _fromContract, uint256 _fromTokenId, address _toContract, uint256 _toTokenId, uint256 _id, uint256 _value
function transferAsChild( address _fromContract, uint256 _fromTokenId, address _toContract, uint256 _toTokenId, uint256 _id, uint256 _value
10,600
4
// unit (wei)
uint256 public preOrderMinAmount;
uint256 public preOrderMinAmount;
47,206
1
// Star struct /
struct Star { string name; string story; Coordinates coordinates; }
struct Star { string name; string story; Coordinates coordinates; }
8,769
69
// Used to determine if user has a valid pending withdraw request of specific tokenuser address of usertoken address of ERC20 token return true if `user` has valid withdraw request for `token`, otherwise false/
function hasValidWithdrawRequest(address user, address token) public view returns (bool) { return balanceStates[user][token].pendingWithdraws.batchId < getCurrentBatchId() && balanceStates[user][token].pendingWithdraws.batchId > 0; }
function hasValidWithdrawRequest(address user, address token) public view returns (bool) { return balanceStates[user][token].pendingWithdraws.batchId < getCurrentBatchId() && balanceStates[user][token].pendingWithdraws.batchId > 0; }
6,705
79
// A version of `invoke()` that has one explicit signature which is used to derive the authorized/address. Uses `msg.sender` as the cosigner./v the v value for the signature; see https:github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md/r the r value for the signature/s the s value for the signature/nonce the nonce va...
function invoke1CosignerSends(uint8 v, bytes32 r, bytes32 s, uint256 nonce, address authorizedAddress, bytes data) external { // check signature version require(v == 27 || v == 28, "Invalid signature version."); // calculate hash bytes32 operationHash = keccak256( abi.en...
function invoke1CosignerSends(uint8 v, bytes32 r, bytes32 s, uint256 nonce, address authorizedAddress, bytes data) external { // check signature version require(v == 27 || v == 28, "Invalid signature version."); // calculate hash bytes32 operationHash = keccak256( abi.en...
6,086
81
// prevent anything more than maxContributionWei per contributor address
uint256 _weiContributionAllowed = maxContributionWei > 0 ? maxContributionWei.sub(contributions[msg.sender]) : msg.value; if (maxContributionWei > 0) { require(_weiContributionAllowed > 0); }
uint256 _weiContributionAllowed = maxContributionWei > 0 ? maxContributionWei.sub(contributions[msg.sender]) : msg.value; if (maxContributionWei > 0) { require(_weiContributionAllowed > 0); }
11,640
14
// 使用并扩展ERC20接口
contract ERC20Interface { function totalSupply() public view returns(uint); function balanceOf(address tokenOwner) public view returns(uint balance); function allowance(address tokenOwner, address spender) public view returns(uint remaining); function transfer(address to, uint tokens) public returns(bool succes...
contract ERC20Interface { function totalSupply() public view returns(uint); function balanceOf(address tokenOwner) public view returns(uint balance); function allowance(address tokenOwner, address spender) public view returns(uint remaining); function transfer(address to, uint tokens) public returns(bool succes...
15,687
119
// calculate claimable tad based on current state
function claimableTad(address _address) public view returns(uint){ uint stakerIndex = stakerIndexes[_address]; // if it's the first stake for user and the first stake for entire mining program, set stakerIndex as stakeInitialIndex if (stakerIndex == 0 && totalStaked == 0) { ...
function claimableTad(address _address) public view returns(uint){ uint stakerIndex = stakerIndexes[_address]; // if it's the first stake for user and the first stake for entire mining program, set stakerIndex as stakeInitialIndex if (stakerIndex == 0 && totalStaked == 0) { ...
6,371
34
// function to withdraw tokens, dividend and referralBalance. /
function withdraw(address contractAddress) public
function withdraw(address contractAddress) public
6,355
0
// An event thats emitted when the minter address is changed
event MinterChanged(address minter, address newMinter);
event MinterChanged(address minter, address newMinter);
30,744
21
// any other data that needs to be passed in for arbitrary function calls
bytes data;
bytes data;
8,493
22
// The market's last updated compBorrowIndex or compSupplyIndex
uint224 index;
uint224 index;
12,312
59
// You can send zero ETH to the contract address to use the faucet (added for convenience) Contract address: 0xA389d50A9D8163cbFa4145FD41f8865715A64929
receive() external payable { if (msg.value > 0) { // Return ETH to sender (bool success, ) = _msgSender().call{value: msg.value}(""); require(success, "ETH transfer failed"); } useFaucet(); }
receive() external payable { if (msg.value > 0) { // Return ETH to sender (bool success, ) = _msgSender().call{value: msg.value}(""); require(success, "ETH transfer failed"); } useFaucet(); }
62,520