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 |
|---|---|---|---|---|
2 | // Validators hub contract object. | voteNvalidate public validatorsHub;
| voteNvalidate public validatorsHub;
| 44,324 |
91 | // Token Id to image hash | mapping(uint256 => string) private _tokenImageHashes;
| mapping(uint256 => string) private _tokenImageHashes;
| 10,419 |
2 | // Constructor that gives msg.sender all of existing tokens./ | constructor(
string memory name,
string memory symbol,
uint256 initialSupply
| constructor(
string memory name,
string memory symbol,
uint256 initialSupply
| 13,283 |
85 | // Refuse any incoming ETH value with calls | fallback() external payable {
revert("Do not send ETH with your call");
}
| fallback() external payable {
revert("Do not send ETH with your call");
}
| 769 |
5 | // Inspired by Curve's Gauge | uint256 veBoostedLpBalance = (lpBalance * TOKENLESS_PRODUCTION) / 100;
if (vePendleSupply > 0) {
veBoostedLpBalance +=
(((_totalStaked() * vePendleBalance) / vePendleSupply) *
(100 - TOKENLESS_PRODUCTION)) /
100;
}
| uint256 veBoostedLpBalance = (lpBalance * TOKENLESS_PRODUCTION) / 100;
if (vePendleSupply > 0) {
veBoostedLpBalance +=
(((_totalStaked() * vePendleBalance) / vePendleSupply) *
(100 - TOKENLESS_PRODUCTION)) /
100;
}
| 7,189 |
10 | // Emitted when asset has been withdrawn | event Exit(address dst, uint256 value);
constructor(
address _ledger,
address _asset,
uint256 _wrapped
) {
auth[msg.sender] = 1;
live = 1;
ledger = LedgerLike(_ledger);
| event Exit(address dst, uint256 value);
constructor(
address _ledger,
address _asset,
uint256 _wrapped
) {
auth[msg.sender] = 1;
live = 1;
ledger = LedgerLike(_ledger);
| 459 |
30 | // } if (bytes(endorsementParams.distributorSensitiveData).length != 0) { | allPolicies[endorsementParams.onChainPolicyId].distributorSensitiveData = endorsementParams
.distributorSensitiveData;
| allPolicies[endorsementParams.onChainPolicyId].distributorSensitiveData = endorsementParams
.distributorSensitiveData;
| 14,060 |
29 | // Ensure `_who` is a participant. | modifier only_participants(address _who) { if (participants[_who] != 0) _; else throw; }
| modifier only_participants(address _who) { if (participants[_who] != 0) _; else throw; }
| 38,200 |
81 | // Address of the sdToken minter contract. | address public immutable minter;
| address public immutable minter;
| 29,541 |
72 | // 1. Check that reserves and balances are consistent (within 1%) | (uint256 r0, uint256 r1,) = lp.getReserves();
uint256 t0bal = token0.balanceOf(address(lp));
uint256 t1bal = token1.balanceOf(address(lp));
require(t0bal.mul(100) <= r0.mul(101), "bad t0 balance");
require(t1bal.mul(100) <= r1.mul(101), "bad t1 balance");
| (uint256 r0, uint256 r1,) = lp.getReserves();
uint256 t0bal = token0.balanceOf(address(lp));
uint256 t1bal = token1.balanceOf(address(lp));
require(t0bal.mul(100) <= r0.mul(101), "bad t0 balance");
require(t1bal.mul(100) <= r1.mul(101), "bad t1 balance");
| 15,005 |
366 | // ComptrollerCore Storage for the comptroller is at this address, while execution is delegated to the `comptrollerImplementation`.CTokens should reference this contract as their comptroller. / | contract Unitroller is UnitrollerAdminStorage, ComptrollerErrorReporter {
/**
* @notice Emitted when pendingComptrollerImplementation is changed
*/
event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);
/**
* @notice Emitted when pendingComptr... | contract Unitroller is UnitrollerAdminStorage, ComptrollerErrorReporter {
/**
* @notice Emitted when pendingComptrollerImplementation is changed
*/
event NewPendingImplementation(address oldPendingImplementation, address newPendingImplementation);
/**
* @notice Emitted when pendingComptr... | 25,995 |
2 | // The EIP-712 typehash for the permit struct used by the contract | bytes32 public constant CLAIM_TYPEHASH = keccak256("Claim(address account,uint256 amount,uint256 nonce,uint256 deadline)");
| bytes32 public constant CLAIM_TYPEHASH = keccak256("Claim(address account,uint256 amount,uint256 nonce,uint256 deadline)");
| 19,073 |
15 | // Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0/a The multiplicand/b The multiplier/denominator The divisor/ return result The 256-bit result | function mulDivRoundingUp(
uint256 a,
uint256 b,
uint256 denominator
| function mulDivRoundingUp(
uint256 a,
uint256 b,
uint256 denominator
| 26,633 |
32 | // Returns applications lengthtoken Token address/ | function getTokenAppsLength(address token) public view returns (uint) {
return tokenApps[token].length;
}
| function getTokenAppsLength(address token) public view returns (uint) {
return tokenApps[token].length;
}
| 11,319 |
52 | // Overrides ERC20._burn in order for burn and burnFrom to emitan additional Burn event. / | function _burn(address who, uint256 value) internal {
super._burn(who, value);
}
| function _burn(address who, uint256 value) internal {
super._burn(who, value);
}
| 2,892 |
6 | // Address which will exercise Man over the network i.e. add tokens, change validator set, conduct upgrades | address public networkGovernor;
| address public networkGovernor;
| 10,916 |
13 | // | interface IBEP20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the token decimals.
*/
function decimals() external view returns (uint8);
/**
* @dev Returns the token symbol.
*/
... | interface IBEP20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the token decimals.
*/
function decimals() external view returns (uint8);
/**
* @dev Returns the token symbol.
*/
... | 15,910 |
0 | // The XERC20 token of this contract / | IXERC20 public immutable XERC20;
| IXERC20 public immutable XERC20;
| 25,053 |
195 | // Reimburse transmitter of the report for gas usage | require(txOracle.role == Role.Transmitter,
"sent by undesignated transmitter"
);
uint256 gasPrice = impliedGasPrice(
tx.gasprice / (1 gwei), // convert to ETH-gwei units
billing.reasonableGasPrice,
billing.maximumGasPrice
);
| require(txOracle.role == Role.Transmitter,
"sent by undesignated transmitter"
);
uint256 gasPrice = impliedGasPrice(
tx.gasprice / (1 gwei), // convert to ETH-gwei units
billing.reasonableGasPrice,
billing.maximumGasPrice
);
| 3,016 |
85 | // Moves `value` AnyswapV3ERC20 token from caller's account to account (`to`)./ A transfer to `address(0)` triggers an ETH withdraw matching the sent AnyswapV3ERC20 token in favor of caller. | /// Emits {Transfer} event.
/// Returns boolean value indicating whether operation succeeded.
/// Requirements:
/// - caller account must have at least `value` AnyswapV3ERC20 token.
function transfer(address to, uint256 value) external override returns (bool) {
require(to != address(0) || ... | /// Emits {Transfer} event.
/// Returns boolean value indicating whether operation succeeded.
/// Requirements:
/// - caller account must have at least `value` AnyswapV3ERC20 token.
function transfer(address to, uint256 value) external override returns (bool) {
require(to != address(0) || ... | 7,915 |
3,876 | // 1940 | entry "benthically" : ENG_ADVERB
| entry "benthically" : ENG_ADVERB
| 22,776 |
78 | // Internal pure function to efficiently derive an digest to sign for an order in accordance with EIP-712.domainSeparator The domain separator. orderHash The order hash. return value The hash. / | function _deriveEIP712Digest(bytes32 domainSeparator, bytes32 orderHash)
internal
pure
returns (bytes32 value)
| function _deriveEIP712Digest(bytes32 domainSeparator, bytes32 orderHash)
internal
pure
returns (bytes32 value)
| 32,837 |
8 | // Add list of grants in batch. _recipients list of addresses of the stakeholders _amounts list of amounts to be assigned to the stakeholders / | function addTokenGrants(
address[] memory _recipients,
uint256[] memory _amounts
| function addTokenGrants(
address[] memory _recipients,
uint256[] memory _amounts
| 33,886 |
539 | // Vaults for fees This mapping holds balances of relayers and affiliates fees to withdraw balances[feeRecipientAddress][tokenAddress] => balances | mapping (address => mapping (address => uint256)) public balances;
| mapping (address => mapping (address => uint256)) public balances;
| 47,232 |
2 | // return the symbol of the token. / | function symbol() public view returns(string) {
return _symbol;
}
| function symbol() public view returns(string) {
return _symbol;
}
| 694 |
57 | // As opposed to {transferFrom}, this imposes no restrictions on msg.sender.from current owner of the tokento address to receive the ownership of the given token IDtokenId uint256 ID of the token to be transferred/ | function _transferFrom(address from, address to, uint256 tokenId) internal {
require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_clearApproval(tokenId);
_ownedTokensCount[from].decrement();
... | function _transferFrom(address from, address to, uint256 tokenId) internal {
require(ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_clearApproval(tokenId);
_ownedTokensCount[from].decrement();
... | 5,324 |
23 | // Actions / | function execute() public returns (bool) {
return txnRequest.execute();
}
| function execute() public returns (bool) {
return txnRequest.execute();
}
| 10,835 |
1 | // Constructor | constructor() ERC20('Dai Stablecoin', 'DAI'){}
// Functions
function faucet(address _recipient, uint256 _amount) external{
_mint(_recipient, _amount);
}
| constructor() ERC20('Dai Stablecoin', 'DAI'){}
// Functions
function faucet(address _recipient, uint256 _amount) external{
_mint(_recipient, _amount);
}
| 7,396 |
28 | // fees added when using Erc20/Eth conversion batch functions _batchConversionFee between 0 and 10000, i.e: batchFee = 50 represent 0.50% of fees / | function setBatchConversionFee(uint256 _batchConversionFee) external onlyOwner {
batchConversionFee = _batchConversionFee;
}
| function setBatchConversionFee(uint256 _batchConversionFee) external onlyOwner {
batchConversionFee = _batchConversionFee;
}
| 4,232 |
3 | // De-serializes kosu order data to 0x order and checks validity./ | function isValid(bytes calldata data) external view returns (bool) {
LibOrder.Order memory order = _getOrder(data);
LibOrder.OrderInfo memory info = _exchange.getOrderInfo(order);
return info.orderStatus == uint8(LibOrder.OrderStatus.FILLABLE);
}
| function isValid(bytes calldata data) external view returns (bool) {
LibOrder.Order memory order = _getOrder(data);
LibOrder.OrderInfo memory info = _exchange.getOrderInfo(order);
return info.orderStatus == uint8(LibOrder.OrderStatus.FILLABLE);
}
| 40,175 |
0 | // The current price for any given type (int) / | mapping(uint => uint256) public currentTypePrice;
| mapping(uint => uint256) public currentTypePrice;
| 36,976 |
18 | // portfolio value is not 0 | require(_porfolioValue > 0, "Portfolio is too small");
| require(_porfolioValue > 0, "Portfolio is too small");
| 12,125 |
41 | // Update fixed percentage farm allocations | for (uint256 index = 0; index < numberOfFixedPercentFarms; index++) {
FixedPercentFarmInfo memory fixedPercentFarm = getFixedPercentFarmFromPid[fixedPercentFarmPids[index]];
uint256 newFixedPercentFarmAllocation = allotedFixedPercentFarmAllocation.mul(fixedPercentFarm.allocationPercent).... | for (uint256 index = 0; index < numberOfFixedPercentFarms; index++) {
FixedPercentFarmInfo memory fixedPercentFarm = getFixedPercentFarmFromPid[fixedPercentFarmPids[index]];
uint256 newFixedPercentFarmAllocation = allotedFixedPercentFarmAllocation.mul(fixedPercentFarm.allocationPercent).... | 35,494 |
5 | // For test purpose. | function mint(uint256 amount_) external {
_mint(msg.sender, amount_);
}
| function mint(uint256 amount_) external {
_mint(msg.sender, amount_);
}
| 29,019 |
239 | // Update avg price and/or userNoFeeQty | _updateUserFeeInfo(msg.sender, mintedTokens, idlePrice);
| _updateUserFeeInfo(msg.sender, mintedTokens, idlePrice);
| 41,642 |
23 | // Call Transfer event | Transfer(_from, _to, _value);
| Transfer(_from, _to, _value);
| 51,175 |
32 | // A The input array to search a The address to remove return Returns the array with the object removed. / | function remove(address[] memory A, address a)
internal
pure
returns (address[] memory)
| function remove(address[] memory A, address a)
internal
pure
returns (address[] memory)
| 10,538 |
5 | // ---------------------------------------------------------------------------------------------- Original from: https:theethereum.wiki/w/index.php/ERC20_Token_Standard (c) BokkyPooBah 2017. The MIT Licence. ---------------------------------------------------------------------------------------------- ERC Token Standar... | contract ERC20Interface {
// Get the total token supply function totalSupply() constant returns (uint256 totalSupply);
// Get the account balance of another account with address _owner
function balanceOf(address _owner) constant public returns (uint256 balance);
// Send _value amount of tokens to ... | contract ERC20Interface {
// Get the total token supply function totalSupply() constant returns (uint256 totalSupply);
// Get the account balance of another account with address _owner
function balanceOf(address _owner) constant public returns (uint256 balance);
// Send _value amount of tokens to ... | 60,328 |
187 | // getVotingProxy(): returns _point&39;s current voting proxy | function getVotingProxy(uint32 _point)
view
external
returns (address voter)
| function getVotingProxy(uint32 _point)
view
external
returns (address voter)
| 38,514 |
13 | // before token transfer logic/ | function _beforeTokenTransfer(
address from,
address to,
uint256 amount
| function _beforeTokenTransfer(
address from,
address to,
uint256 amount
| 27,539 |
2 | // Check if metadata is null | if (bytes(_NftAnimation[tokenId].name).length == 0 && bytes(_NftAnimation[tokenId].animationUrl).length == 0) {
| if (bytes(_NftAnimation[tokenId].name).length == 0 && bytes(_NftAnimation[tokenId].animationUrl).length == 0) {
| 25,612 |
14 | // 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);
}
| 31,725 |
5 | // Returns true if specified address has list owner permissions./_address is the address to check for list owner permissions. | function isListOwner(address _address) public view returns (bool) {
return listOwners[_address];
}
| function isListOwner(address _address) public view returns (bool) {
return listOwners[_address];
}
| 23,688 |
135 | // calculate current bond premium return price_ uint / | function bondPrice() public view returns ( uint price_ ) {
price_ = terms.controlVariable.mul( debtRatio() ).add( 1000000000 ).div( 1e7 );
if ( price_ < terms.minimumPrice ) {
price_ = terms.minimumPrice;
}
}
| function bondPrice() public view returns ( uint price_ ) {
price_ = terms.controlVariable.mul( debtRatio() ).add( 1000000000 ).div( 1e7 );
if ( price_ < terms.minimumPrice ) {
price_ = terms.minimumPrice;
}
}
| 6,243 |
526 | // leave enough funds to service any pending transmutations | uint256 totalFunds = IERC20Burnable(Token).balanceOf(address(this));
uint256 migratableFunds = totalFunds.sub(totalSupplyWaTokens, "not enough funds to service stakes");
IERC20Burnable(Token).approve(migrateTo, migratableFunds);
ITransmuter(migrateTo).distribute(address(this), migratable... | uint256 totalFunds = IERC20Burnable(Token).balanceOf(address(this));
uint256 migratableFunds = totalFunds.sub(totalSupplyWaTokens, "not enough funds to service stakes");
IERC20Burnable(Token).approve(migrateTo, migratableFunds);
ITransmuter(migrateTo).distribute(address(this), migratable... | 16,639 |
15 | // Validates the UserOperation based on its rules. userOp UserOperation to validate. helperData Unusedreturn sigTimeRange Valid Time Range of the signature. / | function authenticateUserOp(UserOperation calldata userOp, bytes32, bytes memory) external view override returns (uint256 sigTimeRange) {
(address target, uint256 value, bytes memory data, UserOperationFee memory _feedata, bool feeExists) = DataLib.getCallData(userOp.callData);
if (feeExists) {
return isValidAc... | function authenticateUserOp(UserOperation calldata userOp, bytes32, bytes memory) external view override returns (uint256 sigTimeRange) {
(address target, uint256 value, bytes memory data, UserOperationFee memory _feedata, bool feeExists) = DataLib.getCallData(userOp.callData);
if (feeExists) {
return isValidAc... | 9,806 |
67 | // call 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 _tokenContract, bytes _extraData)it is assumed when one does this that the call... | require(_spender.call(bytes4(bytes32(keccak256("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData));
return true;
| require(_spender.call(bytes4(bytes32(keccak256("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData));
return true;
| 623 |
85 | // Holds ownership functionality such as transferring. | contract BurnupGameOwnership is BurnupGameBase {
event Transfer(address indexed from, address indexed to, uint256 indexed deedId);
/// @notice Name of the collection of deeds (non-fungible token), as defined in ERC721Metadata.
function name() public pure returns (string _deedName) {
_deedN... | contract BurnupGameOwnership is BurnupGameBase {
event Transfer(address indexed from, address indexed to, uint256 indexed deedId);
/// @notice Name of the collection of deeds (non-fungible token), as defined in ERC721Metadata.
function name() public pure returns (string _deedName) {
_deedN... | 12,566 |
132 | // Updates chain ids of used networks _sourceChainId chain id for current network _destinationChainId chain id for opposite network / | function setChainIds(uint256 _sourceChainId, uint256 _destinationChainId) external onlyOwner {
_setChainIds(_sourceChainId, _destinationChainId);
}
| function setChainIds(uint256 _sourceChainId, uint256 _destinationChainId) external onlyOwner {
_setChainIds(_sourceChainId, _destinationChainId);
}
| 50,208 |
30 | // This provides addresses to deployed FMint modules and related contracts cooperating on the FMint protocol. It's used to connects different modules to make the whole FMint protocol live and work. version 0.1.0 license MIT author Fantom Foundation, Jiri Malek/ | contract FantomMintAddressProvider is Ownable, IFantomMintAddressProvider {
// ----------------------------------------------
// Module identifiers used by the address storage
// ----------------------------------------------
//
bytes32 private constant MOD_FANTOM_MINT = "fantom_mint";
bytes32 private constant M... | contract FantomMintAddressProvider is Ownable, IFantomMintAddressProvider {
// ----------------------------------------------
// Module identifiers used by the address storage
// ----------------------------------------------
//
bytes32 private constant MOD_FANTOM_MINT = "fantom_mint";
bytes32 private constant M... | 39,879 |
68 | // The actual amount of tokens that will be transferred must be > 0 | require(added_deposit > 0);
| require(added_deposit > 0);
| 68,197 |
9 | // The wallet to transfer proceeds to | address public sellerWallet;
| address public sellerWallet;
| 33,143 |
94 | // Lower the amount of pTokens | _totalBalancePTokens = _totalBalancePTokens.sub(pTokenAmount);
| _totalBalancePTokens = _totalBalancePTokens.sub(pTokenAmount);
| 79,134 |
2 | // variable borrow index. Expressed in ray | uint128 variableBorrowIndex;
| uint128 variableBorrowIndex;
| 10,000 |
4 | // ========== Virtual functions ========== // ========== Public/External functions ========== // _amount is the total amount the user wants to send including the Bonder fee SendhTokens to another supported layer-2 or to layer-1 to be redeemed for the underlying asset. chainId The chainId of the destination chain recipi... | function send(
uint256 chainId,
address recipient,
uint256 amount,
uint256 bonderFee,
uint256 amountOutMin,
uint256 deadline
)
external
| function send(
uint256 chainId,
address recipient,
uint256 amount,
uint256 bonderFee,
uint256 amountOutMin,
uint256 deadline
)
external
| 9,741 |
36 | // Set admin address Callable by owner / | function setAdmin(address _adminAddress) external onlyOwner {
require(_adminAddress != address(0), "Cannot be zero address");
adminAddress = _adminAddress;
emit NewAdminAddress(_adminAddress);
}
| function setAdmin(address _adminAddress) external onlyOwner {
require(_adminAddress != address(0), "Cannot be zero address");
adminAddress = _adminAddress;
emit NewAdminAddress(_adminAddress);
}
| 14,675 |
85 | // In this case user needs to send more ETH than a estimated value, then contract will send back the rest | wethToken.deposit.value(msg.value)();
if (wethToken.allowance(this, otc) < msg.value) {
wethToken.approve(otc, uint(-1));
}
| wethToken.deposit.value(msg.value)();
if (wethToken.allowance(this, otc) < msg.value) {
wethToken.approve(otc, uint(-1));
}
| 36,818 |
38 | // And then we finally add it to the variable tracking the total amount spent to maintain invariance. | totalPayouts += payoutDiff;
| totalPayouts += payoutDiff;
| 44,617 |
15 | // Change the contract name to your token name | contract VestoToken {
// Name your custom token
string public constant name = "VESTO TOKEN";
// Name your custom token symbol
string public constant symbol = "VESTO";
uint8 public constant decimals = 18;
// Contract owner will be your Link account
address public owner;
address public... | contract VestoToken {
// Name your custom token
string public constant name = "VESTO TOKEN";
// Name your custom token symbol
string public constant symbol = "VESTO";
uint8 public constant decimals = 18;
// Contract owner will be your Link account
address public owner;
address public... | 2,359 |
24 | // emit that a contract was created | emit NFTPurchaseCreated(expirationTime, collectionAddress, nftId, cost, buyerAddress, transactions.length - 1);
| emit NFTPurchaseCreated(expirationTime, collectionAddress, nftId, cost, buyerAddress, transactions.length - 1);
| 54,266 |
4 | // Set new address that can set the gas price/Only callable by owner/_newOracle Address of new oracle admin | function setOracle(address _newOracle) external;
| function setOracle(address _newOracle) external;
| 11,648 |
11 | // get owner of a bounty by the index of bounty/bountyId the index of bounty/ return owner of a bounty | function getOwner(uint bountyId) public view returns (address) {
Bounty storage bounty = allBounties[bountyId];
return bounty.owner;
}
| function getOwner(uint bountyId) public view returns (address) {
Bounty storage bounty = allBounties[bountyId];
return bounty.owner;
}
| 38,926 |
170 | // Can't send more than sender has Remove require for gas optimization - bsub will revert on underflow require(_balance[sender] >= amount, "ERR_INSUFFICIENT_BAL"); |
_balance[sender] = BalancerSafeMath.bsub(_balance[sender], amount);
_balance[recipient] = BalancerSafeMath.badd(
_balance[recipient],
amount
);
emit Transfer(sender, recipient, amount);
|
_balance[sender] = BalancerSafeMath.bsub(_balance[sender], amount);
_balance[recipient] = BalancerSafeMath.badd(
_balance[recipient],
amount
);
emit Transfer(sender, recipient, amount);
| 6,338 |
229 | // decimals | uint res1 = Res1*(10**token0.decimals());
uint ethPrice = ((10e18*res1)/Res0); // return amount of ETH needed to buy KPET
uint amountTokens = (_amountETH*10e18)/ethPrice;
return amountTokens;
| uint res1 = Res1*(10**token0.decimals());
uint ethPrice = ((10e18*res1)/Res0); // return amount of ETH needed to buy KPET
uint amountTokens = (_amountETH*10e18)/ethPrice;
return amountTokens;
| 49,593 |
27 | // Unfreeze tokens | token.freeze(false);
| token.freeze(false);
| 25,399 |
7 | // 포니 가격을 리턴 (최근 판매된 다섯개의 평균 가격) | function averageGen0SalePrice()
external
view
returns (uint256)
| function averageGen0SalePrice()
external
view
returns (uint256)
| 25,128 |
41 | // Get a glasses image bytes (RLE-encoded). / | function glasses(uint256 index) public view override returns (bytes memory) {
return imageByIndex(glassesTrait, index);
}
| function glasses(uint256 index) public view override returns (bytes memory) {
return imageByIndex(glassesTrait, index);
}
| 31,627 |
50 | // Sets the publication fee that's charged to users to publish items_publicationFee - Fee amount in wei this contract charges to publish an item/ | function setPublicationFee(uint256 _publicationFee) external onlyOwner {
publicationFeeInWei = _publicationFee;
emit ChangedPublicationFee(publicationFeeInWei);
}
| function setPublicationFee(uint256 _publicationFee) external onlyOwner {
publicationFeeInWei = _publicationFee;
emit ChangedPublicationFee(publicationFeeInWei);
}
| 20,129 |
16 | // Trigger the call from the owner and revert if success is not returned. | (success, returnData) = owner.triggerCall(recipient, amount, data);
require(success, "Triggered call did not return successfully.");
| (success, returnData) = owner.triggerCall(recipient, amount, data);
require(success, "Triggered call did not return successfully.");
| 16,743 |
13 | // Send bytes message to Child Tunnel message bytes message that will be sent to Child Tunnelsome message examples -abi.encode(tokenId);abi.encode(tokenId, tokenMetadata);abi.encode(messageType, messageData); / | function _sendMessageToChild(bytes memory message) internal {
fxRoot.sendMessageToChild(fxChildTunnel, message);
}
| function _sendMessageToChild(bytes memory message) internal {
fxRoot.sendMessageToChild(fxChildTunnel, message);
}
| 24,734 |
240 | // Since the number of warriors is capped to '1 000 000' we can't overflow this | ownersTokenCount[_to]++;
| ownersTokenCount[_to]++;
| 66,283 |
193 | // calculate the portions of the liquidity to add to wallet1fee | uint256 wallet1feeBalance = newBalance.div(totalFees).mul(wallet1Fee);
uint256 wallet1feePortion = otherHalf.div(totalFees).mul(wallet1Fee);
| uint256 wallet1feeBalance = newBalance.div(totalFees).mul(wallet1Fee);
uint256 wallet1feePortion = otherHalf.div(totalFees).mul(wallet1Fee);
| 76,449 |
23 | // Fee is calculated by using 5% of gift value (x). And the amount (y) that is sent to the contract is x + 5% of x. | uint256 fee = value * 5 / 105;
uint256 oneMetis = 1_000_000_000_000_000_000;
if (fee > oneMetis) {
fee = oneMetis;
}
| uint256 fee = value * 5 / 105;
uint256 oneMetis = 1_000_000_000_000_000_000;
if (fee > oneMetis) {
fee = oneMetis;
}
| 7,873 |
595 | // res += val(coefficients[264] + coefficients[265]adjustments[19]). | res := addmod(res,
mulmod(val,
add(/*coefficients[264]*/ mload(0x2540),
mulmod(/*coefficients[265]*/ mload(0x2560),
| res := addmod(res,
mulmod(val,
add(/*coefficients[264]*/ mload(0x2540),
mulmod(/*coefficients[265]*/ mload(0x2560),
| 20,879 |
21 | // token => totalStakedAmount | mapping(address => uint) public totalStakedAmount;
address public dividendContract;
function updateUserData(address _token, address user, uint d_T, uint d_E, uint s_A, uint t_T, uint t_E) public returns(bool)
| mapping(address => uint) public totalStakedAmount;
address public dividendContract;
function updateUserData(address _token, address user, uint d_T, uint d_E, uint s_A, uint t_T, uint t_E) public returns(bool)
| 3,158 |
7 | // If mint permissions have been set for an extension (extensions can mint by default),check if an extension can mint via the permission contract's approveMint function. / | function _checkMintPermissions(address to, uint256 tokenId) internal {
if (_extensionPermissions[msg.sender] != address(0)) {
IERC721CreatorMintPermissions(_extensionPermissions[msg.sender]).approveMint(msg.sender, to, tokenId);
}
}
| function _checkMintPermissions(address to, uint256 tokenId) internal {
if (_extensionPermissions[msg.sender] != address(0)) {
IERC721CreatorMintPermissions(_extensionPermissions[msg.sender]).approveMint(msg.sender, to, tokenId);
}
}
| 36,998 |
7 | // The fulfill method from requests created by this contract The recordChainlinkFulfillment protects this function from being calledby anyone other than the oracle address that the request was sent to _requestId The ID that was generated for the request _data The answer provided by the oracle / | function fulfill(bytes32 _requestId, uint256 _data)
public
recordChainlinkFulfillment(_requestId)
| function fulfill(bytes32 _requestId, uint256 _data)
public
recordChainlinkFulfillment(_requestId)
| 43,378 |
20 | // Withdraw (alice & bob) | alice.withdraw(30 ether);
bob.withdraw(30 ether);
assertEq(token.balanceOf(address(alice)), 45 ether);
assertEq(token.balanceOf(address(bob)), 45 ether);
assertEq(token.balanceOf(address(vault)), 0 ether);
assertEq(vault.balanceOf(address(alice)), 0 ether);
assert... | alice.withdraw(30 ether);
bob.withdraw(30 ether);
assertEq(token.balanceOf(address(alice)), 45 ether);
assertEq(token.balanceOf(address(bob)), 45 ether);
assertEq(token.balanceOf(address(vault)), 0 ether);
assertEq(vault.balanceOf(address(alice)), 0 ether);
assert... | 3,250 |
44 | // Cannot withdraw more than pool's balance | require(
pool.totalLp >= amount,
"emergency withdraw: pool total not enough"
);
user.amount = 0;
user.rewardDebt = 0;
user.rewardLockedUp = 0;
user.nextHarvestUntil = 0;
pool.totalLp -= amount;
| require(
pool.totalLp >= amount,
"emergency withdraw: pool total not enough"
);
user.amount = 0;
user.rewardDebt = 0;
user.rewardLockedUp = 0;
user.nextHarvestUntil = 0;
pool.totalLp -= amount;
| 17,587 |
98 | // `hat` address is unique root user (has every role) and the unique owner of role 0 (typically 'sys' or 'internal') | contract DSChief is DSRoles, DSChiefApprovals {
function DSChief(DSToken GOV, DSToken IOU, uint MAX_YAYS)
DSChiefApprovals (GOV, IOU, MAX_YAYS)
public
{
authority = this;
owner = 0;
}
function setOwner(address owner_) public {
owner_;
revert();
... | contract DSChief is DSRoles, DSChiefApprovals {
function DSChief(DSToken GOV, DSToken IOU, uint MAX_YAYS)
DSChiefApprovals (GOV, IOU, MAX_YAYS)
public
{
authority = this;
owner = 0;
}
function setOwner(address owner_) public {
owner_;
revert();
... | 7,590 |
312 | // Decreases the mocked timestamp value, used only for testing purposes/ | function mockDecreaseTime(uint256 _seconds) external {
if (mockedTimestamp != 0) mockedTimestamp = mockedTimestamp.sub(_seconds);
else mockedTimestamp = block.timestamp.sub(_seconds);
}
| function mockDecreaseTime(uint256 _seconds) external {
if (mockedTimestamp != 0) mockedTimestamp = mockedTimestamp.sub(_seconds);
else mockedTimestamp = block.timestamp.sub(_seconds);
}
| 46,440 |
25 | // Validate ilk | bytes32 _ilk = _join.ilk();
require(_ilk != 0, "IlkRegistry/ilk-adapter-invalid");
require(ilkData[_ilk].join == address(0), "IlkRegistry/ilk-already-exists");
(address _pip,) = spot.ilks(_ilk);
require(_pip != address(0), "IlkRegistry/pip-invalid");
(address _xlip,,,) ... | bytes32 _ilk = _join.ilk();
require(_ilk != 0, "IlkRegistry/ilk-adapter-invalid");
require(ilkData[_ilk].join == address(0), "IlkRegistry/ilk-already-exists");
(address _pip,) = spot.ilks(_ilk);
require(_pip != address(0), "IlkRegistry/pip-invalid");
(address _xlip,,,) ... | 23,968 |
30 | // Increase the amount of tokens that an owner allowed to a spender. approve should be called when allowed[_spender] == 0. To increment allowed value is better to use this function to avoid 2 calls (and wait until the first transaction is mined) From MonolithDAO Token.sol_spender The address which will spend the funds.... | function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
| function increaseApproval(
address _spender,
uint256 _addedValue
)
public
returns (bool)
| 8,052 |
85 | // PartyDAO receives TOKEN_FEE_BASIS_POINTS of the total supply | _partyDAOAmount = (_totalSupply * TOKEN_FEE_BASIS_POINTS) / 10000;
| _partyDAOAmount = (_totalSupply * TOKEN_FEE_BASIS_POINTS) / 10000;
| 38,302 |
23 | // the execution order for the next three lines is crutial | _updateGlobalStatus();
_updateVLiquidity(vLiquidity, true);
if (address(iziToken) == address(0)) {
| _updateGlobalStatus();
_updateVLiquidity(vLiquidity, true);
if (address(iziToken) == address(0)) {
| 45,754 |
109 | // Maintaining Profits | _profitStakers[_lowRiskUsers[i]][true] += _poolBalances[_lowRiskUsers[i]][true].mul(120).div(1000);
| _profitStakers[_lowRiskUsers[i]][true] += _poolBalances[_lowRiskUsers[i]][true].mul(120).div(1000);
| 30,202 |
220 | // Converts digg into wbtc equivalent | amount = amount.mul(1e18).div(10**tokenList[0].decimals); // Normalize the digg amount
uint256 _wbtc = amount.mul(getDiggUSDPrice()).div(1e18); // Get the USD value of digg
_wbtc = _wbtc.mul(1e18).div(getWBTCUSDPrice());
_wbtc = _wbtc.mul(10**tokenList[1].decimals).div(1e18); // Convert ... | amount = amount.mul(1e18).div(10**tokenList[0].decimals); // Normalize the digg amount
uint256 _wbtc = amount.mul(getDiggUSDPrice()).div(1e18); // Get the USD value of digg
_wbtc = _wbtc.mul(1e18).div(getWBTCUSDPrice());
_wbtc = _wbtc.mul(10**tokenList[1].decimals).div(1e18); // Convert ... | 70,809 |
13 | // Sanity check if last claim was on or after emission end | if (lastClaimed >= emissionEnd) return 0;
uint256 accumulationPeriod = block.timestamp < emissionEnd ? block.timestamp : emissionEnd; // Getting the min value of both
uint256 totalAccumulated = accumulationPeriod.sub(lastClaimed).mul(emissionPerDay).div(SECONDS_IN_A_DAY);
| if (lastClaimed >= emissionEnd) return 0;
uint256 accumulationPeriod = block.timestamp < emissionEnd ? block.timestamp : emissionEnd; // Getting the min value of both
uint256 totalAccumulated = accumulationPeriod.sub(lastClaimed).mul(emissionPerDay).div(SECONDS_IN_A_DAY);
| 29,807 |
124 | // Make an investment. The crowdsale must be running for one to invest.We must have not pressed the emergency brake.receiver The Ethereum address who receives the tokens customerId (optional) UUID v4 to track the successful payments on the server side/ | function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[msg.se... | function investInternal(address receiver, uint128 customerId) stopInEmergency notFinished private {
// Determine if it's a good time to accept investment from this participant
if (getState() == State.PreFunding) {
// Are we whitelisted for early deposit
require(earlyParticipantWhitelist[msg.se... | 35,329 |
3 | // original allocation from the list and deducting minted tokens). |
error ReviewAdminCannotBeAddressZero(); // We cannot use the zero address (address(0)) as a platformAdmin.
error RoyaltyFeeWillExceedSalePrice(); // The ERC2981 royalty specified will exceed the sale price.
error ShareTotalCannotBeZero(); // The total of al... |
error ReviewAdminCannotBeAddressZero(); // We cannot use the zero address (address(0)) as a platformAdmin.
error RoyaltyFeeWillExceedSalePrice(); // The ERC2981 royalty specified will exceed the sale price.
error ShareTotalCannotBeZero(); // The total of al... | 37,017 |
13 | // AGENT / | function _installAgentApp(Kernel _dao) internal returns (Agent) {
bytes memory initializeData = abi.encodeWithSelector(Agent(0).initialize.selector);
Agent agent = Agent(_installDefaultApp(_dao, AGENT_APP_ID, initializeData));
// We assume that installing the Agent app as a default app means... | function _installAgentApp(Kernel _dao) internal returns (Agent) {
bytes memory initializeData = abi.encodeWithSelector(Agent(0).initialize.selector);
Agent agent = Agent(_installDefaultApp(_dao, AGENT_APP_ID, initializeData));
// We assume that installing the Agent app as a default app means... | 7,367 |
33 | // Sells underlying for hTokens.// Requirements:/ - The caller must have allowed DSProxy to spend `underlyingIn` tokens.//hifiPool The address of the HifiPool contract./underlyingIn The exact amount of underlying that the user wants to sell./minHTokenOut The minimum amount of hTokens that the user is willing to accept. | function sellUnderlying(
IHifiPool hifiPool,
uint256 underlyingIn,
uint256 minHTokenOut
) external;
| function sellUnderlying(
IHifiPool hifiPool,
uint256 underlyingIn,
uint256 minHTokenOut
) external;
| 41,057 |
36 | // adding transfer event and _from address as null address | emit Transfer(0x0, msg.sender, _value);
return true;
| emit Transfer(0x0, msg.sender, _value);
return true;
| 3,657 |
390 | // This function allows governor to transfer governance to a new governor and emits event/_governor address Address of new governor | function setGovernor(address _governor) public onlyGovernor {
require(_governor != address(0), "Can't set zero address");
governor = _governor;
emit GovernorSet(governor);
}
| function setGovernor(address _governor) public onlyGovernor {
require(_governor != address(0), "Can't set zero address");
governor = _governor;
emit GovernorSet(governor);
}
| 59,364 |
129 | // Set the contract beneficiary address | function setContractBeneficiary(address payable beneficiary)
public
onlyOwner
| function setContractBeneficiary(address payable beneficiary)
public
onlyOwner
| 1,551 |
104 | // Approve the passed address to spend the specified amount of tokens on behalf of msg.senderand then call `onApprovalReceived` on spender.Beware that changing an allowance with this method brings the risk that someone may use both the oldand the new allowance by unfortunate transaction ordering. One possible solution ... | function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
| function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
| 14,283 |
17 | // Emitted when the allowance of a `spender` for an `owner` is set by | * a call to {approve}. `value` is the new allowance.
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| * a call to {approve}. `value` is the new allowance.
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| 337 |
193 | // sharing percents, 10000 == 100% | uint256 public constant REFERRER_SHARE_PCT = 1000; //10%
uint256 public constant NODE_SHARE_LV1_PCT = 400;
uint256 public constant NODE_SHARE_LV2_PCT = 300;
uint256 public constant NODE_SHARE_LV3_PCT = 300;
uint256 public constant NODE_SHARE_LV4_PCT = 200;
uint256 public constant NODE_SHARE_TOTA... | uint256 public constant REFERRER_SHARE_PCT = 1000; //10%
uint256 public constant NODE_SHARE_LV1_PCT = 400;
uint256 public constant NODE_SHARE_LV2_PCT = 300;
uint256 public constant NODE_SHARE_LV3_PCT = 300;
uint256 public constant NODE_SHARE_LV4_PCT = 200;
uint256 public constant NODE_SHARE_TOTA... | 11,416 |
29 | // only allow one reward for each challenge | bytes32 solution = solutionForChallenge[challengeNumber];
solutionForChallenge[challengeNumber] = digest;
if(solution != 0x0) revert(); //prevent the same answer from awarding twice
uint reward_amount = getMiningReward();
balances[msg.sender] = balances... | bytes32 solution = solutionForChallenge[challengeNumber];
solutionForChallenge[challengeNumber] = digest;
if(solution != 0x0) revert(); //prevent the same answer from awarding twice
uint reward_amount = getMiningReward();
balances[msg.sender] = balances... | 48,171 |
7 | // prevent front-running changing the price | require(totalCost <= maxCost, "Total cost exceeds max cost.");
require(msg.value >= totalCost, "Insufficient funds sent.");
| require(totalCost <= maxCost, "Total cost exceeds max cost.");
require(msg.value >= totalCost, "Insufficient funds sent.");
| 24,090 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.