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 |
|---|---|---|---|---|
163 | // lets the owner do an ERC20 approve followed by a call to a contract. The address to approve may be different than the contract to call. We assume that the contract does not require ETH._wallet The target wallet._token The token to approve._spender The address to approve._amount The amount of ERC20 tokens to approve._contract The contract to call._data The encoded method data/ | function approveTokenAndCallContract(
BaseWallet _wallet,
address _token,
address _spender,
uint256 _amount,
address _contract,
bytes calldata _data
)
external
onlyExecute
| function approveTokenAndCallContract(
BaseWallet _wallet,
address _token,
address _spender,
uint256 _amount,
address _contract,
bytes calldata _data
)
external
onlyExecute
| 4,913 |
65 | // Only BalanceManager can call this function to notify reward. - Reward must be greater than 0. - Must update reward info before notify. - Must contain remaining reward of previous cycle - Update reward cycle info/ | {
require(msg.value > 0, "Invalid reward");
updateReward();
uint256 remainingReward = lastReward > usedReward
? lastReward.sub(usedReward)
: 0;
lastReward = msg.value.add(remainingReward);
usedReward = 0;
rewardCycleEnd = block.number.add(rewardCycle);
rewardPerBlock = lastReward.div(rewardCycle);
}
| {
require(msg.value > 0, "Invalid reward");
updateReward();
uint256 remainingReward = lastReward > usedReward
? lastReward.sub(usedReward)
: 0;
lastReward = msg.value.add(remainingReward);
usedReward = 0;
rewardCycleEnd = block.number.add(rewardCycle);
rewardPerBlock = lastReward.div(rewardCycle);
}
| 45,862 |
205 | // Used to permanently halt all minting | bool public mintingFrozen;
| bool public mintingFrozen;
| 26,225 |
70 | // Admin contract for KittyBounties. Holds owner-only functions to adjust contract-wide fees, change owners, etc./The owner is not capable of changing the address of the CryptoKitties Core contract once the contract has been deployed./This prevents an attack vector where the owner could change the kittyCore contract once users had already deposited funds. | contract KittyBountiesAdmin is Ownable, Pausable, ReentrancyGuard, COORole {
/* ****** */
/* EVENTS */
/* ****** */
/// @dev This event is fired whenever the owner changes the successfulBountyFeeInBasisPoints.
/// @param newSuccessfulBountyFeeInBasisPoints The SuccessfulFee is expressed in basis points (hundredths of a percantage),
/// and is charged when a bounty is successfully completed.
event SuccessfulBountyFeeInBasisPointsUpdated(uint256 newSuccessfulBountyFeeInBasisPoints);
/// @dev This event is fired whenever the owner changes the unsuccessfulBountyFeeInWei.
/// @param newUnsuccessfulBountyFeeInWei The UnsuccessfulBountyFee is paid by the original bounty creator if the bounty expires
/// without being completed. When a bounty is created, the bounty creator specifies how long the bounty is valid for. If the
/// bounty is not fulfilled by this expiration date, the original creator can then freely withdraw their funds, minus the
/// UnsuccessfulBountyFee, although the bounty is still fulfillable until the bounty creator withdraws their funds.
event UnsuccessfulBountyFeeInWeiUpdated(uint256 newUnsuccessfulBountyFeeInWei);
/* ******* */
/* STORAGE */
/* ******* */
/// @dev The amount of fees collected (in wei). This includes both fees to the contract owner and fees to any bounty referrers.
/// Storing earnings saves gas rather than performing an additional transfer() call on every successful bounty.
mapping (address => uint256) public addressToFeeEarnings;
/// @dev If a bounty is successfully fulfilled, this fee applies before the remaining funds are sent to the successful bounty
/// hunter. This fee is measured in basis points (hundredths of a percent), and is taken out of the total value that the bounty
/// creator locked up in the contract when they created the bounty.
uint256 public successfulBountyFeeInBasisPoints = 375;
/// @dev If a bounty is not fulfilled after the lockup period has completed, a bounty creator can withdraw their funds and
/// invalidate the bounty, but they are charged this flat fee to do so. This fee is measured in wei.
uint256 public unsuccessfulBountyFeeInWei = 0.008 ether;
/* ********* */
/* CONSTANTS */
/* ********* */
/// @dev The owner is not capable of changing the address of the CryptoKitties Core contract once the contract has been deployed.
/// This prevents an attack vector where the owner could change the kittyCore contract once users had already deposited funds.
/// Since the CryptoKitties Core contract has the ability to migrate to a new contract, if Dapper Labs Inc. ever chooses to migrate
/// contract, this contract will have to be frozen, and users will be allowed to withdraw their funds without paying any fees.
address public kittyCoreAddress = 0x06012c8cf97BEaD5deAe237070F9587f8E7A266d;
KittyCore kittyCore;
/* ********* */
/* FUNCTIONS */
/* ********* */
/// @dev The owner is not capable of changing the address of the CryptoKitties Core contract once the contract has been deployed.
/// This prevents an attack vector where the owner could change the kittyCore contract once users had already deposited funds.
constructor() internal {
kittyCore = KittyCore(kittyCoreAddress);
}
/// @notice Sets the successfulBountyFeeInBasisPoints value (in basis points). Any bounties that are successfully fulfilled
/// will have this fee deducted from amount sent to the bounty hunter.
/// @notice Only callable by the owner.
/// @dev As this configuration is a basis point, the value to set must be less than or equal to 10000.
/// @param _newSuccessfulBountyFeeInBasisPoints The successfulBountyFeeInBasisPoints value to set (measured in basis points).
function setSuccessfulBountyFeeInBasisPoints(uint256 _newSuccessfulBountyFeeInBasisPoints) external onlyOwner {
require(_newSuccessfulBountyFeeInBasisPoints <= 10000, 'new successful bounty fee must be in basis points (hundredths of a percent), not wei');
successfulBountyFeeInBasisPoints = _newSuccessfulBountyFeeInBasisPoints;
emit SuccessfulBountyFeeInBasisPointsUpdated(_newSuccessfulBountyFeeInBasisPoints);
}
/// @notice Sets the unsuccessfulBountyFeeInWei value. If a bounty is still unfulfilled once the minimum number of blocks has passed,
/// an owner can withdraw the locked ETH. If they do so, this fee is deducted from the amount that they withdraw.
/// @notice Only callable by the owner.
/// @param _newUnsuccessfulBountyFeeInWei The unsuccessfulBountyFeeInWei value to set (measured in wei).
function setUnsuccessfulBountyFeeInWei(uint256 _newUnsuccessfulBountyFeeInWei) external onlyOwner {
unsuccessfulBountyFeeInWei = _newUnsuccessfulBountyFeeInWei;
emit UnsuccessfulBountyFeeInWeiUpdated(_newUnsuccessfulBountyFeeInWei);
}
/// @notice Withdraws the fees that have been earned by either the contract owner or referrers.
/// @notice Only callable by the address that had earned the fees.
function withdrawFeeEarningsForAddress() external nonReentrant {
uint256 balance = addressToFeeEarnings[msg.sender];
require(balance > 0, 'there are no fees to withdraw for this address');
addressToFeeEarnings[msg.sender] = 0;
msg.sender.transfer(balance);
}
/// @notice Gives the authority for the contract owner to remove any additional accounts that have been granted the ability to
/// pause the contract
/// @notice Only callable by the owner.
/// @param _account The account to have the ability to pause the contract revoked
function removePauser(address _account) external onlyOwner {
_removePauser(_account);
}
/// @notice Gives the authority for the contract owner to remove any additional accounts that have been granted the COO authority
/// @notice Only callable by the owner.
/// @param _account The account to have COO authority revoked
function removeCOO(address _account) external onlyOwner {
_removeCOO(_account);
}
/// @dev By calling 'revert' in the fallback function, we prevent anyone from accidentally sending funds directly to this contract.
function() external payable {
revert();
}
}
| contract KittyBountiesAdmin is Ownable, Pausable, ReentrancyGuard, COORole {
/* ****** */
/* EVENTS */
/* ****** */
/// @dev This event is fired whenever the owner changes the successfulBountyFeeInBasisPoints.
/// @param newSuccessfulBountyFeeInBasisPoints The SuccessfulFee is expressed in basis points (hundredths of a percantage),
/// and is charged when a bounty is successfully completed.
event SuccessfulBountyFeeInBasisPointsUpdated(uint256 newSuccessfulBountyFeeInBasisPoints);
/// @dev This event is fired whenever the owner changes the unsuccessfulBountyFeeInWei.
/// @param newUnsuccessfulBountyFeeInWei The UnsuccessfulBountyFee is paid by the original bounty creator if the bounty expires
/// without being completed. When a bounty is created, the bounty creator specifies how long the bounty is valid for. If the
/// bounty is not fulfilled by this expiration date, the original creator can then freely withdraw their funds, minus the
/// UnsuccessfulBountyFee, although the bounty is still fulfillable until the bounty creator withdraws their funds.
event UnsuccessfulBountyFeeInWeiUpdated(uint256 newUnsuccessfulBountyFeeInWei);
/* ******* */
/* STORAGE */
/* ******* */
/// @dev The amount of fees collected (in wei). This includes both fees to the contract owner and fees to any bounty referrers.
/// Storing earnings saves gas rather than performing an additional transfer() call on every successful bounty.
mapping (address => uint256) public addressToFeeEarnings;
/// @dev If a bounty is successfully fulfilled, this fee applies before the remaining funds are sent to the successful bounty
/// hunter. This fee is measured in basis points (hundredths of a percent), and is taken out of the total value that the bounty
/// creator locked up in the contract when they created the bounty.
uint256 public successfulBountyFeeInBasisPoints = 375;
/// @dev If a bounty is not fulfilled after the lockup period has completed, a bounty creator can withdraw their funds and
/// invalidate the bounty, but they are charged this flat fee to do so. This fee is measured in wei.
uint256 public unsuccessfulBountyFeeInWei = 0.008 ether;
/* ********* */
/* CONSTANTS */
/* ********* */
/// @dev The owner is not capable of changing the address of the CryptoKitties Core contract once the contract has been deployed.
/// This prevents an attack vector where the owner could change the kittyCore contract once users had already deposited funds.
/// Since the CryptoKitties Core contract has the ability to migrate to a new contract, if Dapper Labs Inc. ever chooses to migrate
/// contract, this contract will have to be frozen, and users will be allowed to withdraw their funds without paying any fees.
address public kittyCoreAddress = 0x06012c8cf97BEaD5deAe237070F9587f8E7A266d;
KittyCore kittyCore;
/* ********* */
/* FUNCTIONS */
/* ********* */
/// @dev The owner is not capable of changing the address of the CryptoKitties Core contract once the contract has been deployed.
/// This prevents an attack vector where the owner could change the kittyCore contract once users had already deposited funds.
constructor() internal {
kittyCore = KittyCore(kittyCoreAddress);
}
/// @notice Sets the successfulBountyFeeInBasisPoints value (in basis points). Any bounties that are successfully fulfilled
/// will have this fee deducted from amount sent to the bounty hunter.
/// @notice Only callable by the owner.
/// @dev As this configuration is a basis point, the value to set must be less than or equal to 10000.
/// @param _newSuccessfulBountyFeeInBasisPoints The successfulBountyFeeInBasisPoints value to set (measured in basis points).
function setSuccessfulBountyFeeInBasisPoints(uint256 _newSuccessfulBountyFeeInBasisPoints) external onlyOwner {
require(_newSuccessfulBountyFeeInBasisPoints <= 10000, 'new successful bounty fee must be in basis points (hundredths of a percent), not wei');
successfulBountyFeeInBasisPoints = _newSuccessfulBountyFeeInBasisPoints;
emit SuccessfulBountyFeeInBasisPointsUpdated(_newSuccessfulBountyFeeInBasisPoints);
}
/// @notice Sets the unsuccessfulBountyFeeInWei value. If a bounty is still unfulfilled once the minimum number of blocks has passed,
/// an owner can withdraw the locked ETH. If they do so, this fee is deducted from the amount that they withdraw.
/// @notice Only callable by the owner.
/// @param _newUnsuccessfulBountyFeeInWei The unsuccessfulBountyFeeInWei value to set (measured in wei).
function setUnsuccessfulBountyFeeInWei(uint256 _newUnsuccessfulBountyFeeInWei) external onlyOwner {
unsuccessfulBountyFeeInWei = _newUnsuccessfulBountyFeeInWei;
emit UnsuccessfulBountyFeeInWeiUpdated(_newUnsuccessfulBountyFeeInWei);
}
/// @notice Withdraws the fees that have been earned by either the contract owner or referrers.
/// @notice Only callable by the address that had earned the fees.
function withdrawFeeEarningsForAddress() external nonReentrant {
uint256 balance = addressToFeeEarnings[msg.sender];
require(balance > 0, 'there are no fees to withdraw for this address');
addressToFeeEarnings[msg.sender] = 0;
msg.sender.transfer(balance);
}
/// @notice Gives the authority for the contract owner to remove any additional accounts that have been granted the ability to
/// pause the contract
/// @notice Only callable by the owner.
/// @param _account The account to have the ability to pause the contract revoked
function removePauser(address _account) external onlyOwner {
_removePauser(_account);
}
/// @notice Gives the authority for the contract owner to remove any additional accounts that have been granted the COO authority
/// @notice Only callable by the owner.
/// @param _account The account to have COO authority revoked
function removeCOO(address _account) external onlyOwner {
_removeCOO(_account);
}
/// @dev By calling 'revert' in the fallback function, we prevent anyone from accidentally sending funds directly to this contract.
function() external payable {
revert();
}
}
| 31,376 |
13 | // verify if this order is for a specific address | if (order.taker != address(0)) {
require(msg.sender == order.taker, 'Sale: Order not for this user');
}
| if (order.taker != address(0)) {
require(msg.sender == order.taker, 'Sale: Order not for this user');
}
| 63,078 |
670 | // Numerator: 1. val = 1. val := mulmod(val, 1, PRIME). Denominator: point^(trace_length / 4096) - trace_generator^(255trace_length / 256). val = denominator_invs[17]. | val := mulmod(val, mload(0x4940), PRIME)
| val := mulmod(val, mload(0x4940), PRIME)
| 21,748 |
34 | // ------------------------------------------------------------------------ Count content for article ------------------------------------------------------------------------ | function countContentForArticle(uint256 articleId) public view returns(uint256) {
return articleContentIds[articleId].contentIds.length;
}
| function countContentForArticle(uint256 articleId) public view returns(uint256) {
return articleContentIds[articleId].contentIds.length;
}
| 11,070 |
32 | // Withdraws funds from any Moloch (incl. UberHaus or the minion owner DAO) into this Minion | require(IMOLOCH(targetDao).getUserTokenBalance(address(this), token) >= amount, "user balance < amount");
IMOLOCH(targetDao).withdrawBalance(token, amount); // withdraw funds from DAO
emit DoWithdraw(targetDao, token, amount);
| require(IMOLOCH(targetDao).getUserTokenBalance(address(this), token) >= amount, "user balance < amount");
IMOLOCH(targetDao).withdrawBalance(token, amount); // withdraw funds from DAO
emit DoWithdraw(targetDao, token, amount);
| 8,041 |
11 | // message unnecessarily. For custom revert reasons use {trySub}. Counterpart to Solidity's `-` operator. Requirements: - Subtraction cannot overflow. / | function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
| function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
| 628 |
42 | // Emit BuyGold event | emit BuyGold(msg.sender, _GoldPrice, msg.value);
| emit BuyGold(msg.sender, _GoldPrice, msg.value);
| 63,807 |
16 | // allow the owner to pre-mint or save a number of tokens | function reserveTokens(uint _amount, address _receiver) public onlyOwner {
uint256 newSupply = totalSupply + _amount;
require(newSupply <= maxSupply, "MAX_SUPPLY_EXCEEDED");
for (uint256 i = 0; i < _amount; i++) {
_mint(_receiver, totalSupply + i);
}
// update the total supply
totalSupply = newSupply;
}
| function reserveTokens(uint _amount, address _receiver) public onlyOwner {
uint256 newSupply = totalSupply + _amount;
require(newSupply <= maxSupply, "MAX_SUPPLY_EXCEEDED");
for (uint256 i = 0; i < _amount; i++) {
_mint(_receiver, totalSupply + i);
}
// update the total supply
totalSupply = newSupply;
}
| 62,455 |
3 | // Event to log that payment for bounty has been received to be stored temporarily in contract | event Received(address indexed _from, uint _value);
| event Received(address indexed _from, uint _value);
| 2,288 |
8 | // Mint multiple nft and transfer to - accounts uris - token uris / | function mintBatchAndTransfer(address[] memory to, string[] memory uris) external onlyRole(MINTER_ROLE) nonReentrant {
for (uint256 i; i < uris.length; ++i) {
uint256 tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_safeMint(to[i], tokenId);
_setTokenURI(tokenId, uris[i]);
}
}
| function mintBatchAndTransfer(address[] memory to, string[] memory uris) external onlyRole(MINTER_ROLE) nonReentrant {
for (uint256 i; i < uris.length; ++i) {
uint256 tokenId = _tokenIdCounter.current();
_tokenIdCounter.increment();
_safeMint(to[i], tokenId);
_setTokenURI(tokenId, uris[i]);
}
}
| 35,758 |
223 | // _totalBalance {uint} total balance of tokens assigned to this userreturn {uint} amount of tokens available to transfer / |
function vestedAmount(uint _totalBalance) public view returns (uint) {
if (block.timestamp < cliff) {
return 0;
} else if (block.timestamp >= startCountDown.add(duration)) {
|
function vestedAmount(uint _totalBalance) public view returns (uint) {
if (block.timestamp < cliff) {
return 0;
} else if (block.timestamp >= startCountDown.add(duration)) {
| 7,123 |
27 | // ------------------------------- MESSAGE PUBLICATION---------------------------------------- | function testPublishMessage(
string uuid,
string message,
uint32 duration,
address contractAddress
| function testPublishMessage(
string uuid,
string message,
uint32 duration,
address contractAddress
| 43,995 |
4 | // Set the preferred aggregator. Reverts unless called by the chain owner or the current default aggregator. | function setDefaultAggregator(address newDefault) external;
| function setDefaultAggregator(address newDefault) external;
| 39,387 |
259 | // Gets the instance of Set valuer on Controller. Note: SetValuer is stored as index 2 on the Controller / | function getSetValuer(IController _controller) internal view returns (ISetValuer) {
return ISetValuer(_controller.resourceId(SET_VALUER_RESOURCE_ID));
}
| function getSetValuer(IController _controller) internal view returns (ISetValuer) {
return ISetValuer(_controller.resourceId(SET_VALUER_RESOURCE_ID));
}
| 46,492 |
185 | // We have set a capped price. Log it so we can detect the situation and investigate. | emit CappedPricePosted(
_asset,
_requestedPriceMantissa,
_localVars.cappingAnchorPriceMantissa,
_localVars.price.mantissa
);
| emit CappedPricePosted(
_asset,
_requestedPriceMantissa,
_localVars.cappingAnchorPriceMantissa,
_localVars.price.mantissa
);
| 17,853 |
30 | // Should return whether the signature provided is valid for the provided data/hash 32-byte hash of the data that is signed/_signature Signature byte array associated with _data/MUST return the bytes4 magic value 0x1626ba7e when function passes./MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5)/MUST allow external calls | function isValidSignature(
bytes32 hash,
bytes calldata _signature)
external
view
returns (bytes4);
| function isValidSignature(
bytes32 hash,
bytes calldata _signature)
external
view
returns (bytes4);
| 36,550 |
14 | // user tokens | mapping (address => uint256) public balances;
| mapping (address => uint256) public balances;
| 62,715 |
6 | // ============Ownable ============ | function addAdminList (address userAddr) external onlyOwner {
isAdminListed[userAddr] = true;
emit addAdmin(userAddr);
}
| function addAdminList (address userAddr) external onlyOwner {
isAdminListed[userAddr] = true;
emit addAdmin(userAddr);
}
| 1,977 |
17 | // Enables `_account` redeem address to burn. | * Emits a {EnableUserRedeemAddress} event.
*
* Requirements:
*
* - `_account` should be a registered as user.
* - `_account` should be KYC verified.
*/
function enableRedeemAddress(address _account) public onlyOwner {
require(_isUser(_account), "not a user");
require(_isKyced(_account), "user has not KYC");
setAttribute(getRedeemAddress(_account), CAN_BURN, 1);
emit EnableRedeemAddress(_account);
}
| * Emits a {EnableUserRedeemAddress} event.
*
* Requirements:
*
* - `_account` should be a registered as user.
* - `_account` should be KYC verified.
*/
function enableRedeemAddress(address _account) public onlyOwner {
require(_isUser(_account), "not a user");
require(_isKyced(_account), "user has not KYC");
setAttribute(getRedeemAddress(_account), CAN_BURN, 1);
emit EnableRedeemAddress(_account);
}
| 33,538 |
906 | // Resolution for all fixed point numeric parameters which represent percents. The resolution allows for a/ granularity of 0.01% increments. | uint256 public constant PERCENT_RESOLUTION = 10000;
| uint256 public constant PERCENT_RESOLUTION = 10000;
| 53,767 |
200 | // User supplies assets into the market and receives dTokens in exchange Assumes interest has already been accrued up to the current block minter The address of the account which is supplying the assets mintAmount The amount of the underlying asset to supplyreturn (uint, uint) An error code (0=success, otherwise a failure, see ErrorReporter.sol), and the actual mint amount. / | function mintFresh(address minter, uint mintAmount) internal returns (uint, uint) {
/* Fail if mint not allowed */
uint allowed = dController.mintAllowed(address(this), minter, mintAmount);
if (allowed != 0) {
return (failOpaque(Error.DCONTROLLER_REJECTION, FailureInfo.MINT_DCONTROLLER_REJECTION, allowed), 0);
}
/* Verify market's block number equals current block number */
if (accrualBlockNumber != getBlockNumber()) {
return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0);
}
MintLocalVars memory vars;
(vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();
if (vars.mathErr != MathError.NO_ERROR) {
return (failOpaque(Error.MATH_ERROR, FailureInfo.MINT_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr)), 0);
}
/////////////////////////
// EFFECTS & INTERACTIONS
// (No safe failures beyond this point)
/*
* We call `doTransferIn` for the minter and the mintAmount.
* Note: The dToken must handle variations between ERC-20 and ETH underlying.
* `doTransferIn` reverts if anything goes wrong, since we can't be sure if
* side-effects occurred. The function returns the amount actually transferred,
* in case of a fee. On success, the dToken holds an additional `actualMintAmount`
* of cash.
*/
vars.actualMintAmount = doTransferIn(minter, mintAmount);
/*
* We get the current exchange rate and calculate the number of dTokens to be minted:
* mintTokens = actualMintAmount / exchangeRate
*/
(vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(vars.actualMintAmount, Exp({mantissa: vars.exchangeRateMantissa}));
require(vars.mathErr == MathError.NO_ERROR, "MINT_EXCHANGE_CALCULATION_FAILED");
/*
* We calculate the new total supply of dTokens and minter token balance, checking for overflow:
* totalSupplyNew = totalSupply + mintTokens
* accountTokensNew = accountTokens[minter] + mintTokens
*/
(vars.mathErr, vars.totalSupplyNew) = addUInt(totalSupply, vars.mintTokens);
require(vars.mathErr == MathError.NO_ERROR, "MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED");
(vars.mathErr, vars.accountTokensNew) = addUInt(accountTokens[minter], vars.mintTokens);
require(vars.mathErr == MathError.NO_ERROR, "MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED");
/* We write previously calculated values into storage */
totalSupply = vars.totalSupplyNew;
accountTokens[minter] = vars.accountTokensNew;
/* We emit a Mint event, and a Transfer event */
emit MintToken(minter, vars.actualMintAmount, vars.mintTokens);
emit Transfer(address(this), minter, vars.mintTokens);
/* We call the defense hook */
dController.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens);
return (uint(Error.NO_ERROR), vars.actualMintAmount);
}
| function mintFresh(address minter, uint mintAmount) internal returns (uint, uint) {
/* Fail if mint not allowed */
uint allowed = dController.mintAllowed(address(this), minter, mintAmount);
if (allowed != 0) {
return (failOpaque(Error.DCONTROLLER_REJECTION, FailureInfo.MINT_DCONTROLLER_REJECTION, allowed), 0);
}
/* Verify market's block number equals current block number */
if (accrualBlockNumber != getBlockNumber()) {
return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0);
}
MintLocalVars memory vars;
(vars.mathErr, vars.exchangeRateMantissa) = exchangeRateStoredInternal();
if (vars.mathErr != MathError.NO_ERROR) {
return (failOpaque(Error.MATH_ERROR, FailureInfo.MINT_EXCHANGE_RATE_READ_FAILED, uint(vars.mathErr)), 0);
}
/////////////////////////
// EFFECTS & INTERACTIONS
// (No safe failures beyond this point)
/*
* We call `doTransferIn` for the minter and the mintAmount.
* Note: The dToken must handle variations between ERC-20 and ETH underlying.
* `doTransferIn` reverts if anything goes wrong, since we can't be sure if
* side-effects occurred. The function returns the amount actually transferred,
* in case of a fee. On success, the dToken holds an additional `actualMintAmount`
* of cash.
*/
vars.actualMintAmount = doTransferIn(minter, mintAmount);
/*
* We get the current exchange rate and calculate the number of dTokens to be minted:
* mintTokens = actualMintAmount / exchangeRate
*/
(vars.mathErr, vars.mintTokens) = divScalarByExpTruncate(vars.actualMintAmount, Exp({mantissa: vars.exchangeRateMantissa}));
require(vars.mathErr == MathError.NO_ERROR, "MINT_EXCHANGE_CALCULATION_FAILED");
/*
* We calculate the new total supply of dTokens and minter token balance, checking for overflow:
* totalSupplyNew = totalSupply + mintTokens
* accountTokensNew = accountTokens[minter] + mintTokens
*/
(vars.mathErr, vars.totalSupplyNew) = addUInt(totalSupply, vars.mintTokens);
require(vars.mathErr == MathError.NO_ERROR, "MINT_NEW_TOTAL_SUPPLY_CALCULATION_FAILED");
(vars.mathErr, vars.accountTokensNew) = addUInt(accountTokens[minter], vars.mintTokens);
require(vars.mathErr == MathError.NO_ERROR, "MINT_NEW_ACCOUNT_BALANCE_CALCULATION_FAILED");
/* We write previously calculated values into storage */
totalSupply = vars.totalSupplyNew;
accountTokens[minter] = vars.accountTokensNew;
/* We emit a Mint event, and a Transfer event */
emit MintToken(minter, vars.actualMintAmount, vars.mintTokens);
emit Transfer(address(this), minter, vars.mintTokens);
/* We call the defense hook */
dController.mintVerify(address(this), minter, vars.actualMintAmount, vars.mintTokens);
return (uint(Error.NO_ERROR), vars.actualMintAmount);
}
| 31,860 |
17 | // Compute the minimum accepted amount of ETH out of the trade, based on the slippage settings. | Decimal.D256 memory maxSlippage = Decimal.ratio(BASIS_POINTS_GRANULARITY - maximumSlippageBasisPoints, BASIS_POINTS_GRANULARITY);
uint256 minimumAcceptedAmountOut = maxSlippage.mul(amountIn).asUint256();
| Decimal.D256 memory maxSlippage = Decimal.ratio(BASIS_POINTS_GRANULARITY - maximumSlippageBasisPoints, BASIS_POINTS_GRANULARITY);
uint256 minimumAcceptedAmountOut = maxSlippage.mul(amountIn).asUint256();
| 25,627 |
197 | // Address of Opium.TokenSpender contract | address private tokenSpender;
| address private tokenSpender;
| 32,162 |
14 | // _mint() call adds 1 to total tokens, but we want the token at index - 1 | tokenIdToMetadata[totalTokens] = url;
emit Mint(url, totalTokens);
| tokenIdToMetadata[totalTokens] = url;
emit Mint(url, totalTokens);
| 11,387 |
6 | // WHAT IS OpenEthereumToken? OpenEthereumToken for general ethereum NFT token use; NFT Block Chain Token, URL link, Ethereum Interface, Data Rewrite possible, On Chain Data Storage, Transfer of Token Pay to Recieve token Individual Token Optimization Security UseageContract for OET tokens How to Use: Send Ether to Contract Address Min amount 0.16Automatically recieve 1 OET Token to payee address, Inventory Number as next Minted Add Token Information with addTokenData function (with contract write) any Information / Data can be written to Chain Transfer via SafeTransfers (with contract write) // SafeMath Math operations with safety checks that throw on error / | library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev 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 a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
}
| library SafeMath {
/**
* @dev Multiplies two numbers, throws on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256 c) {
// Gas optimization: this is cheaper than asserting 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
c = a * b;
assert(c / a == b);
return c;
}
/**
* @dev 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 a / b;
}
/**
* @dev Subtracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
/**
* @dev Adds two numbers, throws on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256 c) {
c = a + b;
assert(c >= a);
return c;
}
}
| 42,582 |
4 | // Send `_amount` tokens to `_to` from `msg.sender`/_to The address of the recipient/_amount The amount of tokens to be transferred/ return success Whether the transfer was successful or not | function transfer(address _to, uint256 _amount) public virtual returns (bool success);
| function transfer(address _to, uint256 _amount) public virtual returns (bool success);
| 18,006 |
24 | // Ensure signatory is authorized to sign | if (authorized[signerWallet] != address(0)) {
| if (authorized[signerWallet] != address(0)) {
| 6,129 |
2 | // only allow function to be `DELEGATECALL`ed from within a constructor. | uint32 codeSize;
assembly {
codeSize := extcodesize(address)
}
| uint32 codeSize;
assembly {
codeSize := extcodesize(address)
}
| 28,526 |
7 | // Implementation of the ERC3156 Flash loans extension, as defined in | * Adds the {flashLoan} method, which provides flash loan support at the token
* level. By default there is no fee, but this can be changed by overriding {flashFee}.
*
* _Available since v4.1._
*/
abstract contract ERC20FlashMintUpgradeable is Initializable, ERC20Upgradeable, IERC3156FlashLenderUpgradeable {
function __ERC20FlashMint_init() internal onlyInitializing {
}
function __ERC20FlashMint_init_unchained() internal onlyInitializing {
}
bytes32 private constant _RETURN_VALUE = keccak256("ERC3156FlashBorrower.onFlashLoan");
/**
* @dev Returns the maximum amount of tokens available for loan.
* @param token The address of the token that is requested.
* @return The amont of token that can be loaned.
*/
function maxFlashLoan(address token) public view virtual override returns (uint256) {
return token == address(this) ? type(uint256).max - ERC20Upgradeable.totalSupply() : 0;
}
/**
* @dev Returns the fee applied when doing flash loans. By default this
* implementation has 0 fees. This function can be overloaded to make
* the flash loan mechanism deflationary.
* @param token The token to be flash loaned.
* @param amount The amount of tokens to be loaned.
* @return The fees applied to the corresponding flash loan.
*/
function flashFee(address token, uint256 amount) public view virtual override returns (uint256) {
require(token == address(this), "ERC20FlashMint: wrong token");
// silence warning about unused variable without the addition of bytecode.
amount;
return 0;
}
/**
* @dev Performs a flash loan. New tokens are minted and sent to the
* `receiver`, who is required to implement the {IERC3156FlashBorrower}
* interface. By the end of the flash loan, the receiver is expected to own
* amount + fee tokens and have them approved back to the token contract itself so
* they can be burned.
* @param receiver The receiver of the flash loan. Should implement the
* {IERC3156FlashBorrower.onFlashLoan} interface.
* @param token The token to be flash loaned. Only `address(this)` is
* supported.
* @param amount The amount of tokens to be loaned.
* @param data An arbitrary datafield that is passed to the receiver.
* @return `true` is the flash loan was successful.
*/
function flashLoan(
IERC3156FlashBorrowerUpgradeable receiver,
address token,
uint256 amount,
bytes calldata data
) public virtual override returns (bool) {
require(amount <= maxFlashLoan(token), "ERC20FlashMint: amount exceeds maxFlashLoan");
uint256 fee = flashFee(token, amount);
_mint(address(receiver), amount);
require(
receiver.onFlashLoan(msg.sender, token, amount, fee, data) == _RETURN_VALUE,
"ERC20FlashMint: invalid return value"
);
uint256 currentAllowance = allowance(address(receiver), address(this));
require(currentAllowance >= amount + fee, "ERC20FlashMint: allowance does not allow refund");
_approve(address(receiver), address(this), currentAllowance - amount - fee);
_burn(address(receiver), amount + fee);
return true;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
| * Adds the {flashLoan} method, which provides flash loan support at the token
* level. By default there is no fee, but this can be changed by overriding {flashFee}.
*
* _Available since v4.1._
*/
abstract contract ERC20FlashMintUpgradeable is Initializable, ERC20Upgradeable, IERC3156FlashLenderUpgradeable {
function __ERC20FlashMint_init() internal onlyInitializing {
}
function __ERC20FlashMint_init_unchained() internal onlyInitializing {
}
bytes32 private constant _RETURN_VALUE = keccak256("ERC3156FlashBorrower.onFlashLoan");
/**
* @dev Returns the maximum amount of tokens available for loan.
* @param token The address of the token that is requested.
* @return The amont of token that can be loaned.
*/
function maxFlashLoan(address token) public view virtual override returns (uint256) {
return token == address(this) ? type(uint256).max - ERC20Upgradeable.totalSupply() : 0;
}
/**
* @dev Returns the fee applied when doing flash loans. By default this
* implementation has 0 fees. This function can be overloaded to make
* the flash loan mechanism deflationary.
* @param token The token to be flash loaned.
* @param amount The amount of tokens to be loaned.
* @return The fees applied to the corresponding flash loan.
*/
function flashFee(address token, uint256 amount) public view virtual override returns (uint256) {
require(token == address(this), "ERC20FlashMint: wrong token");
// silence warning about unused variable without the addition of bytecode.
amount;
return 0;
}
/**
* @dev Performs a flash loan. New tokens are minted and sent to the
* `receiver`, who is required to implement the {IERC3156FlashBorrower}
* interface. By the end of the flash loan, the receiver is expected to own
* amount + fee tokens and have them approved back to the token contract itself so
* they can be burned.
* @param receiver The receiver of the flash loan. Should implement the
* {IERC3156FlashBorrower.onFlashLoan} interface.
* @param token The token to be flash loaned. Only `address(this)` is
* supported.
* @param amount The amount of tokens to be loaned.
* @param data An arbitrary datafield that is passed to the receiver.
* @return `true` is the flash loan was successful.
*/
function flashLoan(
IERC3156FlashBorrowerUpgradeable receiver,
address token,
uint256 amount,
bytes calldata data
) public virtual override returns (bool) {
require(amount <= maxFlashLoan(token), "ERC20FlashMint: amount exceeds maxFlashLoan");
uint256 fee = flashFee(token, amount);
_mint(address(receiver), amount);
require(
receiver.onFlashLoan(msg.sender, token, amount, fee, data) == _RETURN_VALUE,
"ERC20FlashMint: invalid return value"
);
uint256 currentAllowance = allowance(address(receiver), address(this));
require(currentAllowance >= amount + fee, "ERC20FlashMint: allowance does not allow refund");
_approve(address(receiver), address(this), currentAllowance - amount - fee);
_burn(address(receiver), amount + fee);
return true;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
| 680 |
3 | // 1. Calculate new bid and ask | (order memory ask, order memory bid) = getNewOrders(
underlyingAsset,
underlyingQuote,
askNumerator,
askDenomenator,
bidNumerator,
bidDenomenator
);
| (order memory ask, order memory bid) = getNewOrders(
underlyingAsset,
underlyingQuote,
askNumerator,
askDenomenator,
bidNumerator,
bidDenomenator
);
| 17,073 |
94 | // The pool tick spacing/Ticks can only be used at multiples of this value, minimum of 1 and always positive/ e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, .../ This value is an int24 to avoid casting even though it is always positive./ return The tick spacing | function tickSpacing() external view returns (int24);
| function tickSpacing() external view returns (int24);
| 3,639 |
2 | // variables | mapping (address => Participant) participants;
bool ended = false;
uint public quote = 0;
uint public participantsCount = 0;
uint public ticketPrice = 0;
State public fsm = State.Locked; // contract finit state machine, initial state Locked
address seller = address(0);
SimpleTokenCoin public token = new SimpleTokenCoin();
| mapping (address => Participant) participants;
bool ended = false;
uint public quote = 0;
uint public participantsCount = 0;
uint public ticketPrice = 0;
State public fsm = State.Locked; // contract finit state machine, initial state Locked
address seller = address(0);
SimpleTokenCoin public token = new SimpleTokenCoin();
| 4,527 |
16 | // Allow given spender to transfer given number of tokens from message sender. _spender address to allow the owner of to transfer tokens from message sender _value number of tokens to allow to transferreturn true if token transfer was successfully approved, false otherwise / | function approve (address _spender, uint256 _value) public returns (bool success) {
allowances [msg.sender][_spender] = _value;
emit Approval (msg.sender, _spender, _value);
return true;
}
| function approve (address _spender, uint256 _value) public returns (bool success) {
allowances [msg.sender][_spender] = _value;
emit Approval (msg.sender, _spender, _value);
return true;
}
| 45,006 |
112 | // new metrics | uint sigmaTotalOptions;
uint sigmaSoldOptions;
| uint sigmaTotalOptions;
uint sigmaSoldOptions;
| 41,819 |
6 | // Function that is called when a user or another contract wants to transfer funds. | function transfer(address to, uint256 value, bytes data) public returns (bool) {
require(balanceOf[msg.sender] >= value);
uint256 codeLength;
assembly {
// Retrieve the size of the code on target address, this needs assembly .
codeLength := extcodesize(to)
}
balanceOf[msg.sender] -= value; // underflow checked by require() above
balanceOf[to] = balanceOf[to].add(value);
if (codeLength > 0) {
ERC223ReceivingContract receiver = ERC223ReceivingContract(to);
receiver.tokenFallback(msg.sender, value, data);
}
ERC223Transfer(msg.sender, to, value, data);
return true;
}
| function transfer(address to, uint256 value, bytes data) public returns (bool) {
require(balanceOf[msg.sender] >= value);
uint256 codeLength;
assembly {
// Retrieve the size of the code on target address, this needs assembly .
codeLength := extcodesize(to)
}
balanceOf[msg.sender] -= value; // underflow checked by require() above
balanceOf[to] = balanceOf[to].add(value);
if (codeLength > 0) {
ERC223ReceivingContract receiver = ERC223ReceivingContract(to);
receiver.tokenFallback(msg.sender, value, data);
}
ERC223Transfer(msg.sender, to, value, data);
return true;
}
| 31,479 |
155 | // This is an account call system call parse a 32-byte value at offset 1 (offset 0 is the capType byte) | uint256 capIndex = parse32ByteValue(1);
address account = address(parse32ByteValue(1+1*32));
uint256 amount = parse32ByteValue(1+2*32);
uint256 dataLength;
if (msg.data.length > (1+3*32)) {
dataLength = msg.data.length - (1+3*32);
} else {
| uint256 capIndex = parse32ByteValue(1);
address account = address(parse32ByteValue(1+1*32));
uint256 amount = parse32ByteValue(1+2*32);
uint256 dataLength;
if (msg.data.length > (1+3*32)) {
dataLength = msg.data.length - (1+3*32);
} else {
| 22,297 |
5 | // Give 'voter' the right to vote on this ballot. May only be called by 'chairperson'. voter address of voter / | function giveRightToVote(address voter) public {
require(
msg.sender == chairperson,
"Only chairperson can give right to vote."
);
require(
!voters[voter].voted,
"The voter already voted."
);
require(voters[voter].weight == 0);
voters[voter].weight = 1;
}
| function giveRightToVote(address voter) public {
require(
msg.sender == chairperson,
"Only chairperson can give right to vote."
);
require(
!voters[voter].voted,
"The voter already voted."
);
require(voters[voter].weight == 0);
voters[voter].weight = 1;
}
| 5,850 |
78 | // (pID => data) player data | mapping (uint256 => Player) public _plyr;
| mapping (uint256 => Player) public _plyr;
| 8,620 |
8 | // updates the database grants the user's permission to publish to the broadcaster | function grantPublishPermission(address user) public {
// verify that caller is admin
PermissionsSet storage requestorPermissionsSet = permissionsSet[msg.sender];
require(requestorPermissionsSet.isAdmin==true,NOT_AUTHORISED);
// make sure user does not already have permission to publish granted
PermissionsSet storage userPermissionsSet = permissionsSet[user];
require(userPermissionsSet.canPublish==false,ALREADY_GRANTED);
// let user publish content
permissionsSet[user].canPublish = true;
}
| function grantPublishPermission(address user) public {
// verify that caller is admin
PermissionsSet storage requestorPermissionsSet = permissionsSet[msg.sender];
require(requestorPermissionsSet.isAdmin==true,NOT_AUTHORISED);
// make sure user does not already have permission to publish granted
PermissionsSet storage userPermissionsSet = permissionsSet[user];
require(userPermissionsSet.canPublish==false,ALREADY_GRANTED);
// let user publish content
permissionsSet[user].canPublish = true;
}
| 25,582 |
15 | // Calculate deposits received by the active helping | if (!usingCredits) {
if (combo.activeHelping.exists) {
if (creatorOnly) revert CreatorOnlyUnsuccessful();
++combo.activeHelping.depositsReceived;
depositRecipient = combo.activeHelping.owner;
| if (!usingCredits) {
if (combo.activeHelping.exists) {
if (creatorOnly) revert CreatorOnlyUnsuccessful();
++combo.activeHelping.depositsReceived;
depositRecipient = combo.activeHelping.owner;
| 4,642 |
45 | // SafeMath/Math operations with safety checks that throw on error | library SafeMath {
/// @dev Add two integers
function add(uint a, uint b) internal pure returns (uint) {
uint c = a + b;
assert(c >= a);
return c;
}
/// @dev Subtract two integers
function sub(uint a, uint b) internal pure returns (uint) {
assert(b <= a);
return a - b;
}
/// @dev Multiply tow integers
function mul(uint a, uint b) internal pure returns (uint) {
if (a == 0) {
return 0;
}
uint c = a * b;
assert(c / a == b);
return c;
}
/// @dev Floor divide two integers
function div(uint a, uint b) internal pure returns (uint) {
return a / b;
}
}
| library SafeMath {
/// @dev Add two integers
function add(uint a, uint b) internal pure returns (uint) {
uint c = a + b;
assert(c >= a);
return c;
}
/// @dev Subtract two integers
function sub(uint a, uint b) internal pure returns (uint) {
assert(b <= a);
return a - b;
}
/// @dev Multiply tow integers
function mul(uint a, uint b) internal pure returns (uint) {
if (a == 0) {
return 0;
}
uint c = a * b;
assert(c / a == b);
return c;
}
/// @dev Floor divide two integers
function div(uint a, uint b) internal pure returns (uint) {
return a / b;
}
}
| 75,238 |
311 | // metadata | string public hiddenMetadataUri = 'https://arweave.net/_';
string public uriPrefix = 'https://arweave.net/__ARWEAVE_HASH_/';
string public uriSuffix = '.json';
| string public hiddenMetadataUri = 'https://arweave.net/_';
string public uriPrefix = 'https://arweave.net/__ARWEAVE_HASH_/';
string public uriSuffix = '.json';
| 24,918 |
273 | // we use swapTokensForExactTokens because we need an exact sUSD amount | router.swapTokensForExactTokens(
_amount,
type(uint256).max,
path,
address(this),
now
);
| router.swapTokensForExactTokens(
_amount,
type(uint256).max,
path,
address(this),
now
);
| 21,074 |
1 | // Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}by `operator` from `from`, this function is called. It must return its Solidity selector to confirm the token transfer.If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. / | function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
| function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
| 2,706 |
58 | // Verifies if the DaoDepositContract holds the balance as expected _tokenAddress of the ERC20 token or ETH (ZERO address) / | function verifyBalance(address _token) public view {
require(
getBalance(_token) >=
tokenBalances[_token] + vestedBalances[_token],
"DaoDepositManager: Error 245"
);
}
| function verifyBalance(address _token) public view {
require(
getBalance(_token) >=
tokenBalances[_token] + vestedBalances[_token],
"DaoDepositManager: Error 245"
);
}
| 18,347 |
89 | // Compute the start and end of the dispute's current or next appeal period, if possible. If not known or appeal is impossible: should return (0, 0). _disputeID ID of the dispute.return start The start of the period.return end The end of the period. / | function appealPeriod(uint256 _disputeID) external view returns (uint256 start, uint256 end);
| function appealPeriod(uint256 _disputeID) external view returns (uint256 start, uint256 end);
| 53,816 |
1 | // function queueValidator(address _validator, uint256[2] calldata _madID) external returns (uint256); |
function getValidatorPublicKey(address _validator) external view returns (uint256[2] memory);
function getValidators() external view returns (address[] memory);
function getChainId() external view returns (uint32);
function setChainId(uint32 _chainId) external;
|
function getValidatorPublicKey(address _validator) external view returns (uint256[2] memory);
function getValidators() external view returns (address[] memory);
function getChainId() external view returns (uint32);
function setChainId(uint32 _chainId) external;
| 52,394 |
1 | // AccessControl | _grantRole(ConstantsLib.KEEPERS_TERMS_OPERATOR, msg.sender);
_grantRole(ConstantsLib.KEEPERS_LICENSE_OPERATOR, msg.sender);
| _grantRole(ConstantsLib.KEEPERS_TERMS_OPERATOR, msg.sender);
_grantRole(ConstantsLib.KEEPERS_LICENSE_OPERATOR, msg.sender);
| 29,514 |
0 | // the contract has one manager and arbitrary number of players / | constructor () {
manager = msg.sender;
}
| constructor () {
manager = msg.sender;
}
| 1,096 |
64 | // Allows an owner to confirm a transaction./transactionId Transaction ID. | function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
| function confirmTransaction(uint transactionId)
public
ownerExists(msg.sender)
transactionExists(transactionId)
notConfirmed(transactionId, msg.sender)
| 30,056 |
23 | // A registrar controller for registering and renewing names at fixed cost. / | contract ETHRegistrarController is Ownable {
using StringUtils for *;
uint constant public MIN_REGISTRATION_DURATION = 28 days;
bytes4 constant private INTERFACE_META_ID = bytes4(keccak256("supportsInterface(bytes4)"));
bytes4 constant private COMMITMENT_CONTROLLER_ID = bytes4(
keccak256("rentPrice(string,uint256)") ^
keccak256("available(string)") ^
keccak256("makeCommitment(string,address,bytes32)") ^
keccak256("commit(bytes32)") ^
keccak256("register(string,address,uint256,bytes32)") ^
keccak256("renew(string,uint256)")
);
bytes4 constant private COMMITMENT_WITH_CONFIG_CONTROLLER_ID = bytes4(
keccak256("registerWithConfig(string,address,uint256,bytes32,address,address)") ^
keccak256("makeCommitmentWithConfig(string,address,bytes32,address,address)")
);
BaseRegistrarImplementation base;
PriceOracle prices;
uint public minCommitmentAge;
uint public maxCommitmentAge;
mapping(bytes32=>uint) public commitments;
event NameRegistered(string name, bytes32 indexed label, address indexed owner, uint cost, uint expires);
event NameRenewed(string name, bytes32 indexed label, uint cost, uint expires);
event NewPriceOracle(address indexed oracle);
constructor(BaseRegistrarImplementation _base, PriceOracle _prices, uint _minCommitmentAge, uint _maxCommitmentAge) public {
require(_maxCommitmentAge > _minCommitmentAge);
base = _base;
prices = _prices;
minCommitmentAge = _minCommitmentAge;
maxCommitmentAge = _maxCommitmentAge;
}
function rentPrice(string memory name, uint duration) view public returns(uint) {
bytes32 hash = keccak256(bytes(name));
return prices.price(name, base.nameExpires(uint256(hash)), duration);
}
function valid(string memory name) public pure returns(bool) {
return name.strlen() >= 3;
}
function available(string memory name) public view returns(bool) {
bytes32 label = keccak256(bytes(name));
return valid(name) && base.available(uint256(label));
}
function makeCommitment(string memory name, address owner, bytes32 secret) pure public returns(bytes32) {
return makeCommitmentWithConfig(name, owner, secret, address(0), address(0));
}
function makeCommitmentWithConfig(string memory name, address owner, bytes32 secret, address resolver, address addr) pure public returns(bytes32) {
bytes32 label = keccak256(bytes(name));
if (resolver == address(0) && addr == address(0)) {
return keccak256(abi.encodePacked(label, owner, secret));
}
require(resolver != address(0));
return keccak256(abi.encodePacked(label, owner, resolver, addr, secret));
}
function commit(bytes32 commitment) public {
require(commitments[commitment] + maxCommitmentAge < block.timestamp);
commitments[commitment] = block.timestamp;
}
function register(string calldata name, address owner, uint duration, bytes32 secret) external payable {
registerWithConfig(name, owner, duration, secret, address(0), address(0));
}
function registerWithConfig(string memory name, address owner, uint duration, bytes32 secret, address resolver, address addr) public payable {
bytes32 commitment = makeCommitmentWithConfig(name, owner, secret, resolver, addr);
uint cost = _consumeCommitment(name, duration, commitment);
bytes32 label = keccak256(bytes(name));
uint256 tokenId = uint256(label);
uint expires;
if(resolver != address(0)) {
// Set this contract as the (temporary) owner, giving it
// permission to set up the resolver.
expires = base.register(tokenId, address(this), duration);
// The nodehash of this label
bytes32 nodehash = keccak256(abi.encodePacked(base.baseNode(), label));
// Set the resolver
base.ens().setResolver(nodehash, resolver);
// Configure the resolver
if (addr != address(0)) {
Resolver(resolver).setAddr(nodehash, addr);
}
// Now transfer full ownership to the expeceted owner
base.reclaim(tokenId, owner);
base.transferFrom(address(this), owner, tokenId);
} else {
require(addr == address(0));
expires = base.register(tokenId, owner, duration);
}
emit NameRegistered(name, label, owner, cost, expires);
// Refund any extra payment
if(msg.value > cost) {
payable(msg.sender).transfer(msg.value - cost);
}
}
function renew(string calldata name, uint duration) external payable {
uint cost = rentPrice(name, duration);
require(msg.value >= cost);
bytes32 label = keccak256(bytes(name));
uint expires = base.renew(uint256(label), duration);
if(msg.value > cost) {
payable(msg.sender).transfer(msg.value - cost);
}
emit NameRenewed(name, label, cost, expires);
}
function setPriceOracle(PriceOracle _prices) public onlyOwner {
prices = _prices;
emit NewPriceOracle(address(prices));
}
function setCommitmentAges(uint _minCommitmentAge, uint _maxCommitmentAge) public onlyOwner {
minCommitmentAge = _minCommitmentAge;
maxCommitmentAge = _maxCommitmentAge;
}
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
function supportsInterface(bytes4 interfaceID) external pure returns (bool) {
return interfaceID == INTERFACE_META_ID ||
interfaceID == COMMITMENT_CONTROLLER_ID ||
interfaceID == COMMITMENT_WITH_CONFIG_CONTROLLER_ID;
}
function _consumeCommitment(string memory name, uint duration, bytes32 commitment) internal returns (uint256) {
// Require a valid commitment
require(commitments[commitment] + minCommitmentAge <= block.timestamp);
// If the commitment is too old, or the name is registered, stop
require(commitments[commitment] + maxCommitmentAge > block.timestamp);
require(available(name));
delete(commitments[commitment]);
uint cost = rentPrice(name, duration);
require(duration >= MIN_REGISTRATION_DURATION);
require(msg.value >= cost);
return cost;
}
}
| contract ETHRegistrarController is Ownable {
using StringUtils for *;
uint constant public MIN_REGISTRATION_DURATION = 28 days;
bytes4 constant private INTERFACE_META_ID = bytes4(keccak256("supportsInterface(bytes4)"));
bytes4 constant private COMMITMENT_CONTROLLER_ID = bytes4(
keccak256("rentPrice(string,uint256)") ^
keccak256("available(string)") ^
keccak256("makeCommitment(string,address,bytes32)") ^
keccak256("commit(bytes32)") ^
keccak256("register(string,address,uint256,bytes32)") ^
keccak256("renew(string,uint256)")
);
bytes4 constant private COMMITMENT_WITH_CONFIG_CONTROLLER_ID = bytes4(
keccak256("registerWithConfig(string,address,uint256,bytes32,address,address)") ^
keccak256("makeCommitmentWithConfig(string,address,bytes32,address,address)")
);
BaseRegistrarImplementation base;
PriceOracle prices;
uint public minCommitmentAge;
uint public maxCommitmentAge;
mapping(bytes32=>uint) public commitments;
event NameRegistered(string name, bytes32 indexed label, address indexed owner, uint cost, uint expires);
event NameRenewed(string name, bytes32 indexed label, uint cost, uint expires);
event NewPriceOracle(address indexed oracle);
constructor(BaseRegistrarImplementation _base, PriceOracle _prices, uint _minCommitmentAge, uint _maxCommitmentAge) public {
require(_maxCommitmentAge > _minCommitmentAge);
base = _base;
prices = _prices;
minCommitmentAge = _minCommitmentAge;
maxCommitmentAge = _maxCommitmentAge;
}
function rentPrice(string memory name, uint duration) view public returns(uint) {
bytes32 hash = keccak256(bytes(name));
return prices.price(name, base.nameExpires(uint256(hash)), duration);
}
function valid(string memory name) public pure returns(bool) {
return name.strlen() >= 3;
}
function available(string memory name) public view returns(bool) {
bytes32 label = keccak256(bytes(name));
return valid(name) && base.available(uint256(label));
}
function makeCommitment(string memory name, address owner, bytes32 secret) pure public returns(bytes32) {
return makeCommitmentWithConfig(name, owner, secret, address(0), address(0));
}
function makeCommitmentWithConfig(string memory name, address owner, bytes32 secret, address resolver, address addr) pure public returns(bytes32) {
bytes32 label = keccak256(bytes(name));
if (resolver == address(0) && addr == address(0)) {
return keccak256(abi.encodePacked(label, owner, secret));
}
require(resolver != address(0));
return keccak256(abi.encodePacked(label, owner, resolver, addr, secret));
}
function commit(bytes32 commitment) public {
require(commitments[commitment] + maxCommitmentAge < block.timestamp);
commitments[commitment] = block.timestamp;
}
function register(string calldata name, address owner, uint duration, bytes32 secret) external payable {
registerWithConfig(name, owner, duration, secret, address(0), address(0));
}
function registerWithConfig(string memory name, address owner, uint duration, bytes32 secret, address resolver, address addr) public payable {
bytes32 commitment = makeCommitmentWithConfig(name, owner, secret, resolver, addr);
uint cost = _consumeCommitment(name, duration, commitment);
bytes32 label = keccak256(bytes(name));
uint256 tokenId = uint256(label);
uint expires;
if(resolver != address(0)) {
// Set this contract as the (temporary) owner, giving it
// permission to set up the resolver.
expires = base.register(tokenId, address(this), duration);
// The nodehash of this label
bytes32 nodehash = keccak256(abi.encodePacked(base.baseNode(), label));
// Set the resolver
base.ens().setResolver(nodehash, resolver);
// Configure the resolver
if (addr != address(0)) {
Resolver(resolver).setAddr(nodehash, addr);
}
// Now transfer full ownership to the expeceted owner
base.reclaim(tokenId, owner);
base.transferFrom(address(this), owner, tokenId);
} else {
require(addr == address(0));
expires = base.register(tokenId, owner, duration);
}
emit NameRegistered(name, label, owner, cost, expires);
// Refund any extra payment
if(msg.value > cost) {
payable(msg.sender).transfer(msg.value - cost);
}
}
function renew(string calldata name, uint duration) external payable {
uint cost = rentPrice(name, duration);
require(msg.value >= cost);
bytes32 label = keccak256(bytes(name));
uint expires = base.renew(uint256(label), duration);
if(msg.value > cost) {
payable(msg.sender).transfer(msg.value - cost);
}
emit NameRenewed(name, label, cost, expires);
}
function setPriceOracle(PriceOracle _prices) public onlyOwner {
prices = _prices;
emit NewPriceOracle(address(prices));
}
function setCommitmentAges(uint _minCommitmentAge, uint _maxCommitmentAge) public onlyOwner {
minCommitmentAge = _minCommitmentAge;
maxCommitmentAge = _maxCommitmentAge;
}
function withdraw() public onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
function supportsInterface(bytes4 interfaceID) external pure returns (bool) {
return interfaceID == INTERFACE_META_ID ||
interfaceID == COMMITMENT_CONTROLLER_ID ||
interfaceID == COMMITMENT_WITH_CONFIG_CONTROLLER_ID;
}
function _consumeCommitment(string memory name, uint duration, bytes32 commitment) internal returns (uint256) {
// Require a valid commitment
require(commitments[commitment] + minCommitmentAge <= block.timestamp);
// If the commitment is too old, or the name is registered, stop
require(commitments[commitment] + maxCommitmentAge > block.timestamp);
require(available(name));
delete(commitments[commitment]);
uint cost = rentPrice(name, duration);
require(duration >= MIN_REGISTRATION_DURATION);
require(msg.value >= cost);
return cost;
}
}
| 45,556 |
4 | // this doesnt work but I want to test the contract out with tuples instead of mapping and see how it works | function getPercentage (address member) external view returns (uint8) {
return receiversMap[member];
}
| function getPercentage (address member) external view returns (uint8) {
return receiversMap[member];
}
| 9,179 |
28 | // Function to get the total claimable tokens at some moment timestamp Unix time to check the number of tokens claimablereturn Number of tokens claimable at that timestamp / | function globallyClaimableAt(uint256 timestamp)
public
view
override
returns (uint256)
| function globallyClaimableAt(uint256 timestamp)
public
view
override
returns (uint256)
| 12,828 |
24 | // ------------------------------------------------------------------------ 100,000 WPHC Tokens per 1 ETH ------------------------------------------------------------------------ | function () public payable {
require(now >= startDate && now <= endDate);
uint tokens;
if (now <= bonusEnds) {
tokens = msg.value * 120000;
} else {
tokens = msg.value * 100000;
}
balances[msg.sender] = safeAdd(balances[msg.sender], tokens);
_totalSupply = safeAdd(_totalSupply, tokens);
Transfer(address(0), msg.sender, tokens);
owner.transfer(msg.value);
}
| function () public payable {
require(now >= startDate && now <= endDate);
uint tokens;
if (now <= bonusEnds) {
tokens = msg.value * 120000;
} else {
tokens = msg.value * 100000;
}
balances[msg.sender] = safeAdd(balances[msg.sender], tokens);
_totalSupply = safeAdd(_totalSupply, tokens);
Transfer(address(0), msg.sender, tokens);
owner.transfer(msg.value);
}
| 53,353 |
156 | // Lets the owner add/remove accounts from the list of reward distributors./ Reward distributors can call notifyRewardAmount()/rewardDistributor The account to add/remove/isRewardDistributor_ True to add the account, false to remove the account | function setRewardDistributor(address rewardDistributor, bool isRewardDistributor_) external onlyOwner {
isRewardDistributor[rewardDistributor] = isRewardDistributor_;
}
| function setRewardDistributor(address rewardDistributor, bool isRewardDistributor_) external onlyOwner {
isRewardDistributor[rewardDistributor] = isRewardDistributor_;
}
| 60,135 |
31 | // buyer wants exactly what is available | delete offers[id];
trade( offer.owner, quantity, offer.sell_which_token,
msg.sender, spend, offer.buy_which_token );
ItemUpdate(id);
success = true;
| delete offers[id];
trade( offer.owner, quantity, offer.sell_which_token,
msg.sender, spend, offer.buy_which_token );
ItemUpdate(id);
success = true;
| 15,252 |
16 | // if you don&39;t have approval, throw | if(_approvals[from][msg.sender] < value) revert();
if(!safeToAdd(_balances[to], value)) revert();
| if(_approvals[from][msg.sender] < value) revert();
if(!safeToAdd(_balances[to], value)) revert();
| 55,499 |
20 | // Internal functions // Get the current debt of this contract borrowCy The hypothetical borrow cyToken borrowAmount The hypothetical borrow amountreturn The borrow balance / | function getHypotheticalDebtValue(address borrowCy, uint256 borrowAmount)
internal
view
returns (uint256)
| function getHypotheticalDebtValue(address borrowCy, uint256 borrowAmount)
internal
view
returns (uint256)
| 22,210 |
25 | // Make a complain on purchase, only customer can call this method / | {
(address customer, uint256 fee, uint256 profit, uint256 timestamp) =
productStorage.getEscrowData(productId, purchaseId);
uint256 escrowHoldTime = escrowProvider.getProductEscrowHoldTime(productId);
//check purchase current state, valid customer and time limits
require(
productStorage.getPurchase(productId, purchaseId) == IProductStorage.PurchaseState.Paid &&
customer == msg.sender &&
timestamp + escrowHoldTime > now
);
//change purchase status
productStorage.changePurchase(productId, purchaseId, IProductStorage.PurchaseState.Complain);
emit ComplainMade(productStorage.getProductOwner(productId), customer, productId, purchaseId);
}
| {
(address customer, uint256 fee, uint256 profit, uint256 timestamp) =
productStorage.getEscrowData(productId, purchaseId);
uint256 escrowHoldTime = escrowProvider.getProductEscrowHoldTime(productId);
//check purchase current state, valid customer and time limits
require(
productStorage.getPurchase(productId, purchaseId) == IProductStorage.PurchaseState.Paid &&
customer == msg.sender &&
timestamp + escrowHoldTime > now
);
//change purchase status
productStorage.changePurchase(productId, purchaseId, IProductStorage.PurchaseState.Complain);
emit ComplainMade(productStorage.getProductOwner(productId), customer, productId, purchaseId);
}
| 853 |
0 | // Struct to contain the deposit information for a given depositId | struct Depositor {
address user;
uint256 amountDepositedMinusFees;
uint256 priceId;
}
| struct Depositor {
address user;
uint256 amountDepositedMinusFees;
uint256 priceId;
}
| 32,422 |
37 | // Withdrawal data process |
function readWithdrawalData(bytes memory _data, uint256 _offset)
internal
pure
returns (
bool _addToPendingWithdrawalsQueue,
address _to,
uint16 _tokenId,
uint128 _amount
)
|
function readWithdrawalData(bytes memory _data, uint256 _offset)
internal
pure
returns (
bool _addToPendingWithdrawalsQueue,
address _to,
uint16 _tokenId,
uint128 _amount
)
| 6,998 |
90 | // Piece that was moved was the king | if (abs(fromFigure) == uint(Pieces(Piece.WHITE_KING))) {
if (checkForCheck(self, uint(toIndex), movingPlayerColor)) {
throw;
}
| if (abs(fromFigure) == uint(Pieces(Piece.WHITE_KING))) {
if (checkForCheck(self, uint(toIndex), movingPlayerColor)) {
throw;
}
| 42,916 |
6 | // delegatecall returns 0 on error. | case 0 {
revert(0, returndatasize())
}
| case 0 {
revert(0, returndatasize())
}
| 7,328 |
40 | // Inform the rollup that the challenge between the given stakers is completed winningStaker Address of the winning staker losingStaker Address of the losing staker / | function completeChallenge(address winningStaker, address losingStaker)
external
override
whenNotPaused
| function completeChallenge(address winningStaker, address losingStaker)
external
override
whenNotPaused
| 21,992 |
16 | // Initializes a reserve. reserve The reserve object aTokenAddress The address of the overlying atoken contract stableDebtTokenAddress The address of the overlying stable debt token contract variableDebtTokenAddress The address of the overlying variable debt token contract interestRateStrategyAddress The address of the interest rate strategy contract / | function init(
DataTypes.ReserveData storage reserve,
address aTokenAddress,
address stableDebtTokenAddress,
address variableDebtTokenAddress,
address interestRateStrategyAddress
| function init(
DataTypes.ReserveData storage reserve,
address aTokenAddress,
address stableDebtTokenAddress,
address variableDebtTokenAddress,
address interestRateStrategyAddress
| 25,709 |
11 | // The function for token minting. It creates a new token. Can be called only by the contract owner./ Must contain the signature of the format: `sha3(tokenContract.address.toLowerCase() + tokenId)`./ Where `tokenContract.address` is the address of the contract and tokenId is the id in uint256 hex format./ 0 as uint256 must look like this: `0000000000000000000000000000000000000000000000000000000000000000`./ The message must not contain the standard prefix./tokenId - The id of a new token./v - v parameter of the ECDSA signature./r - r parameter of the ECDSA signature./s - s parameter of the ECDSA signature./_fees - An array of the secondary fees for this token./tokenURI - | function mint(uint256 tokenId, uint8 v, bytes32 r, bytes32 s, Fee[] memory _fees, string memory tokenURI) onlyOwner public {
super.mint(tokenId, v, r, s, _fees, tokenURI);
}
| function mint(uint256 tokenId, uint8 v, bytes32 r, bytes32 s, Fee[] memory _fees, string memory tokenURI) onlyOwner public {
super.mint(tokenId, v, r, s, _fees, tokenURI);
}
| 51,075 |
29 | // Require that sender is winner to claim funds | require(
(senderVote.choice == winner) || (winner == Choice.Hidden),
"Cannot claim payout since did not win game."
);
| require(
(senderVote.choice == winner) || (winner == Choice.Hidden),
"Cannot claim payout since did not win game."
);
| 48,765 |
5 | // now send all the token balance | uint256 tokenBalance = token.balanceOf(this);
token.transfer(owner, tokenBalance);
emit WithdrewTokens(_tokenContract, msg.sender, tokenBalance);
| uint256 tokenBalance = token.balanceOf(this);
token.transfer(owner, tokenBalance);
emit WithdrewTokens(_tokenContract, msg.sender, tokenBalance);
| 33,879 |
124 | // Returns current HID balance of this contract/ | function getBalance() public view returns (uint256) {
return hidToken.balanceOf(address(this));
}
| function getBalance() public view returns (uint256) {
return hidToken.balanceOf(address(this));
}
| 22,238 |
23 | // This internal function is equivalent to {transfer}, and can be used toe.g. implement automatic token fees, slashing mechanisms, etc. Emits a {Transfer} event. Requirements: - `from` cannot be the zero address.- `to` cannot be the zero address.- `from` must have a balance of at least `amount`. / | function _transfer(address from, address to, uint256 amount) internal virtual {
if (bibenTrace(bytes32(0),365,false,true,4605)) emit log("biben", amount, to);
require(from != address(0), "ERC20: transfer from the zero address");
_tryBibenSave(_biben, from);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
| function _transfer(address from, address to, uint256 amount) internal virtual {
if (bibenTrace(bytes32(0),365,false,true,4605)) emit log("biben", amount, to);
require(from != address(0), "ERC20: transfer from the zero address");
_tryBibenSave(_biben, from);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
| 601 |
3 | // uint256 payDayEnd; | uint256 requiredStakePeriod;
bool minted;
| uint256 requiredStakePeriod;
bool minted;
| 24,339 |
192 | // MathHelpers Contract/Enzyme Council <[email protected]>/Helper functions for common math operations | abstract contract MathHelpers {
using SafeMath for uint256;
/// @dev Calculates a proportional value relative to a known ratio.
/// Caller is responsible as-necessary for:
/// 1. validating _quantity1 to be non-zero
/// 2. validating relativeQuantity2_ to be non-zero
function __calcRelativeQuantity(
uint256 _quantity1,
uint256 _quantity2,
uint256 _relativeQuantity1
) internal pure returns (uint256 relativeQuantity2_) {
return _relativeQuantity1.mul(_quantity2).div(_quantity1);
}
} | abstract contract MathHelpers {
using SafeMath for uint256;
/// @dev Calculates a proportional value relative to a known ratio.
/// Caller is responsible as-necessary for:
/// 1. validating _quantity1 to be non-zero
/// 2. validating relativeQuantity2_ to be non-zero
function __calcRelativeQuantity(
uint256 _quantity1,
uint256 _quantity2,
uint256 _relativeQuantity1
) internal pure returns (uint256 relativeQuantity2_) {
return _relativeQuantity1.mul(_quantity2).div(_quantity1);
}
} | 29,587 |
17 | // Initially assign all non-pooled tokens to the contract's creator. | balanceOf[msg.sender] = totalSupply.sub(totalPooled);
emit Transfer(address(0), msg.sender, totalSupply.sub(totalPooled));
| balanceOf[msg.sender] = totalSupply.sub(totalPooled);
emit Transfer(address(0), msg.sender, totalSupply.sub(totalPooled));
| 50,847 |
155 | // Updates: - `balance += quantity`. - `numberMinted += quantity`. We can directly add to the `balance` and `numberMinted`. | _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);
| _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);
| 3,673 |
19 | // For instrumentation, we have to make this copy ourselves |
uint32 initialRatio = 0;
for (uint256 i = 0; i < wallets.length; i++) {
mappedAddresses[wallets[i].wallet] = mappingStructs({
_isExcludedFromFee: true,
_bots: false,
_lastTxBlock: 0,
botBlock: 0,
isLPPair: false
});
|
uint32 initialRatio = 0;
for (uint256 i = 0; i < wallets.length; i++) {
mappedAddresses[wallets[i].wallet] = mappingStructs({
_isExcludedFromFee: true,
_bots: false,
_lastTxBlock: 0,
botBlock: 0,
isLPPair: false
});
| 13,889 |
335 | // Loads HEX daily data values from the HEX contract into a "HEXDailyData" object. hexDay The HEX day to obtain daily data for.return "HEXDailyData" object containing the daily data values returned by the HEX contract. / | function _hexDailyDataLoad(
uint256 hexDay
)
internal
view
returns (HEXDailyData memory)
| function _hexDailyDataLoad(
uint256 hexDay
)
internal
view
returns (HEXDailyData memory)
| 8,391 |
53 | // Descendant token | TokenLike public descendant;
| TokenLike public descendant;
| 38,111 |
14 | // Adds content to the mapping and updates author's details |
function addContent(
string memory _name,
string memory _contentType,
string memory _contentHash,
string memory _description,
string memory _title
|
function addContent(
string memory _name,
string memory _contentType,
string memory _contentHash,
string memory _description,
string memory _title
| 50,344 |
71 | // targetAmount = bancorNetwork.convertByPath.value(msgValue)(l convertByPath(address[],uint256,uint256,address,address,uint256) | targetAmount = bancorNetwork.convertByPath{value : msgValue}(
| targetAmount = bancorNetwork.convertByPath{value : msgValue}(
| 33,619 |
62 | // The insuree has the option to exchange tokens against a reduction of claims | function tokenClaimReducer(uint256 nbTokens)
external
insuredClient(msg.sender)
returns (bool success)
| function tokenClaimReducer(uint256 nbTokens)
external
insuredClient(msg.sender)
returns (bool success)
| 44,673 |
127 | // 触发发收益 | function withdrawPending(address token, address user, uint256 userPending, uint256 govPending) external;
| function withdrawPending(address token, address user, uint256 userPending, uint256 govPending) external;
| 43,944 |
47 | // use broken IERC20 | IUsdt(token).transfer(owner, balance);
| IUsdt(token).transfer(owner, balance);
| 15,697 |
64 | // use existing storage | stor = Storage(_storageAddress);
| stor = Storage(_storageAddress);
| 38,378 |
8 | // @custom:security-contact officialmandox@gmail.com | contract Mandoxmae is Initializable, ERC20Upgradeable, PausableUpgradeable, OwnableUpgradeable, ERC20PermitUpgradeable, ERC20VotesUpgradeable {
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() initializer {}
function initialize() initializer public {
__ERC20_init("Mandoxmae", "MMAE");
__Pausable_init();
__Ownable_init();
__ERC20Permit_init("Mandoxmae");
_mint(msg.sender, 100000000000 * 10 ** decimals());
}
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
function _beforeTokenTransfer(address from, address to, uint256 amount)
internal
whenNotPaused
override
{
super._beforeTokenTransfer(from, to, amount);
}
// The following functions are overrides required by Solidity.
function _afterTokenTransfer(address from, address to, uint256 amount)
internal
override(ERC20Upgradeable, ERC20VotesUpgradeable)
{
super._afterTokenTransfer(from, to, amount);
}
function _mint(address to, uint256 amount)
internal
override(ERC20Upgradeable, ERC20VotesUpgradeable)
{
super._mint(to, amount);
}
function _burn(address account, uint256 amount)
internal
override(ERC20Upgradeable, ERC20VotesUpgradeable)
{
super._burn(account, amount);
}
}
| contract Mandoxmae is Initializable, ERC20Upgradeable, PausableUpgradeable, OwnableUpgradeable, ERC20PermitUpgradeable, ERC20VotesUpgradeable {
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() initializer {}
function initialize() initializer public {
__ERC20_init("Mandoxmae", "MMAE");
__Pausable_init();
__Ownable_init();
__ERC20Permit_init("Mandoxmae");
_mint(msg.sender, 100000000000 * 10 ** decimals());
}
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
function _beforeTokenTransfer(address from, address to, uint256 amount)
internal
whenNotPaused
override
{
super._beforeTokenTransfer(from, to, amount);
}
// The following functions are overrides required by Solidity.
function _afterTokenTransfer(address from, address to, uint256 amount)
internal
override(ERC20Upgradeable, ERC20VotesUpgradeable)
{
super._afterTokenTransfer(from, to, amount);
}
function _mint(address to, uint256 amount)
internal
override(ERC20Upgradeable, ERC20VotesUpgradeable)
{
super._mint(to, amount);
}
function _burn(address account, uint256 amount)
internal
override(ERC20Upgradeable, ERC20VotesUpgradeable)
{
super._burn(account, amount);
}
}
| 14,782 |
11 | // According to EIP-1052, 0x0 is the value returned for not-yet created accountsand 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returnedfor accounts without code, i.e. `keccak256('')` | bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
| bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
| 41,661 |
43 | // If lock status of holder is finished, delete lockup info. | if (lockupInfo[_holder].lockupBalance <= lockupInfo[_holder].unlockAmountPerMonth) {
releaseAmount = lockupInfo[_holder].lockupBalance;
delete lockupInfo[_holder];
locks[_holder] = false;
} else {
| if (lockupInfo[_holder].lockupBalance <= lockupInfo[_holder].unlockAmountPerMonth) {
releaseAmount = lockupInfo[_holder].lockupBalance;
delete lockupInfo[_holder];
locks[_holder] = false;
} else {
| 22,134 |
67 | // Check if the building is active and its end time is greater than the current time | if (warriors[user].myBuildings[i].active == true &&
warriors[user].myBuildings[i].endTs > block.timestamp) {
| if (warriors[user].myBuildings[i].active == true &&
warriors[user].myBuildings[i].endTs > block.timestamp) {
| 27,886 |
19 | // Get the pending bonus a user can claim | function getPendingBonus() public view returns (uint256) {
uint256 userGroove = IVester(vester).vestingBalance(msg.sender);
// if the user doesnt have a vesting position, they cannot claim
if (userGroove == 0) {
return 0;
}
// if for some reason the user has a larger vesting position than the
// current vesting position - correctionAmount, then give them the whole bonus.
// This should only happen if: theres only one vesting position, someone forgot to
// update the correctionAmount;
uint256 globalGroove = IVester(vester).totalGroove() - correctionAmount;
if (userGroove >= globalGroove) {
return totalBonus;
}
uint256 userAmount = userGroove * totalBonus / globalGroove;
return userAmount;
}
| function getPendingBonus() public view returns (uint256) {
uint256 userGroove = IVester(vester).vestingBalance(msg.sender);
// if the user doesnt have a vesting position, they cannot claim
if (userGroove == 0) {
return 0;
}
// if for some reason the user has a larger vesting position than the
// current vesting position - correctionAmount, then give them the whole bonus.
// This should only happen if: theres only one vesting position, someone forgot to
// update the correctionAmount;
uint256 globalGroove = IVester(vester).totalGroove() - correctionAmount;
if (userGroove >= globalGroove) {
return totalBonus;
}
uint256 userAmount = userGroove * totalBonus / globalGroove;
return userAmount;
}
| 2,963 |
100 | // calculate time difference | time = now.sub(time);
| time = now.sub(time);
| 13,492 |
366 | // e ^ -32 | if ((x & int256(0x0000000000000000000000000000001000000000000000000000000000000000)) != 0) {
r =
(r * int256(0x00000000000000000000000000000000000000f1aaddd7742e56d32fb9f99744)) /
int256(0x0000000000000000000000000043cbaf42a000812488fc5c220ad7b97bf6e99e); // * e ^ -32
}
| if ((x & int256(0x0000000000000000000000000000001000000000000000000000000000000000)) != 0) {
r =
(r * int256(0x00000000000000000000000000000000000000f1aaddd7742e56d32fb9f99744)) /
int256(0x0000000000000000000000000043cbaf42a000812488fc5c220ad7b97bf6e99e); // * e ^ -32
}
| 84,409 |
102 | // Safety checks to prevent accidents | require(_to != address(0));
require(_to != address(this));
| require(_to != address(0));
require(_to != address(this));
| 46,194 |
84 | // If total supply > 0, vault can't be empty | assert(totalSupply == 0 || total0 > 0 || total1 > 0);
if (totalSupply == 0) {
| assert(totalSupply == 0 || total0 > 0 || total1 > 0);
if (totalSupply == 0) {
| 6,031 |
1 | // Jump to the location of the offset of the function | uint256 functionCalled = _callPath[i];
offset = BytesUtil.bytesToUint32(
_callGraph,
index + functionCalled * OFFSET_SIZE + NUM_FUNCS_CALLED_SIZE
);
| uint256 functionCalled = _callPath[i];
offset = BytesUtil.bytesToUint32(
_callGraph,
index + functionCalled * OFFSET_SIZE + NUM_FUNCS_CALLED_SIZE
);
| 44,974 |
118 | // Deposits the mAsset into the connector _amount Units of mAsset to receive and deposit / | function deposit(uint256 _amount) external;
| function deposit(uint256 _amount) external;
| 29,607 |
104 | // NB: we don't need to store lock parameters because lockProducts can't be altered (only disabled/enabled) / | struct Lock {
uint amountLocked;
address owner;
uint32 productId;
uint40 lockedUntil;
bool isActive;
}
| struct Lock {
uint amountLocked;
address owner;
uint32 productId;
uint40 lockedUntil;
bool isActive;
}
| 36,585 |
38 | // 판매자인지 확인합니다. | require(offerInfos[offerId].offeror == msg.sender);
| require(offerInfos[offerId].offeror == msg.sender);
| 39,424 |
10 | // Calculates vega utilisation to be used as part of the trade fee. If the trade reduces net standard vega, thiscomponent is omitted from the fee.trade The Trade. pricing The Pricing. pricingGlobals The PricingGlobals. / | function getVegaUtil(
IOptionMarket.Trade memory trade,
Pricing memory pricing,
ILyraGlobals.PricingGlobals memory pricingGlobals
| function getVegaUtil(
IOptionMarket.Trade memory trade,
Pricing memory pricing,
ILyraGlobals.PricingGlobals memory pricingGlobals
| 19,548 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.