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
14
// See {IERC20-transferFrom}. Emits an {Approval} event indicating the updated allowance. This is notrequired by the EIP. See the note at the beginning of {ERC20}. /
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
29,859
8
// mostly helps with function identification if disassembled
logCall(numcalls, numcallsinternal);
logCall(numcalls, numcallsinternal);
41,146
20
// The maximum tick that may be passed to getSqrtRatioAtTick computed from log base 1.0001 of 2128
int24 internal constant MAX_TICK = -MIN_TICK;
int24 internal constant MAX_TICK = -MIN_TICK;
4,351
5
// Event to emit upon purchase
event mint(uint256 id, address mintFrom, address mintTo); constructor( string memory name, string memory symbol, uint256 price, address payable _indecent, address payable _tdb, address payable _bf )
event mint(uint256 id, address mintFrom, address mintTo); constructor( string memory name, string memory symbol, uint256 price, address payable _indecent, address payable _tdb, address payable _bf )
25,811
164
// payout for claiming
function payouts(address payable _to, uint256 _amount, address token) external onlyOperator { require(_to != address(0),"_to is zero"); if (token != ETHEREUM) { IERC20(token).safeTransfer(_to, _amount); } else { _to.transfer(_amount); } emit ePayouts...
function payouts(address payable _to, uint256 _amount, address token) external onlyOperator { require(_to != address(0),"_to is zero"); if (token != ETHEREUM) { IERC20(token).safeTransfer(_to, _amount); } else { _to.transfer(_amount); } emit ePayouts...
77,478
50
// TODO: What should we do with this? Should it be allowed? Should it be a canary?
function echidna_price() public view returns(bool) { uint price = priceFeedTestnet.getPrice(); if (price == 0) { return false; } // Uncomment to check that the condition is meaningful //else return false; return true; }
function echidna_price() public view returns(bool) { uint price = priceFeedTestnet.getPrice(); if (price == 0) { return false; } // Uncomment to check that the condition is meaningful //else return false; return true; }
18,693
5
// transfer the tokens to this contract
bool success = SOV.transferFrom(_sender, address(this), _amount); require(success);
bool success = SOV.transferFrom(_sender, address(this), _amount); require(success);
51,379
6
// What percentage does the smart conract take as a processing fee
uint constant internal HOUSE_EDGE_PERCENT = 1;
uint constant internal HOUSE_EDGE_PERCENT = 1;
17,835
34
// Linearly interpolate between last updated price (with corresponding timestamp) and current price (with current timestamp) to imply price at the timestamp we are updating
return _currentPrice.mul(_updateInterval) .add(_previousLoggedDataPoint.mul(_timeFromExpectedUpdate)) .div(timeFromLastUpdate);
return _currentPrice.mul(_updateInterval) .add(_previousLoggedDataPoint.mul(_timeFromExpectedUpdate)) .div(timeFromLastUpdate);
13,937
157
// Safety function to be able to recover tokens if they are sent to this contract by mistake /
function withdrawTokensTo(address erc20Address, address recipient) external onlyOwner { uint256 tokenBalance = IERC20(erc20Address).balanceOf(address(this)); require(tokenBalance > 0, "No tokens"); IERC20(erc20Address).safeTransfer(recipient, tokenBalance); }
function withdrawTokensTo(address erc20Address, address recipient) external onlyOwner { uint256 tokenBalance = IERC20(erc20Address).balanceOf(address(this)); require(tokenBalance > 0, "No tokens"); IERC20(erc20Address).safeTransfer(recipient, tokenBalance); }
2,377
44
// ========== FARM CALLBACKS ========== // onDeposit() is used to control fees and accessibility instead having animplementation in each farm contract Deposit is only allowed, if farm is open and not not paused._amount tokens the user wants to deposit return fee returns the deposit fee (1e18 factor) /
function onDeposit(uint256 _amount) external view override returns (uint256 fee)
function onDeposit(uint256 _amount) external view override returns (uint256 fee)
59,926
13
// function to check if the crowdsale has ended/self Stored crowdsale from crowdsale contract/ return success
function crowdsaleEnded(CrowdsaleStorage storage self) public view returns (bool) { return now > self.endTime; }
function crowdsaleEnded(CrowdsaleStorage storage self) public view returns (bool) { return now > self.endTime; }
49,635
40
// Take tokens out from circulation
totalSupply = totalSupply.sub(value); totalUpgraded = totalUpgraded.add(value);
totalSupply = totalSupply.sub(value); totalUpgraded = totalUpgraded.add(value);
32,746
68
// Execute hold and keep open. /
function executeHoldAndKeepOpen(address token, bytes32 holdId, uint256 value, bytes32 secret) external returns (bool) { return _executeHold( token, holdId, msg.sender, value, secret, true ); }
function executeHoldAndKeepOpen(address token, bytes32 holdId, uint256 value, bytes32 secret) external returns (bool) { return _executeHold( token, holdId, msg.sender, value, secret, true ); }
7,120
36
// Extended to 36 months
endTime = endTimeExtended; extended = true; MiningExtended(endTime, swapTime, swapEndTime);
endTime = endTimeExtended; extended = true; MiningExtended(endTime, swapTime, swapEndTime);
24,098
152
// returns (uint nodeIndex)
{
{
57,235
278
// Determine whether a sender delegate is authorizedauthorizer address Address doing the authorizationdelegate address Address being authorized return bool True if a delegate is authorized to send/
function isSenderAuthorized( address authorizer, address delegate
function isSenderAuthorized( address authorizer, address delegate
26,362
7
// Sends a token to the specified addr, works with Eth also/If amount is type(uint).max it will send proxy balance/If weth address is set it will unwrap by default/_tokenAddr Address of token, use 0xEeee... for eth/_to Where the tokens are sent/_amount Amount of tokens, can be type(uint).max
function _sendToken(address _tokenAddr, address _to, uint _amount) internal returns (uint) { if (_amount == type(uint256).max) { _amount = _tokenAddr.getBalance(address(this)); } // unwrap and send eth if (_tokenAddr == TokenUtils.WETH_ADDR) { TokenUtils.with...
function _sendToken(address _tokenAddr, address _to, uint _amount) internal returns (uint) { if (_amount == type(uint256).max) { _amount = _tokenAddr.getBalance(address(this)); } // unwrap and send eth if (_tokenAddr == TokenUtils.WETH_ADDR) { TokenUtils.with...
53,756
3
// 00b3e97c6c661eabfda5dc35ede44a934c3aa990a005d4a73cdcaf8652686661ffb247222a65bcd8bab5b5bf94aeec02246c6fae4accc5913846ae95deba8206c33e06ba914f7b0be0171aeefe0d1397b2d8d43afe9596b1d95409cb9883a4c9ca566b18ccf847d03d9b83c446e4c3de81dff7c6ebd65ba77b3dcba58487053963d222425f184e41a7354c627506ce375046426f87544b204dfdb627aafa1...
if (msg.sender != owner) throw; CAmodulus = _CAmodulus;
if (msg.sender != owner) throw; CAmodulus = _CAmodulus;
10,557
3
// The total number of tokens minted by address.
mapping(address => uint256) _totalMintedByUser;
mapping(address => uint256) _totalMintedByUser;
37,358
112
// AlpacaVaultAdapterWithIndirection//A vault adapter implementation which wraps a vesper vault.
contract VesperLinkVaultAdapterWithIndirection is VesperLinkVaultAdapter { using SafeERC20 for IDetailedERC20; using SafeMath for uint256; constructor(IVesperPool _vault, IPoolRewards _vspPool, address _admin, IUniswapV2Router02 _uniV2Router, IDetailedERC20 _vesperToken) VesperLinkVau...
contract VesperLinkVaultAdapterWithIndirection is VesperLinkVaultAdapter { using SafeERC20 for IDetailedERC20; using SafeMath for uint256; constructor(IVesperPool _vault, IPoolRewards _vspPool, address _admin, IUniswapV2Router02 _uniV2Router, IDetailedERC20 _vesperToken) VesperLinkVau...
3,701
2
// event sent when the random number is generated by the VRF
event RandomNumberCreated( uint256 indexed idFromMetawin, uint256 randomNumber, uint256 normalizedRandomNumber );
event RandomNumberCreated( uint256 indexed idFromMetawin, uint256 randomNumber, uint256 normalizedRandomNumber );
31,820
2
// Hashed rotation key data /
bytes internal _hashedRotationKeyData;
bytes internal _hashedRotationKeyData;
45,095
115
// Overrides adding new minters so that only governance can authorized them./
function addMinter(address _minter) public onlyGovernance { super.addMinter(_minter); }
function addMinter(address _minter) public onlyGovernance { super.addMinter(_minter); }
11,140
179
// Get token Ids of all tokens owned by _owner
function walletOfOwner(address _owner) external view returns (uint256[] memory)
function walletOfOwner(address _owner) external view returns (uint256[] memory)
6,380
10
// Assign winner
uint index = randomness % riders.length; lastWinner = riders[index];
uint index = randomness % riders.length; lastWinner = riders[index];
51,962
4
// Keep track of used signatures to prevent reuse before expiration.
mapping(address => mapping(bytes32 => bool)) private _sigUsage;
mapping(address => mapping(bytes32 => bool)) private _sigUsage;
17,573
6
// Allow an address to purchase multiple challenges/ Buying an challenge typically mints it, it will throw if an challenge has reached its maximum quantity/ _to Address to send the challenges once purchased/ _challengeIds The identifiers of the challenges to be purchased/ _quantities The quantities of each challenge to...
function purchaseChallengesWithPrtcle( address _to, uint256[] calldata _challengeIds, uint256[] calldata _quantities
function purchaseChallengesWithPrtcle( address _to, uint256[] calldata _challengeIds, uint256[] calldata _quantities
12,951
77
// NOT synchronized!!! /
{ var fn = matchingEnabled ? _offeru : super.offer; return fn(pay_amt, pay_gem, buy_amt, buy_gem); }
{ var fn = matchingEnabled ? _offeru : super.offer; return fn(pay_amt, pay_gem, buy_amt, buy_gem); }
39,527
3
// StabilityBoard
rates.grantPermission(stabilityBoardProxyAddress, "StabilityBoard"); feeAccount.grantPermission(stabilityBoardProxyAddress, "StabilityBoard"); interestEarnedAccount.grantPermission(stabilityBoardProxyAddress, "StabilityBoard"); tokenAEur.grantPermission(stabilityBoardProxyAddress, "Stabi...
rates.grantPermission(stabilityBoardProxyAddress, "StabilityBoard"); feeAccount.grantPermission(stabilityBoardProxyAddress, "StabilityBoard"); interestEarnedAccount.grantPermission(stabilityBoardProxyAddress, "StabilityBoard"); tokenAEur.grantPermission(stabilityBoardProxyAddress, "Stabi...
14,474
33
// https:github.com/ethereum-optimism/optimism/blob/eaa371a0184b56b7ca6d9eb9cb0a2b78b2ccd864/op-bindings/predeploys/addresses.goL6-L21
vm.assume(addr < address(0x4200000000000000000000000000000000000000) || addr > address(0x4200000000000000000000000000000000000800));
vm.assume(addr < address(0x4200000000000000000000000000000000000000) || addr > address(0x4200000000000000000000000000000000000800));
30,409
167
// For collecting minted Hedron data
struct Archive { string hedronType; uint256 tokenId; }
struct Archive { string hedronType; uint256 tokenId; }
64,550
118
// private function to allocate DYP to be disbursed calculated according to time passed
function disburseTokens() private { uint amount = getPendingDisbursement(); if (contractBalance < amount) { amount = contractBalance; } if (amount == 0 || totalTokens == 0) return; tokensToBeSwapped = tokensToBeSwapped.add(amount); contractBalan...
function disburseTokens() private { uint amount = getPendingDisbursement(); if (contractBalance < amount) { amount = contractBalance; } if (amount == 0 || totalTokens == 0) return; tokensToBeSwapped = tokensToBeSwapped.add(amount); contractBalan...
9,119
20
// Record the supply cap of each item being created in the group.
uint256 fullCollectionSize = 0; for (uint256 i = 0; i < groupSize; i++) { uint256 itemInitialSupply = initialSupply[i]; uint256 itemMaximumSupply = _maximumSupply[i]; fullCollectionSize = fullCollectionSize.add(itemMaximumSupply); require(itemMaximumSupply > 0, "You cannot create...
uint256 fullCollectionSize = 0; for (uint256 i = 0; i < groupSize; i++) { uint256 itemInitialSupply = initialSupply[i]; uint256 itemMaximumSupply = _maximumSupply[i]; fullCollectionSize = fullCollectionSize.add(itemMaximumSupply); require(itemMaximumSupply > 0, "You cannot create...
40,387
178
// Private function to remove a token from this extension"s token tracking data structures.This has O(1) time complexity, but alters the order of the _allTokens array. tokenId uint256 ID of the token to be removed from the tokens list /
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tok...
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tok...
18,767
231
// Remove the token from the owner list
for (uint i = 0; i < ownerToToken[from].length; i++) { if (ownerToToken[from][i] == tokenId) { ownerToToken[from][i] = ownerToToken[from][ownerToToken[from].length - 1]; ownerToToken[from].pop(); ownerToToken[to].push(tokenId);
for (uint i = 0; i < ownerToToken[from].length; i++) { if (ownerToToken[from][i] == tokenId) { ownerToToken[from][i] = ownerToToken[from][ownerToToken[from].length - 1]; ownerToToken[from].pop(); ownerToToken[to].push(tokenId);
49,458
40
// /
return (
return (
21,368
22
// Allows users to borrow a specific `amount` of the reserve underlying asset, provided that the borroweralready supplied enough collateral, or he was given enough allowance by a credit delegator on thecorresponding debt token (StableDebtToken or VariableDebtToken)- E.g. User borrows 100 USDC passing as `onBehalfOf` hi...
function borrow(
function borrow(
18,731
0
// ========== CONSTANT VARIABLES ========== // ========== STATE VARIABLES ========== // ========== EVENTS ========== // ========== MODIFIERS ========== /
modifier accrue { IStrategyVBNB(strategyVBNB).updateBalance(); if (now > lastAccrueTime) { uint interest = pendingInterest(); glbDebtVal = glbDebtVal.add(interest); reservedBNB = reservedBNB.add(interest.mul(config.getReservePoolBps()).div(10000)); las...
modifier accrue { IStrategyVBNB(strategyVBNB).updateBalance(); if (now > lastAccrueTime) { uint interest = pendingInterest(); glbDebtVal = glbDebtVal.add(interest); reservedBNB = reservedBNB.add(interest.mul(config.getReservePoolBps()).div(10000)); las...
37,360
228
// abusing underflow here =_=
for (uint8 i = 15; i < 255 ; i -= 1) { uint8 _byte = uint8(_b >> (i * 8)); second |= byteHex(_byte); if (i != 0) { second <<= 16; }
for (uint8 i = 15; i < 255 ; i -= 1) { uint8 _byte = uint8(_b >> (i * 8)); second |= byteHex(_byte); if (i != 0) { second <<= 16; }
50,736
20
// Emitted when new token is breed from same owners. /
event breedSelf( address indexed selfAddress, // msg.sender address uint256 motherTokenId, uint256 donorTokenId, string tokenURI, // child seed uri uint256 newTokenId, // new minted child id uint256 sktFeePrice // fee to skt wallet );
event breedSelf( address indexed selfAddress, // msg.sender address uint256 motherTokenId, uint256 donorTokenId, string tokenURI, // child seed uri uint256 newTokenId, // new minted child id uint256 sktFeePrice // fee to skt wallet );
24,995
8
// create a new functionSelectors array for selector
facets_[numFacets].facetAddress = facetAddress_; facets_[numFacets].functionSelectors = new bytes4[](selectorCount); facets_[numFacets].functionSelectors[0] = selector; numFacetSelectors[numFacets] = 1; numFacets++;
facets_[numFacets].facetAddress = facetAddress_; facets_[numFacets].functionSelectors = new bytes4[](selectorCount); facets_[numFacets].functionSelectors[0] = selector; numFacetSelectors[numFacets] = 1; numFacets++;
5,837
196
// This will pay DAO 10% of the initial sale. =============================================================================
if(daoShare > 0){ (bool dao, ) = payable(daoAccount).call{value: (address(this).balance * daoShare) / 100}("");
if(daoShare > 0){ (bool dao, ) = payable(daoAccount).call{value: (address(this).balance * daoShare) / 100}("");
11,836
92
// Privileged function to de authorize an address/who The address to remove authorization from
function deauthorize(address who) external onlyOwner { authorized[who] = false; }
function deauthorize(address who) external onlyOwner { authorized[who] = false; }
53,654
19
// All new recipients must have shares
require(shares > 0); outletShares.push(shares); uint256 outlet = outletShares.length-1; outletRecipient[outlet] = newRecipient; outletLookup[newRecipient] = outlet; outletController[outlet][owner()] = true;
require(shares > 0); outletShares.push(shares); uint256 outlet = outletShares.length-1; outletRecipient[outlet] = newRecipient; outletLookup[newRecipient] = outlet; outletController[outlet][owner()] = true;
39,008
3
// compose a set of the same child ERC721s into a KODA tokens/Caller must own both KODA and child NFT tokens
function composeNFTsIntoKodaTokens(uint256[] calldata _kodaTokenIds, address _nft, uint256[] calldata _nftTokenIds) external { uint256 totalKodaTokens = _kodaTokenIds.length; require(totalKodaTokens > 0 && totalKodaTokens == _nftTokenIds.length, "Invalid list"); IERC721 nftContract = IERC72...
function composeNFTsIntoKodaTokens(uint256[] calldata _kodaTokenIds, address _nft, uint256[] calldata _nftTokenIds) external { uint256 totalKodaTokens = _kodaTokenIds.length; require(totalKodaTokens > 0 && totalKodaTokens == _nftTokenIds.length, "Invalid list"); IERC721 nftContract = IERC72...
45,416
21
// Approve and then communicate the approved contract in a single tx // Сall the receiveApproval function on the contract you want to be notified. // This crafts the function signature manually so one doesn't have to include a contract in here just for this. // receiveApproval(address _from, uint256 _value, address _to...
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } }
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool) { tokenRecipient spender = tokenRecipient(_spender); if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } }
18,338
225
// Unpauses token transfers /
function unpause() external onlyOwners { _unpause(); }
function unpause() external onlyOwners { _unpause(); }
15,680
0
// Fired when the throne is taken by someone /
event ThroneTaken(address prevOwner, address newOwner, uint32 prevOwnerTimeSpent, uint32 round, uint256 timestamp); event WinnerChosen(address winner, uint256 prize, uint32 totalTimeSpent, uint32 round, uint32 totalPlayers, uint256 timestamp); event TimeBoosterUsed(address user, uint8 bonusUsed, uint32 roun...
event ThroneTaken(address prevOwner, address newOwner, uint32 prevOwnerTimeSpent, uint32 round, uint256 timestamp); event WinnerChosen(address winner, uint256 prize, uint32 totalTimeSpent, uint32 round, uint32 totalPlayers, uint256 timestamp); event TimeBoosterUsed(address user, uint8 bonusUsed, uint32 roun...
29,724
302
// Performs a deep copy of a byte array onto another byte array of greater than or equal length./dest Byte array that will be overwritten with source bytes./source Byte array to copy onto dest bytes.
function deepCopyBytes( bytes memory dest, bytes memory source ) internal pure { uint256 sourceLen = source.length;
function deepCopyBytes( bytes memory dest, bytes memory source ) internal pure { uint256 sourceLen = source.length;
8,824
35
// make the swap
arcadiumSwapRouter.swapExactTokensForTokensSupportingFeeOnTransferTokens( totalTokenBalance, 0, // accept any amount of tokens path, address(this), block.timestamp )
arcadiumSwapRouter.swapExactTokensForTokensSupportingFeeOnTransferTokens( totalTokenBalance, 0, // accept any amount of tokens path, address(this), block.timestamp )
33,735
33
// XUSD AlphaHomora Strategy Investment strategy for investing stablecoins via AlphaHomora/CREAM XUSD.fi Inc /
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { IERC20, InitializableAbstractStrategy } from "../utils/InitializableAbstractStrategy.sol"; import { IVault } from "../interfaces/IVault.sol"; import { ICERC20 } from "../interfaces/alphaHomora/ICERC20.sol"; import { ISafeBox ...
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; import { IERC20, InitializableAbstractStrategy } from "../utils/InitializableAbstractStrategy.sol"; import { IVault } from "../interfaces/IVault.sol"; import { ICERC20 } from "../interfaces/alphaHomora/ICERC20.sol"; import { ISafeBox ...
44,411
200
// if there is nothing to swap, return
if(amount == 0) return 0;
if(amount == 0) return 0;
5,690
5
// console.log("%s %s", _currency, NATIVE_TOKEN);console.log("%s %s", _amount, msg.value);
if (_currency == NATIVE_TOKEN) { if (_from == address(this)) {
if (_currency == NATIVE_TOKEN) { if (_from == address(this)) {
17,631
30
// Call parents constructor with current constructors argument
contract C6_1_ParentConstructor{ uint256 public parentVal; constructor(uint256 _parentValue){ parentVal = _parentValue; } }
contract C6_1_ParentConstructor{ uint256 public parentVal; constructor(uint256 _parentValue){ parentVal = _parentValue; } }
3,019
248
// Similar to EIP20 transfer, except it handles a False result from `transferFrom` and returns an explanatory error code rather than reverting.If caller has not called `checkTransferIn`, this may revert due to insufficient balance or insufficient allowance. If caller has called `checkTransferIn` prior to this call, and...
function doTransferIn(address from, uint amount) internal returns (Error) { EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying); bool result; token.transferFrom(from, address(this), amount); // solium-disable-next-line security/no-inline-assembly assembl...
function doTransferIn(address from, uint amount) internal returns (Error) { EIP20NonStandardInterface token = EIP20NonStandardInterface(underlying); bool result; token.transferFrom(from, address(this), amount); // solium-disable-next-line security/no-inline-assembly assembl...
23,872
169
// Check pay token
require(payTokens[_payTokenName] != ADDRESS_NULL, "not support this address pay token"); Order memory order = orderByOrderId[_nftAddress][_orderId];
require(payTokens[_payTokenName] != ADDRESS_NULL, "not support this address pay token"); Order memory order = orderByOrderId[_nftAddress][_orderId];
21,833
285
// return discounted price of blind aworld nft
function _getBundleCryptidPrice(uint256 mintNumber) internal view returns (uint256) { uint256 bundlePrice = mintNumber * awCryptidPrice; if (mintNumber == 3) { return threeBundleCryptidPrice; } else if (mintNumber == 10) { return tenBundleCryptidPrice; } else ...
function _getBundleCryptidPrice(uint256 mintNumber) internal view returns (uint256) { uint256 bundlePrice = mintNumber * awCryptidPrice; if (mintNumber == 3) { return threeBundleCryptidPrice; } else if (mintNumber == 10) { return tenBundleCryptidPrice; } else ...
37,958
390
// with greatness > 19 add nickname prefix
if (greatness >= 19) { if (greatness == 19) { output = string(abi.encodePacked('"', nicknames[deterministic % (nicknames.length)], '" ', output)); } else {
if (greatness >= 19) { if (greatness == 19) { output = string(abi.encodePacked('"', nicknames[deterministic % (nicknames.length)], '" ', output)); } else {
36,984
157
// mint token
_mint(collector_address, tokenId); _setTokenURI(tokenId, tokenURI); _setTokenIPFSHash(tokenId, ipfsHash);
_mint(collector_address, tokenId); _setTokenURI(tokenId, tokenURI); _setTokenIPFSHash(tokenId, ipfsHash);
50,171
35
// Ensure a single SLOAD while avoiding solc's excessive bitmasking bureaucracy.
uint256 hop_; {
uint256 hop_; {
32,768
96
// checks if the Maker credit line increase could violate the pool constraints-> make function pure and call with current pool values approxNav
function validate(uint juniorSupplyDAI, uint juniorRedeemDAI, uint seniorSupplyDAI, uint seniorRedeemDAI) public view returns(int) { uint newAssets = safeSub(safeSub(safeAdd(safeAdd(safeAdd(assessor.totalBalance(), assessor.getNAV()), seniorSupplyDAI), juniorSupplyDAI), juniorRedeemDAI), seniorR...
function validate(uint juniorSupplyDAI, uint juniorRedeemDAI, uint seniorSupplyDAI, uint seniorRedeemDAI) public view returns(int) { uint newAssets = safeSub(safeSub(safeAdd(safeAdd(safeAdd(assessor.totalBalance(), assessor.getNAV()), seniorSupplyDAI), juniorSupplyDAI), juniorRedeemDAI), seniorR...
22,319
1
// 这里把 Your ticker 改成你想要的代笔简写,如BTC,LTC, DOGE 如 string public token_ticker = "BTC";
string public token_ticker = "GLO";
string public token_ticker = "GLO";
175
9
// Constructor initializes the isOwner mapping. /
function MultiSigWallet() public { isAuthorised[0xF748D2322ADfE0E9f9b262Df6A2aD6CBF79A541A] = true; //account 1 isAuthorised[0x4BbBbDd42c7aab36BeA6A70a0cB35d6C20Be474E] = true; //account 2 isAuthorised[0x2E661Be8C26925DDAFc25EEe3971efb8754E6D90] = true; //account 3 isAuthorised[0x1...
function MultiSigWallet() public { isAuthorised[0xF748D2322ADfE0E9f9b262Df6A2aD6CBF79A541A] = true; //account 1 isAuthorised[0x4BbBbDd42c7aab36BeA6A70a0cB35d6C20Be474E] = true; //account 2 isAuthorised[0x2E661Be8C26925DDAFc25EEe3971efb8754E6D90] = true; //account 3 isAuthorised[0x1...
29,139
20
// Set paramaters for the reward distribution _rewardPerBlock The reward token amount per a block _decrementUnitPerBlock The decerement amount of the reward token per a block /
function _setParams(uint256 _rewardPerBlock, uint256 _decrementUnitPerBlock) internal { emit SetRewardParams(_rewardPerBlock, _decrementUnitPerBlock); rewardPerBlock = _rewardPerBlock; decrementUnitPerBlock = _decrementUnitPerBlock; }
function _setParams(uint256 _rewardPerBlock, uint256 _decrementUnitPerBlock) internal { emit SetRewardParams(_rewardPerBlock, _decrementUnitPerBlock); rewardPerBlock = _rewardPerBlock; decrementUnitPerBlock = _decrementUnitPerBlock; }
11,197
107
// Returns array of modules./start Start of the page./pageSize Maximum number of modules that should be returned./ return Array of modules.
function getModulesPaginated(address start, uint256 pageSize) public view returns (address[] memory array, address next)
function getModulesPaginated(address start, uint256 pageSize) public view returns (address[] memory array, address next)
23,661
5
// The Chainlink VRF has a max gas of 200,000 gas (computation units)
address nftOwner = requestIdToSender[requestId]; uint256 tokenId = requestIdToTokenId[requestId]; _safeMint(nftOwner, tokenId); tokenIdToRandomNumber[tokenId] = randomNumber; emit CreatedUnfinishedRandomSVG(tokenId, randomNumber);
address nftOwner = requestIdToSender[requestId]; uint256 tokenId = requestIdToTokenId[requestId]; _safeMint(nftOwner, tokenId); tokenIdToRandomNumber[tokenId] = randomNumber; emit CreatedUnfinishedRandomSVG(tokenId, randomNumber);
37,158
4
// Returns the tokenURI for a given _tokenId
function tokenURI(uint256 _tokenId) public view override returns (string memory)
function tokenURI(uint256 _tokenId) public view override returns (string memory)
21,865
114
// Checks the amount of input tokens to output tokens _input The address of the token being converted _output The address of the token to be converted to _inputAmount The input amount of tokens that are being converted /
function convert_rate( address _input, address _output, uint256 _inputAmount
function convert_rate( address _input, address _output, uint256 _inputAmount
64,861
178
// If the result is a tie, no parties are incoherent and no need to move tokens. Note that 0 (refuse to arbitrate) winning is not a tie.
if (winningChoice==0 && (dispute.voteCounter[dispute.appeals].voteCount[0] != dispute.voteCounter[dispute.appeals].winningCount)) {
if (winningChoice==0 && (dispute.voteCounter[dispute.appeals].voteCount[0] != dispute.voteCounter[dispute.appeals].winningCount)) {
76,100
77
// yes - just execute the call.
_to.transfer(_value); return 0;
_to.transfer(_value); return 0;
34,201
103
// Creates a Chainlink request to the specified oracle address Generates and stores a request ID, increments the local nonce, and uses `transferAndCall` tosend LINK which creates a request on the target oracle contract.Emits ChainlinkRequested event. oracleAddress The address of the oracle for the request req The initi...
function sendChainlinkRequestTo( address oracleAddress, Chainlink.Request memory req, uint256 payment
function sendChainlinkRequestTo( address oracleAddress, Chainlink.Request memory req, uint256 payment
35,240
22
// Works for Bancor assets and old bancor pools
function getRatioByPath(address _from, address _to, uint256 _amount) public view returns(uint256) { BancorNetworkInterface bancorNetwork = BancorNetworkInterface( getBancorContractAddresByName("BancorNetwork") ); // get Bancor path array address[] memory path = bancorNetwork.conversionPath(_from...
function getRatioByPath(address _from, address _to, uint256 _amount) public view returns(uint256) { BancorNetworkInterface bancorNetwork = BancorNetworkInterface( getBancorContractAddresByName("BancorNetwork") ); // get Bancor path array address[] memory path = bancorNetwork.conversionPath(_from...
12,851
35
// Addition to ERC20 token methods. It allows to approve the transfer of value and execute a call with the sent data.Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race...
function approveAndCall( address _spender, uint256 _value, bytes _data ) public payable returns (bool)
function approveAndCall( address _spender, uint256 _value, bytes _data ) public payable returns (bool)
19,628
122
// Restake is to be called weekly. It unstakes 7% of what's currently staked, then restakes. _lastId Frontend must submit last ID because it doesn't work direct from Nexus Mutual./
{ // All Nexus functions. uint256 withdrawn = _withdrawNxm(); // This will unstake from all unstaking protocols uint256 unstaked = _unstakeNxm(_lastId); // This will stake for all protocols, including unstaking protocols uint256 staked = _stakeNxm(); startPro...
{ // All Nexus functions. uint256 withdrawn = _withdrawNxm(); // This will unstake from all unstaking protocols uint256 unstaked = _unstakeNxm(_lastId); // This will stake for all protocols, including unstaking protocols uint256 staked = _stakeNxm(); startPro...
62,700
471
// Either early expiration is enabled and it's before the expiration time or it's after the expiration time.
require( (enableEarlyExpiration && getCurrentTime() < expirationTimestamp) || getCurrentTime() >= expirationTimestamp, "Cannot settle" );
require( (enableEarlyExpiration && getCurrentTime() < expirationTimestamp) || getCurrentTime() >= expirationTimestamp, "Cannot settle" );
7,944
82
// this method might be overridden for implementing any sale logic.return Actual rate. /
function getRate(uint amount) internal constant returns (uint); function getBaseRate() internal constant returns (uint);
function getRate(uint amount) internal constant returns (uint); function getBaseRate() internal constant returns (uint);
14,567
3
// Integer division of two numbers, truncating the quotient./
function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
function div(uint256 a, uint256 b) internal pure returns (uint256) { // assert(b > 0); // Solidity automatically throws when dividing by 0 uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; }
1,765
74
// enforce max sell restrictions.
require(nextPrivateWalletSellDate[from] <= block.timestamp, "Cannot sell yet"); require(amount <= getPrivateSaleMaxSell(), "Attempting to sell over max sell amount. Check max."); nextPrivateWalletSellDate[from] = block.timestamp + 24 hours;
require(nextPrivateWalletSellDate[from] <= block.timestamp, "Cannot sell yet"); require(amount <= getPrivateSaleMaxSell(), "Attempting to sell over max sell amount. Check max."); nextPrivateWalletSellDate[from] = block.timestamp + 24 hours;
5,866
307
// assigned (and available on the emitted {IERC721-Transfer} event), and the tokenURI autogenerated based on the base URI passed at construction.Requirements: - the caller must have the `MINTER_ROLE`. /
function mintByAdmin(address to, string memory _tokenURI) public onlyOwner { _tokenIds.increment(); uint256 newItemId = _tokenIds.current(); require(newItemId <= maxSupply); _mint(to, newItemId); _setTokenURI(newItemId, _tokenURI); }
function mintByAdmin(address to, string memory _tokenURI) public onlyOwner { _tokenIds.increment(); uint256 newItemId = _tokenIds.current(); require(newItemId <= maxSupply); _mint(to, newItemId); _setTokenURI(newItemId, _tokenURI); }
3,248
113
// calculate current mining state
function getMiningState(uint _blockNum) public view returns(uint, uint){ require(_blockNum >= miningStateBlock, "_blockNum must be >= miningStateBlock"); uint blockNumber = _blockNum; if(_blockNum>endMiningBlockNum){ //if current block.number is bigger than the end of program, only update t...
function getMiningState(uint _blockNum) public view returns(uint, uint){ require(_blockNum >= miningStateBlock, "_blockNum must be >= miningStateBlock"); uint blockNumber = _blockNum; if(_blockNum>endMiningBlockNum){ //if current block.number is bigger than the end of program, only update t...
11,313
8
// The Lootmart contract is used to calculate the token ID, guaranteeing the correct supply for each helm
ILoot private ogLootContract; ILmart private lmartContract; IRiftData private riftDataContract; IHelmsMetadata public metadataContract;
ILoot private ogLootContract; ILmart private lmartContract; IRiftData private riftDataContract; IHelmsMetadata public metadataContract;
45,353
32
// Set tokenURI, contentURI and withdrawOnBurn to the same as source token
_setTokenURI(claimTokenId, _tokenURIs[tokenId]); _contentURIs[claimTokenId] = _contentURIs[tokenId]; _withdrawOnBurn[claimTokenId] = _withdrawOnBurn[tokenId];
_setTokenURI(claimTokenId, _tokenURIs[tokenId]); _contentURIs[claimTokenId] = _contentURIs[tokenId]; _withdrawOnBurn[claimTokenId] = _withdrawOnBurn[tokenId];
40,710
33
// check allowance
require( BUSD.allowance(beneficiary, address(this)) >= busdAmount, "Contract not approved to transfer BUSD" );
require( BUSD.allowance(beneficiary, address(this)) >= busdAmount, "Contract not approved to transfer BUSD" );
21,211
86
// Current min quorum votes using Noun total supply /
function minQuorumVotes() public view returns (uint256) { return bps2Uint(getDynamicQuorumParamsAt(block.number).minQuorumVotesBPS, nouns.totalSupply()); }
function minQuorumVotes() public view returns (uint256) { return bps2Uint(getDynamicQuorumParamsAt(block.number).minQuorumVotesBPS, nouns.totalSupply()); }
26,617
38
// Extends the end time of an auction if we are within the grace period.
function _maybeExtendTime (uint64 auctionId, Auction storage auction) internal { uint64 gracePeriodStart = auction.endTimestamp - BIDDING_GRACE_PERIOD; uint64 _now = uint64(block.timestamp); if (_now > gracePeriodStart) { auction.endTimestamp = uint32(_now + BIDDING_GRACE_PERIOD)...
function _maybeExtendTime (uint64 auctionId, Auction storage auction) internal { uint64 gracePeriodStart = auction.endTimestamp - BIDDING_GRACE_PERIOD; uint64 _now = uint64(block.timestamp); if (_now > gracePeriodStart) { auction.endTimestamp = uint32(_now + BIDDING_GRACE_PERIOD)...
34,435
31
// n.b. that the operator takes the gem and might not be the same operator who brought the gem
function free(uint256 wad) external operator { require(wad <= 2**255, "RwaUrn/overflow"); vat.frob(gemJoin.ilk(), address(this), address(this), address(this), -int256(wad), 0); gemJoin.exit(msg.sender, wad); emit Free(msg.sender, wad); }
function free(uint256 wad) external operator { require(wad <= 2**255, "RwaUrn/overflow"); vat.frob(gemJoin.ilk(), address(this), address(this), address(this), -int256(wad), 0); gemJoin.exit(msg.sender, wad); emit Free(msg.sender, wad); }
7,856
99
// allow sender to mint for "to"
return _purchase(msg.sender, to, tokenIn, maxAmount, amountIn, proof);
return _purchase(msg.sender, to, tokenIn, maxAmount, amountIn, proof);
32,967
76
// Emitted when an aToken is initialized underlyingAsset The address of the underlying asset pool The address of the associated lending pool treasury The address of the treasury incentivesController The address of the incentives controller for this aToken eTokenDecimals the decimals of the underlying eTokenName the nam...
function initialize( ILendingPool pool, address treasury, address underlyingAsset, IEaveIncentivesController incentivesController, uint8 eTokenDecimals, string calldata eTokenName, string calldata eTokenSymbol, bytes calldata params ) external;
function initialize( ILendingPool pool, address treasury, address underlyingAsset, IEaveIncentivesController incentivesController, uint8 eTokenDecimals, string calldata eTokenName, string calldata eTokenSymbol, bytes calldata params ) external;
73,475
77
// Construct the token. This token must be created through a team multisig wallet, so that it is owned by that wallet._name Token name _symbol Token symbol - should be all caps _initialSupply How many tokens we start with _decimals Number of decimal places _mintable Are new tokens created over the crowdsale or do we di...
function CrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint8 _decimals, bool _mintable) public UpgradeableToken(msg.sender)
function CrowdsaleToken(string _name, string _symbol, uint _initialSupply, uint8 _decimals, bool _mintable) public UpgradeableToken(msg.sender)
38,519
113
// override for get eth only after finalization
function _forwardFunds() internal { }
function _forwardFunds() internal { }
52,379
93
// uint load = getDivdLoad();/v2 begin
uint load = getDivdLoad();
uint load = getDivdLoad();
6,280
891
// deposit eth on behalf of proxy
DSProxy(payable(proxy)).execute{value: ethAmount}(AAVE_BASIC_PROXY, abi.encodeWithSignature("deposit(address,address,uint256)", market, ETH_ADDR, ethAmount));
DSProxy(payable(proxy)).execute{value: ethAmount}(AAVE_BASIC_PROXY, abi.encodeWithSignature("deposit(address,address,uint256)", market, ETH_ADDR, ethAmount));
49,460
6
// See {IClaimIssuer-isClaimRevoked}. /
function isClaimRevoked( bytes memory sig ) public view override returns (bool) { return _revokedClaims[sig]; }
function isClaimRevoked( bytes memory sig ) public view override returns (bool) { return _revokedClaims[sig]; }
19,428
259
// The Governance token
Treats public govToken;
Treats public govToken;
50,637
45
// Gets the balance of the specified address._addr The address to query the the balance of. return An uint256 representing the amount owned by the passed address./
function balanceOf(address _addr) public view returns (uint256) { return balances[_addr]; }
function balanceOf(address _addr) public view returns (uint256) { return balances[_addr]; }
17,825
68
// Sends all the marketing ETH to the marketingWallet
(bool sent,)=marketingWallet.call{value:address(this).balance}("");
(bool sent,)=marketingWallet.call{value:address(this).balance}("");
7,946
108
// _protocols List of the 10 protocols we're using. _wNxm Address of the wNxm contract. _arNxm Address of the arNxm contract. _nxmMaster Address of Nexus' master address (to fetch others). _rewardManager Address of the ReferralRewards smart contract./
{ require(address(arNxm) == address(0), "Contract has already been initialized."); for (uint256 i = 0; i < _protocols.length; i++) protocols.push(_protocols[i]); Ownable.initializeOwnable(); wNxm = IERC20(_wNxm); nxm = IERC20(_nxm); arNxm = IERC20(_arNxm); n...
{ require(address(arNxm) == address(0), "Contract has already been initialized."); for (uint256 i = 0; i < _protocols.length; i++) protocols.push(_protocols[i]); Ownable.initializeOwnable(); wNxm = IERC20(_wNxm); nxm = IERC20(_nxm); arNxm = IERC20(_arNxm); n...
62,503
24
// stake amount of GMI tokens to Staking Pool/ this method can called by anyone/ _projectIdid of the project/ _amountamount of the tokens to be staked
function stake(uint256 _projectId, uint256 _amount) external validProject(_projectId) { StakeInfo storage stakeInfo = projects[_projectId].stakeInfo; require(!isAlreadyStaked(_projectId, _msgSender()), "You already staking"); require(block.number >= stakeInfo.startBlockNumber, "Staking has n...
function stake(uint256 _projectId, uint256 _amount) external validProject(_projectId) { StakeInfo storage stakeInfo = projects[_projectId].stakeInfo; require(!isAlreadyStaked(_projectId, _msgSender()), "You already staking"); require(block.number >= stakeInfo.startBlockNumber, "Staking has n...
18,519
117
// Multiplies two precise units, and then truncates by the full scale, rounding up the result x Left hand input to multiplication y Right hand input to multiplicationreturnResult after multiplying the two inputs and then dividing by the shared scale unit, rounded up to the closest base unit. /
function mulTruncateCeil(uint256 x, uint256 y) internal pure returns (uint256)
function mulTruncateCeil(uint256 x, uint256 y) internal pure returns (uint256)
36,573