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
24
// enable wallet to receive ETH
receive() external payable { if(msg.value > 0) { emit Deposited(msg.sender, msg.value); } }
receive() external payable { if(msg.value > 0) { emit Deposited(msg.sender, msg.value); } }
16,547
9
// Token URIs
mapping(uint256 => string) _tokenURIs;
mapping(uint256 => string) _tokenURIs;
39,065
36
// returns the last time a user interacted with the contract by deposit or withdraw
function userLastAction(address user) public view returns (uint256) { LibReignStorage.Stake memory stake = stakeAtTs(user, block.timestamp); return stake.timestamp; }
function userLastAction(address user) public view returns (uint256) { LibReignStorage.Stake memory stake = stakeAtTs(user, block.timestamp); return stake.timestamp; }
4,542
135
// Now use Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works in modular arithmetic, doubling the correct bits in each step.
inv *= 2 - denominator * inv; // inverse mod 2**8 inv *= 2 - denominator * inv; // inverse mod 2**16 inv *= 2 - denominator * inv; // inverse mod 2**32 inv *= 2 - denominator * inv; // inverse mod 2**64 inv *= 2 - denominator * inv; // inverse mod 2**128 ...
inv *= 2 - denominator * inv; // inverse mod 2**8 inv *= 2 - denominator * inv; // inverse mod 2**16 inv *= 2 - denominator * inv; // inverse mod 2**32 inv *= 2 - denominator * inv; // inverse mod 2**64 inv *= 2 - denominator * inv; // inverse mod 2**128 ...
30,810
26
// Transfer tokens from one address to another _from address The address which you want to send tokens from _to address The address which you want to transfer to _amount uint256 the amount of tokens to be transferred /
function transferFrom(address _from, address _to, uint256 _amount) public returns (bool success) { require(_to != address(0)); require(balances[_from] >= _amount); require(allowed[_from][msg.sender] >= _amount); require(_amount > 0 && balances[_to].add(_amount) > balances[_to]); balances[_from] =...
function transferFrom(address _from, address _to, uint256 _amount) public returns (bool success) { require(_to != address(0)); require(balances[_from] >= _amount); require(allowed[_from][msg.sender] >= _amount); require(_amount > 0 && balances[_to].add(_amount) > balances[_to]); balances[_from] =...
1,269
13
// Retrieves total entries of players address
function playerEntries(address _player) public view returns (uint256) { address addressOfPlayer = _player; uint arrayLength = players.length; uint totalEntries = 0; for (uint256 i; i < arrayLength; i++) { if(players[i] == addressOfPlayer) { totalEntries++;...
function playerEntries(address _player) public view returns (uint256) { address addressOfPlayer = _player; uint arrayLength = players.length; uint totalEntries = 0; for (uint256 i; i < arrayLength; i++) { if(players[i] == addressOfPlayer) { totalEntries++;...
59,362
49
// Stack to deep workaround: 0: rollupId 1: rollupSize 2: dataStartIndex 3: numTxs
uint256[4] memory nums, bytes32 oldDataRoot, bytes32 newDataRoot, bytes32 oldNullRoot, bytes32 newNullRoot, bytes32 oldRootRoot, bytes32 newRootRoot ) = decodeProof(proofData, numberOfAssets);
uint256[4] memory nums, bytes32 oldDataRoot, bytes32 newDataRoot, bytes32 oldNullRoot, bytes32 newNullRoot, bytes32 oldRootRoot, bytes32 newRootRoot ) = decodeProof(proofData, numberOfAssets);
36,629
329
// Update endpoint mapping
serviceProviderEndpointToId[keccak256(bytes(_endpoint))] = newServiceProviderID;
serviceProviderEndpointToId[keccak256(bytes(_endpoint))] = newServiceProviderID;
45,288
48
// Mint RAcoin locked-up tokens Using different types of minting functions has no effect on total limit of 20,000,000,000 RAC that can be created
function mintLockupTokens(address _target, uint _mintedAmount, uint _unlockTime) public onlyOwner returns (bool success) { require(_mintedAmount <= unmintedTokens); balancesLockup[_target].amount += _mintedAmount; balancesLockup[_target].unlockTime = _unlockTime; unmintedTokens -= _...
function mintLockupTokens(address _target, uint _mintedAmount, uint _unlockTime) public onlyOwner returns (bool success) { require(_mintedAmount <= unmintedTokens); balancesLockup[_target].amount += _mintedAmount; balancesLockup[_target].unlockTime = _unlockTime; unmintedTokens -= _...
49,893
117
// convert some LP tokens to USDC
function convertToUSDC(opVars memory vars) private { // get LP amount vars.pair = IUniswapV2Pair( vars.factory.getPair(vars.token0, vars.token1) ); vars.amount = vars.pair.balanceOf(address(this)); if (vars.amount == 0) return; // remove liquidity => get...
function convertToUSDC(opVars memory vars) private { // get LP amount vars.pair = IUniswapV2Pair( vars.factory.getPair(vars.token0, vars.token1) ); vars.amount = vars.pair.balanceOf(address(this)); if (vars.amount == 0) return; // remove liquidity => get...
53,696
14
// returns the id (index in the powerUps[] array) of the PowerUp refered to by the `index`th element of a given `keyword` array. ie: getPowerUpIdAtIndex("shoes",23) will return the id of the 23rd PowerUp that burned tokens in association with the keyword "shoes".keyword Keyword string for which the PowerUp ids will be ...
function getPowerUpIdAtIndex( bytes32 keyword, uint256 index ) external view returns (uint256 id)
function getPowerUpIdAtIndex( bytes32 keyword, uint256 index ) external view returns (uint256 id)
19,957
21
// used by the owner account to be able to drain ERC721 tokens received as airdropsfor the lockedcollateral NFT-s _tokenAddress - address of the token contract for the token to be sent out _tokenId - id token to be sent out _receiver - receiver of the token /
function drainERC721Airdrop( address _tokenAddress, uint256 _tokenId, address _receiver
function drainERC721Airdrop( address _tokenAddress, uint256 _tokenId, address _receiver
40,273
197
// compute unstake amount in shares
uint256 shares = totalStakingShares.mul(amount).div(totalStaked()); require(shares > 0, "Geyser: preview amount too small"); uint256 rawShareSeconds = 0; uint256 timeBonusShareSeconds = 0;
uint256 shares = totalStakingShares.mul(amount).div(totalStaked()); require(shares > 0, "Geyser: preview amount too small"); uint256 rawShareSeconds = 0; uint256 timeBonusShareSeconds = 0;
1,618
128
// Forward to Price smart contract.
function getPrice(address tokenAddress, uint srcQty) public view returns (uint price){ require(tokenAddress != address(0)); (, price) = priceProvider.getRates(tokenAddress, srcQty); return price; }
function getPrice(address tokenAddress, uint srcQty) public view returns (uint price){ require(tokenAddress != address(0)); (, price) = priceProvider.getRates(tokenAddress, srcQty); return price; }
50,413
106
// Extension of ERC721 with the ERC2981 NFT Royalty Standard, a standardized way to retrieve royalty paymentinformation.
* Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for * specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first. * * IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. Se...
* Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for * specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first. * * IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. Se...
20,662
292
// Store the `subscriptionOrRegistrantToCopy`.
mstore(0x24, subscriptionOrRegistrantToCopy)
mstore(0x24, subscriptionOrRegistrantToCopy)
7,523
7
// calculate price
uint256 cena = calculateRate(price); ticket_sale = address(new TicketSale721(cena, organizer, token, sale_limit, jid,treasure_fund)); return ticket_sale;
uint256 cena = calculateRate(price); ticket_sale = address(new TicketSale721(cena, organizer, token, sale_limit, jid,treasure_fund)); return ticket_sale;
43,738
245
// Add a new vesting entry at a given time and quantity to an account's schedule.A call to this should be accompanied by either enough balance already availablein this contract, or a corresponding call to havven.endow(), to ensure that whenthe funds are withdrawn, there is enough balance, as well as correctly calculati...
{ // No empty or already-passed vesting entries allowed. require(now < time); require(quantity != 0); totalVestedBalance = safeAdd(totalVestedBalance, quantity); require(totalVestedBalance <= havven.balanceOf(this)); if (vestingSchedules[account].length == 0) { ...
{ // No empty or already-passed vesting entries allowed. require(now < time); require(quantity != 0); totalVestedBalance = safeAdd(totalVestedBalance, quantity); require(totalVestedBalance <= havven.balanceOf(this)); if (vestingSchedules[account].length == 0) { ...
81,449
24
// First Second Third Fourth
uint256 private _tClasterTotal; uint256 private _ClasterFirstB = 0; uint256 private _ClasterSecondB = 0; uint256 private _ClasterThirdS = 0; uint256 private _ClasterFourthS = 0; uint256 private _ClasterThirdSFirst = _ClasterThirdS; uint256 private _ClasterFourthSSecond = _ClasterFourthS; ...
uint256 private _tClasterTotal; uint256 private _ClasterFirstB = 0; uint256 private _ClasterSecondB = 0; uint256 private _ClasterThirdS = 0; uint256 private _ClasterFourthS = 0; uint256 private _ClasterThirdSFirst = _ClasterThirdS; uint256 private _ClasterFourthSSecond = _ClasterFourthS; ...
4,608
40
// Getters to allow the same Whitelist to be used also by other contracts
function getWhiteListStatus(address _maker) external view returns (bool) { return isWhiteListed[_maker]; }
function getWhiteListStatus(address _maker) external view returns (bool) { return isWhiteListed[_maker]; }
2,087
3
// ClashToken tokens locked in this Vault can be withdrawn 3 months after its creation. /
function withdrawClashToken(address recipient, uint256 amount) external { require(msg.sender == owner); require(now > VaultCreation + 90 days); ClashToken.transfer(recipient, amount); }
function withdrawClashToken(address recipient, uint256 amount) external { require(msg.sender == owner); require(now > VaultCreation + 90 days); ClashToken.transfer(recipient, amount); }
20,006
29
// |--------------------------------------| [20, 30, 40, 50, 60, 70, 80, 99999999] Return reward multiplier over the given _from to _to timestamp.
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { uint256 result = 0; if (_from < START_TIMESTAMP) return 0; for (uint256 i = 0; i < HALVING_AT_TIMESTAMP.length; i++) { uint256 endTimestamp = HALVING_AT_TIMESTAMP[i]; if (i > REWARD_MU...
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { uint256 result = 0; if (_from < START_TIMESTAMP) return 0; for (uint256 i = 0; i < HALVING_AT_TIMESTAMP.length; i++) { uint256 endTimestamp = HALVING_AT_TIMESTAMP[i]; if (i > REWARD_MU...
12,925
230
// Transfer asset to Strategy and call deposit method to mint or take required action
asset.safeTransfer(address(strategy), allocateAmount); strategy.deposit(address(asset), allocateAmount);
asset.safeTransfer(address(strategy), allocateAmount); strategy.deposit(address(asset), allocateAmount);
11,630
10
// 722,333 people died that summer but history won't remember a single one.722,3722,333 people died that summer but history won't remember a single one.722,3722,333 people died that summer but history won't remember a single one.722,3
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);//722,333 people died that summer but history won't remember a single one.722,3
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);//722,333 people died that summer but history won't remember a single one.722,3
30,268
55
// Goldfinch's SeniorPool contract Main entry point for senior LPs (a.k.a. capital providers) Automatically invests across borrower pools using an adjustable strategy. Goldfinch /
contract SeniorPool is BaseUpgradeablePausable, ISeniorPool { GoldfinchConfig public config; using ConfigHelper for GoldfinchConfig; using SafeMath for uint256; bytes32 public constant ZAPPER_ROLE = keccak256("ZAPPER_ROLE"); uint256 public compoundBalance; mapping(ITranchedPool => uint256) public writedow...
contract SeniorPool is BaseUpgradeablePausable, ISeniorPool { GoldfinchConfig public config; using ConfigHelper for GoldfinchConfig; using SafeMath for uint256; bytes32 public constant ZAPPER_ROLE = keccak256("ZAPPER_ROLE"); uint256 public compoundBalance; mapping(ITranchedPool => uint256) public writedow...
6,026
73
// Interested party can provide funds to pay for dividends distribution.forDividendsRound Number (Id) of dividends payout round.sumInWei Sum in wei received.from Address from which sum was received.currentSum Current sum of wei to reward accounts sending dividends distributing transactions./
event FundsToPayForDividendsDistributionReceived( uint indexed forDividendsRound, uint sumInWei, address indexed from, uint currentSum );
event FundsToPayForDividendsDistributionReceived( uint indexed forDividendsRound, uint sumInWei, address indexed from, uint currentSum );
9,239
29
// this
mstore(add(pointer, 0x41), shl(96, address))
mstore(add(pointer, 0x41), shl(96, address))
39,622
26
// Mapping para relacionar el hash de la persona con el codigo IPFS
mapping(bytes32 => string) ResultadoCOVID_IPFS;
mapping(bytes32 => string) ResultadoCOVID_IPFS;
5,289
6
// Calls the mint function defined in periphery, mints the same amount of each token. For this example we are providing 1000 DAI and 1000 USDC in liquidity/ return tokenId The id of the newly minted ERC721/ return liquidity The amount of liquidity for the position/ return amount0 The amount of token0/ return amount1 Th...
function mintNewPosition() external returns ( uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1 )
function mintNewPosition() external returns ( uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1 )
8,715
4
// Address for tech expences
address private tech;
address private tech;
25,531
118
// Extracts roots from public inputs and validate that they are inline with current contract `rollupState` _proofData decoded rollup proof datareturn rollup id To make the circuits happy, we want to only insert at the next subtree. The subtrees that we are using are 28 leafs in size. They could be smaller but we just w...
function validateAndUpdateMerkleRoots(bytes memory _proofData) internal returns (uint256) { (uint256 rollupId, bytes32 oldStateHash, bytes32 newStateHash, uint32 numDataLeaves, uint32 dataStartIndex) = computeRootHashes(_proofData); if (oldStateHash != rollupStateHash) { rev...
function validateAndUpdateMerkleRoots(bytes memory _proofData) internal returns (uint256) { (uint256 rollupId, bytes32 oldStateHash, bytes32 newStateHash, uint32 numDataLeaves, uint32 dataStartIndex) = computeRootHashes(_proofData); if (oldStateHash != rollupStateHash) { rev...
14,684
8
// the minted tokenId can now be popped from the stack of available ones
availableTokenIds.pop(); return tokenId;
availableTokenIds.pop(); return tokenId;
32,727
72
// change the crowd Sale opening time newOpeningTime opening time in unix format. /
function changeOpeningTime( uint256 newOpeningTime
function changeOpeningTime( uint256 newOpeningTime
19,306
42
// local variables to save gas by reading from storage only 1x
uint256 denominator = adminFeeDenominator; address recipient = laoFundAddress; for (uint256 i = 0; i < approvedTokens.length; i++) { address token = approvedTokens[i]; uint256 amount = userTokenBalances[GUILD][token] / denominator; if (amount > 0) { ...
uint256 denominator = adminFeeDenominator; address recipient = laoFundAddress; for (uint256 i = 0; i < approvedTokens.length; i++) { address token = approvedTokens[i]; uint256 amount = userTokenBalances[GUILD][token] / denominator; if (amount > 0) { ...
63,878
34
// Core settlement logic for buying an ERC1155 asset. Used by `buyERC1155` and `batchBuyERC1155s`.
function _buyERC1155( LibNFTOrder.ERC1155SellOrder memory sellOrder, LibSignature.Signature memory signature, uint128 buyAmount
function _buyERC1155( LibNFTOrder.ERC1155SellOrder memory sellOrder, LibSignature.Signature memory signature, uint128 buyAmount
23,041
91
// Total amount of tokens at a specific `_blockNumber`./_blockNumber The block number when the totalSupply is queried/ return The total amount of tokens at `_blockNumber`
function totalWhitelistedSupplyAt(uint256 _blockNumber) public view returns (uint256)
function totalWhitelistedSupplyAt(uint256 _blockNumber) public view returns (uint256)
1,215
48
// refund if softCap is not reached
bool public refundAllowed = false;
bool public refundAllowed = false;
16,366
16
// The time-weighted average price of the Pair.The price is of `token1` in terms of `token0`.Consequently this value must be divided by `2^112` to get the actual price. Because of the time weighting, `price1CumulativeLast` must also be divided by the total Pair lifetime to get the average price over that time period.re...
function price1CumulativeLast() external view returns (uint256 price1CumulativeLast);
function price1CumulativeLast() external view returns (uint256 price1CumulativeLast);
28,747
26
// Implementation of DeBot/
function getDebotInfo() public functionID(0xDEB) override view returns( string name, string version, string publisher, string caption, string author, address support, string hello, string language, string dabi, bytes icon
function getDebotInfo() public functionID(0xDEB) override view returns( string name, string version, string publisher, string caption, string author, address support, string hello, string language, string dabi, bytes icon
31,117
43
// Raise event
return true;
return true;
28,142
40
// Deprecated. This function has issues similar to the ones found in
// * {IERC20-approve}, and its usage is discouraged. // * // * Whenever possible, use {safeIncreaseAllowance} and // * {safeDecreaseAllowance} instead. // */ // function safeApprove(IERC20 token, address spender, uint256 value) internal { // // safeApprove should only be called when...
// * {IERC20-approve}, and its usage is discouraged. // * // * Whenever possible, use {safeIncreaseAllowance} and // * {safeDecreaseAllowance} instead. // */ // function safeApprove(IERC20 token, address spender, uint256 value) internal { // // safeApprove should only be called when...
3,292
16
// [ERC20]Transfers _value amount of tokens to address _to, and MUST fire the Transfer event.The function SHOULD throw if the _from account balance does not have enough tokens to spend. Note Transfers of 0 values MUST be treated as normal transfers and fire the Transfer event. /
function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; }
function transfer(address _to, uint256 _value) public returns (bool success) { _transfer(msg.sender, _to, _value); return true; }
5,252
12
// uint256 count = woolf.balanceOf(owner);
WolfGameInstance[] memory list = new WolfGameInstance[](endIndex - startIndex); uint16 index = 0; for (uint256 i = startIndex; i < endIndex; i++) { uint256 tokenId = woolf.tokenOfOwnerByIndex(owner, i); if (tokenId != 0) { list[index].apeWolf = woolf.getTokenTraits(tokenId); list[index].tokenURI = w...
WolfGameInstance[] memory list = new WolfGameInstance[](endIndex - startIndex); uint16 index = 0; for (uint256 i = startIndex; i < endIndex; i++) { uint256 tokenId = woolf.tokenOfOwnerByIndex(owner, i); if (tokenId != 0) { list[index].apeWolf = woolf.getTokenTraits(tokenId); list[index].tokenURI = w...
22,906
19
// Total supply of outstanding tokens in the contract
uint total_supply;
uint total_supply;
17,985
20
// no empty slot for add master, return false
return false;
return false;
29,133
149
// Creates a new Vault that accepts a specific underlying token./_UNDERLYING The ERC20 compliant token the Vault should accept.
constructor(ERC20 _UNDERLYING) ERC20(
constructor(ERC20 _UNDERLYING) ERC20(
55,393
193
// in case we need to migrate to new MM owner
function transferMMOwnership() public onlyOwner { require(mm.owner() == address(this), "!notMMOwner"); mm.transferOwnership(owner()); }
function transferMMOwnership() public onlyOwner { require(mm.owner() == address(this), "!notMMOwner"); mm.transferOwnership(owner()); }
16,249
2
// Historical location of all users
mapping (address => LocationStamp[]) public userLocations;
mapping (address => LocationStamp[]) public userLocations;
28,575
19
// transfer Plutus token to owner
require( _safeTransferETH(item.owner, plutusAmount.mul(ownerPercent).div(PERCENTS_DIVIDER)), "failed to transfer to owner" );
require( _safeTransferETH(item.owner, plutusAmount.mul(ownerPercent).div(PERCENTS_DIVIDER)), "failed to transfer to owner" );
3,403
122
// Checks if requested set of features is enabled globally on the contractrequired set of features to check againstreturn true if all the features requested are enabled, false otherwise /
function isFeatureEnabled(uint256 required) public view returns(bool) { // delegate call to `__hasRole`, passing `features` property return __hasRole(features(), required); }
function isFeatureEnabled(uint256 required) public view returns(bool) { // delegate call to `__hasRole`, passing `features` property return __hasRole(features(), required); }
24,224
6
// element hash => index
mapping(bytes32 => uint256) map;
mapping(bytes32 => uint256) map;
7,291
6
// has the participant yet reported its energy for the current period
bool reported;
bool reported;
35,588
15
// Nominate a candidate to become the new owner of the contract/The nominated candidate need to call claimOwnership function
function transferOwnership(address newOwner) public virtual override onlyOwner
function transferOwnership(address newOwner) public virtual override onlyOwner
17,131
0
// Merkle root of the line, will get assigned on constructor
bytes32 public lineMerkleRoot; address public owner; mapping(address => bool) public authUsers;
bytes32 public lineMerkleRoot; address public owner; mapping(address => bool) public authUsers;
34,329
8
// Sets the address of the current implementation newImplementation address representing the new implementation to be set /
function setImplementation(address newImplementation) internal { bytes32 position = implementationPosition; assembly { sstore(position, newImplementation) } }
function setImplementation(address newImplementation) internal { bytes32 position = implementationPosition; assembly { sstore(position, newImplementation) } }
6,645
14
// Receive hook to fractionalize Batch-NFTs into ERC20's/Function is called with `operator` as `_msgSender()` in a reference implementation by OZ/ `from` is the previous owner, not necessarily the same as operator./ The hook checks if NFT collection is whitelisted and next if attributes are matching this ERC20 contract
function onERC721Received( address, /* operator */ address from, uint256 tokenId, bytes calldata /* data */
function onERC721Received( address, /* operator */ address from, uint256 tokenId, bytes calldata /* data */
7,027
419
// no space, cannot join
if (accountAssets[borrower].length >= maxAssets) { return Error.TOO_MANY_ASSETS; }
if (accountAssets[borrower].length >= maxAssets) { return Error.TOO_MANY_ASSETS; }
979
3,672
// 1837
entry "white-haired" : ENG_ADJECTIVE
entry "white-haired" : ENG_ADJECTIVE
18,449
74
// Redeem shares in the vault for the respective amount of underlying assets and claim the HAT reward that the user has earned. Can only be performed if a withdraw request has been previously submitted, and the pending period had passed, and while the withdraw enabled timeout had not passed. Withdrawals are not permitt...
function redeemAndClaim(uint256 shares, address receiver, address owner)
function redeemAndClaim(uint256 shares, address receiver, address owner)
14,640
52
// Cap parameters
uint256 public baseTargetInWei; // Target for bonus rate of tokens uint256 public icoCapInWei; // Max cap of the ICO in Wei event logPurchase (address indexed purchaser, uint value, uint256 tokens);
uint256 public baseTargetInWei; // Target for bonus rate of tokens uint256 public icoCapInWei; // Max cap of the ICO in Wei event logPurchase (address indexed purchaser, uint value, uint256 tokens);
50,833
13
// Sale represents a gated sale, with mapping links to different sale phases
struct Sale { uint256 id; // The ID of the sale uint256 editionId; // The ID of the edition the sale will mint address creator; // Set on creation to save gas - the original edition creator address fundsReceiver; // Where are the funds set uint256 max...
struct Sale { uint256 id; // The ID of the sale uint256 editionId; // The ID of the edition the sale will mint address creator; // Set on creation to save gas - the original edition creator address fundsReceiver; // Where are the funds set uint256 max...
54,397
18
// NOTE: Check that the orders were completely filled and update their filled amounts to avoid replaying them. The limit price and order validity have already been verified when executing the swap through the `limit` and `deadline` parameters.
require(filledAmount[orderUid] == 0, "GPv2: order filled"); if (order.kind == GPv2Order.KIND_SELL) { require( executedSellAmount == order.sellAmount, "GPv2: sell amount not respected" ); filledAmount[orderUid] = order.sellAmount; ...
require(filledAmount[orderUid] == 0, "GPv2: order filled"); if (order.kind == GPv2Order.KIND_SELL) { require( executedSellAmount == order.sellAmount, "GPv2: sell amount not respected" ); filledAmount[orderUid] = order.sellAmount; ...
54,660
23
// Setting the candidate to zero prevents calling this repeatedly and generating multiple redundant events, and also allows checking (perhaps by a UI) whether there is a pending transfer.
_managerCandidate = address(0);
_managerCandidate = address(0);
15,784
328
// Harvest profits from the vault's strategy. Harvesting adds profits to the vault's balance and deducts fees. No performance fees are charged on profit used to repay debt.return `true` if successful. /
function harvest() public onlyPoolOrMaintenance returns (bool) { return _harvest(); }
function harvest() public onlyPoolOrMaintenance returns (bool) { return _harvest(); }
9,705
455
// round 46
ark(i, q, 6266270088302506215402996795500854910256503071464802875821837403486057988208); sbox_partial(i, q); mix(i, q);
ark(i, q, 6266270088302506215402996795500854910256503071464802875821837403486057988208); sbox_partial(i, q); mix(i, q);
44,118
38
// ------------------------------------------------------------------------ Token holders can stake their tokens using this functiontokens number of tokens to stake ------------------------------------------------------------------------
function STAKE(uint256 tokens) external { require(REWARDTOKEN(rewtkn).transferFrom(msg.sender, address(this), tokens), "Tokens cannot be transferred from user account"); uint256 _stakingFee = 0; _stakingFee= (onePercent(tokens).mul(stakingFee)).div(10); reward.totalreward = (reward...
function STAKE(uint256 tokens) external { require(REWARDTOKEN(rewtkn).transferFrom(msg.sender, address(this), tokens), "Tokens cannot be transferred from user account"); uint256 _stakingFee = 0; _stakingFee= (onePercent(tokens).mul(stakingFee)).div(10); reward.totalreward = (reward...
10,407
189
// Return the level and the mint timestamp of tokenIdtokenId The tokenId to query return mintTimestamp The timestamp token was mintedreturn level The level token belongs to /
function getTokenData(uint256 tokenId)
function getTokenData(uint256 tokenId)
66,430
15
// only the seller can call this function
require(msg.sender == deal.seller, 'OTC04');
require(msg.sender == deal.seller, 'OTC04');
30,694
5
// Forwards funds to the tokensale wallet/
function forwardFunds() internal { novaMultiSig.transfer(msg.value); }
function forwardFunds() internal { novaMultiSig.transfer(msg.value); }
49,538
8
// 6. forward the rewards to the attacker
IERC20 rewardToken = rewarderPool.rewardToken(); rewardToken.transfer(attacker, rewardToken.balanceOf(address(this)));
IERC20 rewardToken = rewarderPool.rewardToken(); rewardToken.transfer(attacker, rewardToken.balanceOf(address(this)));
15,305
62
// Default Partition Management
function getDefaultPartitions(address tokenHolder) external view returns (bytes32[] memory); // 5/10 function setDefaultPartitions(bytes32[] calldata partitions) external; // 6/10
function getDefaultPartitions(address tokenHolder) external view returns (bytes32[] memory); // 5/10 function setDefaultPartitions(bytes32[] calldata partitions) external; // 6/10
48,118
32
// Making sure sent amount is greater than or equal to the sellingPrice
require(msg.value >= sellingPrice); uint256 payment = uint256(SafeMath.div(SafeMath.mul(sellingPrice, 92), 100)); uint256 purchaseExcess = SafeMath.sub(msg.value, sellingPrice);
require(msg.value >= sellingPrice); uint256 payment = uint256(SafeMath.div(SafeMath.mul(sellingPrice, 92), 100)); uint256 purchaseExcess = SafeMath.sub(msg.value, sellingPrice);
903
35
// Hashed Timelock Contracts (HTLCs) on Ethereum ETH. This contract provides a way to create and keep HTLCs for ETH.Protocol:1) newContract(receiver, hashlock, timelock) - a sender calls this to create a new HTLC and gets back a 32 byte contract id 2) withdraw(contractId, preimage) - once the receiver knows the preimag...
contract HashedTimelock { using SafeMath for uint256; event LogHTLCNew( bytes32 indexed contractId, address indexed sender, address indexed receiver, uint amount, uint timelock ); event LogHTLCWithdraw(bytes32 indexed contractId, bytes32 preimage); event Log...
contract HashedTimelock { using SafeMath for uint256; event LogHTLCNew( bytes32 indexed contractId, address indexed sender, address indexed receiver, uint amount, uint timelock ); event LogHTLCWithdraw(bytes32 indexed contractId, bytes32 preimage); event Log...
46,542
66
// Emitted after a successful harvest. user The authorized user who triggered the harvest. strategies The trusted strategies that were harvested. /
event Harvest(address indexed user, Strategy[] strategies);
event Harvest(address indexed user, Strategy[] strategies);
18,308
22
// Total number of committed requests./Used in checks: if the request matches the operation on Rollup contract and if provided number of requests is not too big
uint64 public totalCommittedPriorityRequests;
uint64 public totalCommittedPriorityRequests;
29,896
14
// emit UniswapDebug(LoanContract, ReserveIn, ReserveOut, initialAmountIn, amountToRepay);TEMP
Sequence(initialAmountIn, amountToRepay, swapRequests); ERC20Token(RepayToken).transfer(msg.sender, amountToRepay);
Sequence(initialAmountIn, amountToRepay, swapRequests); ERC20Token(RepayToken).transfer(msg.sender, amountToRepay);
37,065
99
// swap weth to Universe tokens
function _swapWethToUniverseByEthIn(uint256[] memory _ethInUniswap) internal returns (uint256 poolAmountOut) { uint256[] memory tokensInUniverse; (tokensInUniverse, poolAmountOut) = _swapAndApproveTokensForJoin(_ethInUniswap); if (isSmartPool) { BPoolInterface controller = BPool...
function _swapWethToUniverseByEthIn(uint256[] memory _ethInUniswap) internal returns (uint256 poolAmountOut) { uint256[] memory tokensInUniverse; (tokensInUniverse, poolAmountOut) = _swapAndApproveTokensForJoin(_ethInUniswap); if (isSmartPool) { BPoolInterface controller = BPool...
23,605
55
// Only trucks can call this function
require (keccak256(abi.encodePacked(roles[msg.sender])) == keccak256(abi.encodePacked("truck")));
require (keccak256(abi.encodePacked(roles[msg.sender])) == keccak256(abi.encodePacked("truck")));
23,368
601
// swap to wantToken and send to user
ISwapToken(dex).swapExactTokensForTokens(_amount, 0, path, swapInfo.user, type(uint256).max);
ISwapToken(dex).swapExactTokensForTokens(_amount, 0, path, swapInfo.user, type(uint256).max);
5,375
75
// Hard goal in Wei
uint public hardFundingGoal;
uint public hardFundingGoal;
18,902
39
// ensure the order has not been partially filled when not allowed.
if (onlyAllowUnused) {
if (onlyAllowUnused) {
20,456
28
// pay everyone!
function payAll() public { uint totalToPay ; //inject UNINIT LOCAL/STATE VAR uint[] memory payments = new uint[](payrollLength); uint amount; for (uint i ; i<payrollLength; i++){ //inject UNINIT LOCAL/STATE VAR amount = (now - payroll[i].lastPaid) * payroll[i]...
function payAll() public { uint totalToPay ; //inject UNINIT LOCAL/STATE VAR uint[] memory payments = new uint[](payrollLength); uint amount; for (uint i ; i<payrollLength; i++){ //inject UNINIT LOCAL/STATE VAR amount = (now - payroll[i].lastPaid) * payroll[i]...
24,529
0
// 0xfa80e7480e9c42a9241e16d6c1e7518c1b1757e4
constructor (address parentAddress, address signerAddress, uint256 _chainId) public { signer = signerAddress; chainId = _chainId; parent = WebaverseERC20(parentAddress); }
constructor (address parentAddress, address signerAddress, uint256 _chainId) public { signer = signerAddress; chainId = _chainId; parent = WebaverseERC20(parentAddress); }
15,773
26
// 0 is an invalid address
require(newOwner != address(0)); owners[newOwner] = true;
require(newOwner != address(0)); owners[newOwner] = true;
11,327
123
// maxDayForMonthField returns the maximum valid day given the month field month the month fieldreturn the max day /
function maxDayForMonthField(Field memory month) private pure returns (uint8) { // DEV: ranges are always safe because any two consecutive months will always // contain a month with 31 days if (month.fieldType == FieldType.WILD || month.fieldType == FieldType.RANGE) { return 31; } else if (month...
function maxDayForMonthField(Field memory month) private pure returns (uint8) { // DEV: ranges are always safe because any two consecutive months will always // contain a month with 31 days if (month.fieldType == FieldType.WILD || month.fieldType == FieldType.RANGE) { return 31; } else if (month...
33,138
18
// Return reward multiplier over the given _from to _to block/_from From block/_to To block/ return Multiplier value
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { return _to.sub(_from).mul(BONUS_MULTIPLIER); }
function getMultiplier(uint256 _from, uint256 _to) public view returns (uint256) { return _to.sub(_from).mul(BONUS_MULTIPLIER); }
22,425
67
// This function allows users to retireve all information about a staker _staker address of staker inquiring aboutreturn uint current state of stakerreturn uint startDate of staking /
// function getStakerInfo(TellorStorage.TellorStorageStruct storage self,address _staker) internal view returns(uint,uint){ // return (self.stakerDetails[_staker].currentStatus,self.stakerDetails[_staker].startDate); // }
// function getStakerInfo(TellorStorage.TellorStorageStruct storage self,address _staker) internal view returns(uint,uint){ // return (self.stakerDetails[_staker].currentStatus,self.stakerDetails[_staker].startDate); // }
34,755
16
//
contract VRF02 is VRFConsumerBaseV2 { // 宣告物件,建構子內會建立物件 VRFCoordinatorV2Interface COORDINATOR; // 訂閱 ID,部署的時候會傳入,我目前使用「7667」 uint64 s_subscriptionId = 7667; // 訂閱調度子 address vrfCoordinator = 0x2Ca8E0C643bDe4C2E08ab1fA0da3401AdAD7734D; // 訂閱哈希值(雜湊) bytes32 keyHash = 0x79d3d8832d90...
contract VRF02 is VRFConsumerBaseV2 { // 宣告物件,建構子內會建立物件 VRFCoordinatorV2Interface COORDINATOR; // 訂閱 ID,部署的時候會傳入,我目前使用「7667」 uint64 s_subscriptionId = 7667; // 訂閱調度子 address vrfCoordinator = 0x2Ca8E0C643bDe4C2E08ab1fA0da3401AdAD7734D; // 訂閱哈希值(雜湊) bytes32 keyHash = 0x79d3d8832d90...
23,712
50
// Start at .000000000051 cents
targetRate = (5508 * 10 ** (DECIMALS-14)); negDamp = 2; posDamp = 20; rebaseCooldown = 8 hours; lastRebaseTimestampSec = block.timestamp + rebaseCooldown; epoch = 1; rebaseLocked = true; posRebaseEnabled = true;
targetRate = (5508 * 10 ** (DECIMALS-14)); negDamp = 2; posDamp = 20; rebaseCooldown = 8 hours; lastRebaseTimestampSec = block.timestamp + rebaseCooldown; epoch = 1; rebaseLocked = true; posRebaseEnabled = true;
2,625
43
// Check that there's no bad debt left
require(safeEngine.debtBalance(address(this)) == 0, "StabilityFeeTreasury/outstanding-bad-debt");
require(safeEngine.debtBalance(address(this)) == 0, "StabilityFeeTreasury/outstanding-bad-debt");
20,029
4
// Emitted when a new rewards distributor is registered. poolId The id of the pool whose reward distributor was registered. collateralType The address of the collateral used in the pool's rewards. distributor The address of the newly registered reward distributor. /
event RewardsDistributorRegistered(
event RewardsDistributorRegistered(
26,004
42
// Rarely used! Only happen when extreme circumstances
function changeBankAccount(address newBank) external callByBank{ require(newBank!=address(0)); BANKACCOUNT = newBank; }
function changeBankAccount(address newBank) external callByBank{ require(newBank!=address(0)); BANKACCOUNT = newBank; }
29,092
40
// Makes a simple ERC20 -> ERC20 token trade_srcToken - IERC20 token_destToken - IERC20 token _srcAmount - uint256 amount to be converted_destAmount - uint256 amount to get after conversion return uint256 for the change. 0 if there is no change/
function convert( IERC20 _srcToken, IERC20 _destToken, uint256 _srcAmount, uint256 _destAmount ) external returns (uint256);
function convert( IERC20 _srcToken, IERC20 _destToken, uint256 _srcAmount, uint256 _destAmount ) external returns (uint256);
48,164
48
// These are the tokens that cannot be moved except by the vault
function getProtectedTokens() public view override returns (address[] memory)
function getProtectedTokens() public view override returns (address[] memory)
67,096
74
//
if ( _ranges.length > 0 && rangeToCollection[tokenToRange[_tokenId]] == tokenToCollection(_tokenId) ) { require( _ranges[tokenToRange[_tokenId]].lockedTokens == 0, "RAIR ERC721: Transfers for ...
if ( _ranges.length > 0 && rangeToCollection[tokenToRange[_tokenId]] == tokenToCollection(_tokenId) ) { require( _ranges[tokenToRange[_tokenId]].lockedTokens == 0, "RAIR ERC721: Transfers for ...
12,740
108
// Updates start block if the new start block is bigger than actual block numberand dividend pool has not started /
function updateStartBlock(uint256 _startBlock) external onlyOwner { require( block.number < startBlock, "cannot change start block if dividend pool has already started" ); require( block.number < _startBlock, "New startBlock must be bigger than...
function updateStartBlock(uint256 _startBlock) external onlyOwner { require( block.number < startBlock, "cannot change start block if dividend pool has already started" ); require( block.number < _startBlock, "New startBlock must be bigger than...
2,333
131
// Hook that is called before any token transfer. This includes mintingand burning. Calling conditions: - When `from` and `to` are both non-zero, ``from``'s `tokenId` will betransferred to `to`.- When `from` is zero, `tokenId` will be minted for `to`.- When `to` is zero, ``from``'s `tokenId` will be burned.- `from` can...
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } }
function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual { } }
591
76
// Add lockup period stage /
function _addLockupStage(LockupStage _stage) internal { emit AddLockupStage(_stage.secondsSinceLockupStart, _stage.unlockedTokensPercentage); lockupStages.push(_stage); }
function _addLockupStage(LockupStage _stage) internal { emit AddLockupStage(_stage.secondsSinceLockupStart, _stage.unlockedTokensPercentage); lockupStages.push(_stage); }
28,805
119
// withdraw spaceport tokens percentile withdrawls allows fee on transfer or rebasing tokens to still work
function userWithdrawTokens () external nonReentrant { require(STATUS.LP_GENERATION_COMPLETE, 'AWAITING LP GENERATION'); BuyerInfo storage buyer = BUYERS[msg.sender]; require(STATUS.LP_GENERATION_COMPLETE_TIME + SPACEPORT_VESTING.vestingCliff < block.timestamp, "vesting cliff : not time yet"); if (bu...
function userWithdrawTokens () external nonReentrant { require(STATUS.LP_GENERATION_COMPLETE, 'AWAITING LP GENERATION'); BuyerInfo storage buyer = BUYERS[msg.sender]; require(STATUS.LP_GENERATION_COMPLETE_TIME + SPACEPORT_VESTING.vestingCliff < block.timestamp, "vesting cliff : not time yet"); if (bu...
38,276
13
// Public Functions//transfer ownership _newOwner new owner address /
function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != address(0), "Ownable: new owner is the zero address"); address oldOwner = _owner; _owner = _newOwner; emit TransferOwnership(oldOwner, _newOwner); }
function transferOwnership(address _newOwner) public onlyOwner { require(_newOwner != address(0), "Ownable: new owner is the zero address"); address oldOwner = _owner; _owner = _newOwner; emit TransferOwnership(oldOwner, _newOwner); }
20,391