Unnamed: 0 int64 0 7.36k | comments stringlengths 3 35.2k | code_string stringlengths 1 527k | code stringlengths 1 527k | __index_level_0__ int64 0 88.6k |
|---|---|---|---|---|
14 | // All Types | function identifier(bytes29 _view) internal pure returns (uint8) {
return uint8(_view.indexUint(0, 1));
}
| function identifier(bytes29 _view) internal pure returns (uint8) {
return uint8(_view.indexUint(0, 1));
}
| 27,852 |
182 | // The amount of tokens to burn | uint256 burnAmount = _amount.mul(burnFeePercent).div(100);
| uint256 burnAmount = _amount.mul(burnFeePercent).div(100);
| 26,486 |
24 | // Factory contract: keeps track of meme for only leaderboard and view purposes | contract MemeRecorder {
address[] public memeContracts;
constructor() public {}
function addMeme(string _ipfsHash, string _name) public {
Meme newMeme;
newMeme = new Meme(_ipfsHash, msg.sender, _name, 18, 1, 10000000000);
memeContracts.push(newMeme);
}
function getMemes() public view returns(address[]) {
return memeContracts;
}
} | contract MemeRecorder {
address[] public memeContracts;
constructor() public {}
function addMeme(string _ipfsHash, string _name) public {
Meme newMeme;
newMeme = new Meme(_ipfsHash, msg.sender, _name, 18, 1, 10000000000);
memeContracts.push(newMeme);
}
function getMemes() public view returns(address[]) {
return memeContracts;
}
} | 69,262 |
240 | // Domain and version for use in signatures (EIP-712) | bytes constant internal DOMAIN_NAME = "SWAP";
bytes constant internal DOMAIN_VERSION = "2";
| bytes constant internal DOMAIN_NAME = "SWAP";
bytes constant internal DOMAIN_VERSION = "2";
| 26,331 |
9 | // =============== ERC721x =============== | function supportsInterface(bytes4 _interfaceId)
public
view
virtual
override(ERC2981, ERC4907A)
returns (bool)
| function supportsInterface(bytes4 _interfaceId)
public
view
virtual
override(ERC2981, ERC4907A)
returns (bool)
| 31,858 |
54 | // Initiate Payout / | function InitiatePayout(address _addr, string _exchange, string _token) external
onlyOwner
| function InitiatePayout(address _addr, string _exchange, string _token) external
onlyOwner
| 2,465 |
6 | // ============ Re-entrency vulnerabilities ============ / | modifier callerIsUser() {
require(tx.origin == msg.sender, "The caller is another contract");
_;
}
| modifier callerIsUser() {
require(tx.origin == msg.sender, "The caller is another contract");
_;
}
| 24,786 |
32 | // add ref. bonus | _dividends += referralBalance_[_customerAddress];
referralBalance_[_customerAddress] = 0;
if (_recipient == address(0x0)){
_recipient = msg.sender;
}
| _dividends += referralBalance_[_customerAddress];
referralBalance_[_customerAddress] = 0;
if (_recipient == address(0x0)){
_recipient = msg.sender;
}
| 52,260 |
10 | // Make sure the claim has a valid id | require(_claim.id > 0 && _claim.id <= claimCount);
| require(_claim.id > 0 && _claim.id <= claimCount);
| 42,709 |
289 | // Initialize the stored rewards | rewardsPerTokenStored.push(0);
| rewardsPerTokenStored.push(0);
| 71,309 |
1 | // Administrator for this contract / | address public admin;
address public underWriterAdmin;
| address public admin;
address public underWriterAdmin;
| 27,224 |
147 | // The easiest way to bubble the revert reason is using memory via assembly |
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
|
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
| 32,035 |
87 | // Calculates referrer bonusvalue of etherto get bonus for return bonus tokens/ | function getReferrerBonus(uint256 value) view public returns(uint256) {
return value.mul(baseRate).mul(referrerBonusPercent).div(PERCENT_DIVIDER);
}
| function getReferrerBonus(uint256 value) view public returns(uint256) {
return value.mul(baseRate).mul(referrerBonusPercent).div(PERCENT_DIVIDER);
}
| 20,621 |
15 | // Move the OSD gas compensation to the Gas Pool | _withdrawOSD(contractsCache.activePool, contractsCache.osdToken, gasPoolAddress, OSD_GAS_COMPENSATION, OSD_GAS_COMPENSATION);
emit VaultUpdated(msg.sender, vars.compositeDebt, vars.netColl, vars.stake, uint8(BorrowerOperation.openVault));
emit BorrowFeeInROSE(msg.sender, vars.ROSEFee);
| _withdrawOSD(contractsCache.activePool, contractsCache.osdToken, gasPoolAddress, OSD_GAS_COMPENSATION, OSD_GAS_COMPENSATION);
emit VaultUpdated(msg.sender, vars.compositeDebt, vars.netColl, vars.stake, uint8(BorrowerOperation.openVault));
emit BorrowFeeInROSE(msg.sender, vars.ROSEFee);
| 31,258 |
51 | // Allow withdrawing any token other than the relevant one / | function releaseForeignToken(ERC20 _token, uint256 amount) onlyOwner {
require(_token != token);
_token.transfer(owner, amount);
}
| function releaseForeignToken(ERC20 _token, uint256 amount) onlyOwner {
require(_token != token);
_token.transfer(owner, amount);
}
| 21,827 |
14 | // uint8 r = fromHexChar(uint8(ss[0]))16 + fromHexChar(uint8(ss[1])); | for (uint i = 0; i < ss.length / 2; ++i) {
r[i] = bytes1(fromHexChar(uint8(ss[2*i])) * 16 +
fromHexChar(uint8(ss[2*i+1])));
}
| for (uint i = 0; i < ss.length / 2; ++i) {
r[i] = bytes1(fromHexChar(uint8(ss[2*i])) * 16 +
fromHexChar(uint8(ss[2*i+1])));
}
| 22,159 |
33 | // Safely manipulate unsigned fixed-point decimals at a given precision level. Functions accepting uints in this contract and derived contractsare taken to be such fixed point decimals of a specified precision (either standardor high). / | library SafeDecimalMath {
using SafeMath for uint;
/* Number of decimal places in the representations. */
uint8 public constant decimals = 18;
uint8 public constant highPrecisionDecimals = 27;
/* The number representing 1.0. */
uint public constant UNIT = 10 ** uint(decimals);
/* The number representing 1.0 for higher fidelity numbers. */
uint public constant PRECISE_UNIT = 10 ** uint(highPrecisionDecimals);
uint private constant UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR = 10 ** uint(highPrecisionDecimals - decimals);
/**
* @return Provides an interface to UNIT.
*/
function unit()
external
pure
returns (uint)
{
return UNIT;
}
/**
* @return Provides an interface to PRECISE_UNIT.
*/
function preciseUnit()
external
pure
returns (uint)
{
return PRECISE_UNIT;
}
/**
* @return The result of multiplying x and y, interpreting the operands as fixed-point
* decimals.
*
* @dev A unit factor is divided out after the product of x and y is evaluated,
* so that product must be less than 2**256. As this is an integer division,
* the internal division always rounds down. This helps save on gas. Rounding
* is more expensive on gas.
*/
function multiplyDecimal(uint x, uint y)
internal
pure
returns (uint)
{
/* Divide by UNIT to remove the extra factor introduced by the product. */
return x.mul(y) / UNIT;
}
/**
* @return The result of safely multiplying x and y, interpreting the operands
* as fixed-point decimals of the specified precision unit.
*
* @dev The operands should be in the form of a the specified unit factor which will be
* divided out after the product of x and y is evaluated, so that product must be
* less than 2**256.
*
* Unlike multiplyDecimal, this function rounds the result to the nearest increment.
* Rounding is useful when you need to retain fidelity for small decimal numbers
* (eg. small fractions or percentages).
*/
function _multiplyDecimalRound(uint x, uint y, uint precisionUnit)
private
pure
returns (uint)
{
/* Divide by UNIT to remove the extra factor introduced by the product. */
uint quotientTimesTen = x.mul(y) / (precisionUnit / 10);
if (quotientTimesTen % 10 >= 5) {
quotientTimesTen += 10;
}
return quotientTimesTen / 10;
}
/**
* @return The result of safely multiplying x and y, interpreting the operands
* as fixed-point decimals of a precise unit.
*
* @dev The operands should be in the precise unit factor which will be
* divided out after the product of x and y is evaluated, so that product must be
* less than 2**256.
*
* Unlike multiplyDecimal, this function rounds the result to the nearest increment.
* Rounding is useful when you need to retain fidelity for small decimal numbers
* (eg. small fractions or percentages).
*/
function multiplyDecimalRoundPrecise(uint x, uint y)
internal
pure
returns (uint)
{
return _multiplyDecimalRound(x, y, PRECISE_UNIT);
}
/**
* @return The result of safely multiplying x and y, interpreting the operands
* as fixed-point decimals of a standard unit.
*
* @dev The operands should be in the standard unit factor which will be
* divided out after the product of x and y is evaluated, so that product must be
* less than 2**256.
*
* Unlike multiplyDecimal, this function rounds the result to the nearest increment.
* Rounding is useful when you need to retain fidelity for small decimal numbers
* (eg. small fractions or percentages).
*/
function multiplyDecimalRound(uint x, uint y)
internal
pure
returns (uint)
{
return _multiplyDecimalRound(x, y, UNIT);
}
/**
* @return The result of safely dividing x and y. The return value is a high
* precision decimal.
*
* @dev y is divided after the product of x and the standard precision unit
* is evaluated, so the product of x and UNIT must be less than 2**256. As
* this is an integer division, the result is always rounded down.
* This helps save on gas. Rounding is more expensive on gas.
*/
function divideDecimal(uint x, uint y)
internal
pure
returns (uint)
{
/* Reintroduce the UNIT factor that will be divided out by y. */
return x.mul(UNIT).div(y);
}
/**
* @return The result of safely dividing x and y. The return value is as a rounded
* decimal in the precision unit specified in the parameter.
*
* @dev y is divided after the product of x and the specified precision unit
* is evaluated, so the product of x and the specified precision unit must
* be less than 2**256. The result is rounded to the nearest increment.
*/
function _divideDecimalRound(uint x, uint y, uint precisionUnit)
private
pure
returns (uint)
{
uint resultTimesTen = x.mul(precisionUnit * 10).div(y);
if (resultTimesTen % 10 >= 5) {
resultTimesTen += 10;
}
return resultTimesTen / 10;
}
/**
* @return The result of safely dividing x and y. The return value is as a rounded
* standard precision decimal.
*
* @dev y is divided after the product of x and the standard precision unit
* is evaluated, so the product of x and the standard precision unit must
* be less than 2**256. The result is rounded to the nearest increment.
*/
function divideDecimalRound(uint x, uint y)
internal
pure
returns (uint)
{
return _divideDecimalRound(x, y, UNIT);
}
/**
* @return The result of safely dividing x and y. The return value is as a rounded
* high precision decimal.
*
* @dev y is divided after the product of x and the high precision unit
* is evaluated, so the product of x and the high precision unit must
* be less than 2**256. The result is rounded to the nearest increment.
*/
function divideDecimalRoundPrecise(uint x, uint y)
internal
pure
returns (uint)
{
return _divideDecimalRound(x, y, PRECISE_UNIT);
}
/**
* @dev Convert a standard decimal representation to a high precision one.
*/
function decimalToPreciseDecimal(uint i)
internal
pure
returns (uint)
{
return i.mul(UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR);
}
/**
* @dev Convert a high precision decimal to a standard decimal representation.
*/
function preciseDecimalToDecimal(uint i)
internal
pure
returns (uint)
{
uint quotientTimesTen = i / (UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR / 10);
if (quotientTimesTen % 10 >= 5) {
quotientTimesTen += 10;
}
return quotientTimesTen / 10;
}
}
| library SafeDecimalMath {
using SafeMath for uint;
/* Number of decimal places in the representations. */
uint8 public constant decimals = 18;
uint8 public constant highPrecisionDecimals = 27;
/* The number representing 1.0. */
uint public constant UNIT = 10 ** uint(decimals);
/* The number representing 1.0 for higher fidelity numbers. */
uint public constant PRECISE_UNIT = 10 ** uint(highPrecisionDecimals);
uint private constant UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR = 10 ** uint(highPrecisionDecimals - decimals);
/**
* @return Provides an interface to UNIT.
*/
function unit()
external
pure
returns (uint)
{
return UNIT;
}
/**
* @return Provides an interface to PRECISE_UNIT.
*/
function preciseUnit()
external
pure
returns (uint)
{
return PRECISE_UNIT;
}
/**
* @return The result of multiplying x and y, interpreting the operands as fixed-point
* decimals.
*
* @dev A unit factor is divided out after the product of x and y is evaluated,
* so that product must be less than 2**256. As this is an integer division,
* the internal division always rounds down. This helps save on gas. Rounding
* is more expensive on gas.
*/
function multiplyDecimal(uint x, uint y)
internal
pure
returns (uint)
{
/* Divide by UNIT to remove the extra factor introduced by the product. */
return x.mul(y) / UNIT;
}
/**
* @return The result of safely multiplying x and y, interpreting the operands
* as fixed-point decimals of the specified precision unit.
*
* @dev The operands should be in the form of a the specified unit factor which will be
* divided out after the product of x and y is evaluated, so that product must be
* less than 2**256.
*
* Unlike multiplyDecimal, this function rounds the result to the nearest increment.
* Rounding is useful when you need to retain fidelity for small decimal numbers
* (eg. small fractions or percentages).
*/
function _multiplyDecimalRound(uint x, uint y, uint precisionUnit)
private
pure
returns (uint)
{
/* Divide by UNIT to remove the extra factor introduced by the product. */
uint quotientTimesTen = x.mul(y) / (precisionUnit / 10);
if (quotientTimesTen % 10 >= 5) {
quotientTimesTen += 10;
}
return quotientTimesTen / 10;
}
/**
* @return The result of safely multiplying x and y, interpreting the operands
* as fixed-point decimals of a precise unit.
*
* @dev The operands should be in the precise unit factor which will be
* divided out after the product of x and y is evaluated, so that product must be
* less than 2**256.
*
* Unlike multiplyDecimal, this function rounds the result to the nearest increment.
* Rounding is useful when you need to retain fidelity for small decimal numbers
* (eg. small fractions or percentages).
*/
function multiplyDecimalRoundPrecise(uint x, uint y)
internal
pure
returns (uint)
{
return _multiplyDecimalRound(x, y, PRECISE_UNIT);
}
/**
* @return The result of safely multiplying x and y, interpreting the operands
* as fixed-point decimals of a standard unit.
*
* @dev The operands should be in the standard unit factor which will be
* divided out after the product of x and y is evaluated, so that product must be
* less than 2**256.
*
* Unlike multiplyDecimal, this function rounds the result to the nearest increment.
* Rounding is useful when you need to retain fidelity for small decimal numbers
* (eg. small fractions or percentages).
*/
function multiplyDecimalRound(uint x, uint y)
internal
pure
returns (uint)
{
return _multiplyDecimalRound(x, y, UNIT);
}
/**
* @return The result of safely dividing x and y. The return value is a high
* precision decimal.
*
* @dev y is divided after the product of x and the standard precision unit
* is evaluated, so the product of x and UNIT must be less than 2**256. As
* this is an integer division, the result is always rounded down.
* This helps save on gas. Rounding is more expensive on gas.
*/
function divideDecimal(uint x, uint y)
internal
pure
returns (uint)
{
/* Reintroduce the UNIT factor that will be divided out by y. */
return x.mul(UNIT).div(y);
}
/**
* @return The result of safely dividing x and y. The return value is as a rounded
* decimal in the precision unit specified in the parameter.
*
* @dev y is divided after the product of x and the specified precision unit
* is evaluated, so the product of x and the specified precision unit must
* be less than 2**256. The result is rounded to the nearest increment.
*/
function _divideDecimalRound(uint x, uint y, uint precisionUnit)
private
pure
returns (uint)
{
uint resultTimesTen = x.mul(precisionUnit * 10).div(y);
if (resultTimesTen % 10 >= 5) {
resultTimesTen += 10;
}
return resultTimesTen / 10;
}
/**
* @return The result of safely dividing x and y. The return value is as a rounded
* standard precision decimal.
*
* @dev y is divided after the product of x and the standard precision unit
* is evaluated, so the product of x and the standard precision unit must
* be less than 2**256. The result is rounded to the nearest increment.
*/
function divideDecimalRound(uint x, uint y)
internal
pure
returns (uint)
{
return _divideDecimalRound(x, y, UNIT);
}
/**
* @return The result of safely dividing x and y. The return value is as a rounded
* high precision decimal.
*
* @dev y is divided after the product of x and the high precision unit
* is evaluated, so the product of x and the high precision unit must
* be less than 2**256. The result is rounded to the nearest increment.
*/
function divideDecimalRoundPrecise(uint x, uint y)
internal
pure
returns (uint)
{
return _divideDecimalRound(x, y, PRECISE_UNIT);
}
/**
* @dev Convert a standard decimal representation to a high precision one.
*/
function decimalToPreciseDecimal(uint i)
internal
pure
returns (uint)
{
return i.mul(UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR);
}
/**
* @dev Convert a high precision decimal to a standard decimal representation.
*/
function preciseDecimalToDecimal(uint i)
internal
pure
returns (uint)
{
uint quotientTimesTen = i / (UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR / 10);
if (quotientTimesTen % 10 >= 5) {
quotientTimesTen += 10;
}
return quotientTimesTen / 10;
}
}
| 6,032 |
4 | // add a function prefixed with test here so forge coverage will ignore this file | function testChillOnHelper() public {}
}
| function testChillOnHelper() public {}
}
| 16,686 |
105 | // Explicit conversion to address takes bottom 160 bits | address expected = address(uint256(keccak256(abi.encodePacked(product))));
return (actual == expected);
| address expected = address(uint256(keccak256(abi.encodePacked(product))));
return (actual == expected);
| 26,379 |
191 | // Initial price is 0 and increases by 0.01 ETH every 100 tokens until reaching 0.08 ETH. The price will remain at 0.08 ETH for nearly the remainder of the mint. When only 200 tokens remain the price will increase once more to 0.09 ETH. When only 100 tokens remain the price will update to the final price of 0.10 ETH. |
require(tx.origin == msg.sender, "Minting from another contract is not supported.");
if (currentPrice == 0) {
require(balanceOf(msg.sender) + quantity <= MAX_FREE_PER_WALLET, "The max a single wallet can mint when price is 0.00 ETH is 5. Once the price is higher than 0, the max a single wallet can mint is 20.");
} else {
|
require(tx.origin == msg.sender, "Minting from another contract is not supported.");
if (currentPrice == 0) {
require(balanceOf(msg.sender) + quantity <= MAX_FREE_PER_WALLET, "The max a single wallet can mint when price is 0.00 ETH is 5. Once the price is higher than 0, the max a single wallet can mint is 20.");
} else {
| 47,566 |
20 | // Standard Way of deriving salt | bytes32 salt = keccak256(abi.encode(_user, _saltNonce));
| bytes32 salt = keccak256(abi.encode(_user, _saltNonce));
| 21,780 |
35 | // Get parameters of many collaterals assets asset addresses owner owner address / | function getMultiCollateralParameters(address[] calldata assets, address owner)
external
view
returns (CollateralParameters[] memory r)
{
uint length = assets.length;
| function getMultiCollateralParameters(address[] calldata assets, address owner)
external
view
returns (CollateralParameters[] memory r)
{
uint length = assets.length;
| 55,769 |
227 | // Checks the whitelist for msg.sender.// Reverts if msg.sender is not in the whitelist. | function _onlyWhitelisted() internal view {
// Check if the message sender is an EOA. In the future, this potentially may break. It is important that functions
// which rely on the whitelist not be explicitly vulnerable in the situation where this no longer holds true.
if (tx.origin == msg.sender) {
return;
}
// Only check the whitelist for calls from contracts.
if (!IWhitelist(whitelist).isWhitelisted(msg.sender)) {
revert Unauthorized();
}
}
| function _onlyWhitelisted() internal view {
// Check if the message sender is an EOA. In the future, this potentially may break. It is important that functions
// which rely on the whitelist not be explicitly vulnerable in the situation where this no longer holds true.
if (tx.origin == msg.sender) {
return;
}
// Only check the whitelist for calls from contracts.
if (!IWhitelist(whitelist).isWhitelisted(msg.sender)) {
revert Unauthorized();
}
}
| 69,056 |
46 | // public variables of reward distribution | mapping(address => uint256) public investorContribution; //Track record whether token holder exist or not
address[] public icoContributors; //Array of addresses of ICO contributors
uint256 public tokenHolderIndex = 0; //To split the iterations of For Loop
uint256 public totalContributors = 0; //Total number of ICO contributors
| mapping(address => uint256) public investorContribution; //Track record whether token holder exist or not
address[] public icoContributors; //Array of addresses of ICO contributors
uint256 public tokenHolderIndex = 0; //To split the iterations of For Loop
uint256 public totalContributors = 0; //Total number of ICO contributors
| 24,367 |
9 | // shares The amount of shares that would be minted/ return assets The amount of assets that would be required, under ideal conditions only | function previewMint(uint256 shares) external view returns (uint256 assets);
| function previewMint(uint256 shares) external view returns (uint256 assets);
| 38,975 |
24 | // initial min amount is 0 revert in case we received 0 tokens after swap | if (_amount <= minTokenAmount[_transitToken]) {
revert LessOrEqualsMinAmount();
}
| if (_amount <= minTokenAmount[_transitToken]) {
revert LessOrEqualsMinAmount();
}
| 26,787 |
8 | // The Ownable constructor sets the original `owner` o the contract to the sender account/ | constructor() public {
_owner = msg.sender;
}
| constructor() public {
_owner = msg.sender;
}
| 1,906 |
127 | // Emitted when an address has been added to or removed from the token transfer allowlist. accountAddress that was added to or removed from the token transfer allowlist.isAllowedTrue if the address was added to the allowlist, false if removed. / | event TransferAllowlistUpdated(
address account,
bool isAllowed
);
| event TransferAllowlistUpdated(
address account,
bool isAllowed
);
| 27,582 |
240 | // now let's check if there is better apr somewhere else.If there is and profit potential is worth changing then lets do it | (uint256 lowest, uint256 lowestApr, , uint256 potential) = estimateAdjustPosition();
| (uint256 lowest, uint256 lowestApr, , uint256 potential) = estimateAdjustPosition();
| 5,902 |
190 | // finally transfer the ether, this withdrawal pattern prevents re-entry attacks | msg.sender.transfer(revenue);
Transfer(msg.sender, this, _amount);
return revenue;
| msg.sender.transfer(revenue);
Transfer(msg.sender, this, _amount);
return revenue;
| 45,830 |
14 | // permit transaction | bool isLock = true;
| bool isLock = true;
| 15,597 |
6 | // The next token ID of the NFT to "lazy mint". | uint256 public nextTokenIdToMint;
| uint256 public nextTokenIdToMint;
| 71,781 |
27 | // Allows for the total credit (bonus + non-bonus) of an address to be queried. This is a constant function which does not alter the state of the contract and therefore does notrequire any gas or a signature to be executed._addr The address of which to query the total credits. return The total amount of credit the address has (bonus + non-bonus credit)./ | function getTotalDropsOf(address _addr) public view returns(uint256) {
return getDropsOf(_addr).add(getBonusDropsOf(_addr));
}
| function getTotalDropsOf(address _addr) public view returns(uint256) {
return getDropsOf(_addr).add(getBonusDropsOf(_addr));
}
| 21,974 |
59 | // https:docs.Pynthetix.io/contracts/source/contracts/Pynthetixstate | contract PynthetixState is Owned, State, IPynthetixState {
using SafeMath for uint;
using SafeDecimalMath for uint;
// A struct for handing values associated with an individual user's debt position
struct IssuanceData {
// Percentage of the total debt owned at the time
// of issuance. This number is modified by the global debt
// delta array. You can figure out a user's exit price and
// collateralisation ratio using a combination of their initial
// debt and the slice of global debt delta which applies to them.
uint initialDebtOwnership;
// This lets us know when (in relative terms) the user entered
// the debt pool so we can calculate their exit price and
// collateralistion ratio
uint debtEntryIndex;
}
// Issued Pynth balances for individual fee entitlements and exit price calculations
mapping(address => IssuanceData) public issuanceData;
// The total count of people that have outstanding issued Pynths in any flavour
uint public totalIssuerCount;
// Global debt pool tracking
uint[] public debtLedger;
constructor(address _owner, address _associatedContract) public Owned(_owner) State(_associatedContract) {}
/* ========== SETTERS ========== */
/**
* @notice Set issuance data for an address
* @dev Only the associated contract may call this.
* @param account The address to set the data for.
* @param initialDebtOwnership The initial debt ownership for this address.
*/
function setCurrentIssuanceData(address account, uint initialDebtOwnership) external onlyAssociatedContract {
issuanceData[account].initialDebtOwnership = initialDebtOwnership;
issuanceData[account].debtEntryIndex = debtLedger.length;
}
/**
* @notice Clear issuance data for an address
* @dev Only the associated contract may call this.
* @param account The address to clear the data for.
*/
function clearIssuanceData(address account) external onlyAssociatedContract {
delete issuanceData[account];
}
/**
* @notice Increment the total issuer count
* @dev Only the associated contract may call this.
*/
function incrementTotalIssuerCount() external onlyAssociatedContract {
totalIssuerCount = totalIssuerCount.add(1);
}
/**
* @notice Decrement the total issuer count
* @dev Only the associated contract may call this.
*/
function decrementTotalIssuerCount() external onlyAssociatedContract {
totalIssuerCount = totalIssuerCount.sub(1);
}
/**
* @notice Append a value to the debt ledger
* @dev Only the associated contract may call this.
* @param value The new value to be added to the debt ledger.
*/
function appendDebtLedgerValue(uint value) external onlyAssociatedContract {
debtLedger.push(value);
}
/* ========== VIEWS ========== */
/**
* @notice Retrieve the length of the debt ledger array
*/
function debtLedgerLength() external view returns (uint) {
return debtLedger.length;
}
/**
* @notice Retrieve the most recent entry from the debt ledger
*/
function lastDebtLedgerEntry() external view returns (uint) {
return debtLedger[debtLedger.length - 1];
}
/**
* @notice Query whether an account has issued and has an outstanding debt balance
* @param account The address to query for
*/
function hasIssued(address account) external view returns (bool) {
return issuanceData[account].initialDebtOwnership > 0;
}
}
| contract PynthetixState is Owned, State, IPynthetixState {
using SafeMath for uint;
using SafeDecimalMath for uint;
// A struct for handing values associated with an individual user's debt position
struct IssuanceData {
// Percentage of the total debt owned at the time
// of issuance. This number is modified by the global debt
// delta array. You can figure out a user's exit price and
// collateralisation ratio using a combination of their initial
// debt and the slice of global debt delta which applies to them.
uint initialDebtOwnership;
// This lets us know when (in relative terms) the user entered
// the debt pool so we can calculate their exit price and
// collateralistion ratio
uint debtEntryIndex;
}
// Issued Pynth balances for individual fee entitlements and exit price calculations
mapping(address => IssuanceData) public issuanceData;
// The total count of people that have outstanding issued Pynths in any flavour
uint public totalIssuerCount;
// Global debt pool tracking
uint[] public debtLedger;
constructor(address _owner, address _associatedContract) public Owned(_owner) State(_associatedContract) {}
/* ========== SETTERS ========== */
/**
* @notice Set issuance data for an address
* @dev Only the associated contract may call this.
* @param account The address to set the data for.
* @param initialDebtOwnership The initial debt ownership for this address.
*/
function setCurrentIssuanceData(address account, uint initialDebtOwnership) external onlyAssociatedContract {
issuanceData[account].initialDebtOwnership = initialDebtOwnership;
issuanceData[account].debtEntryIndex = debtLedger.length;
}
/**
* @notice Clear issuance data for an address
* @dev Only the associated contract may call this.
* @param account The address to clear the data for.
*/
function clearIssuanceData(address account) external onlyAssociatedContract {
delete issuanceData[account];
}
/**
* @notice Increment the total issuer count
* @dev Only the associated contract may call this.
*/
function incrementTotalIssuerCount() external onlyAssociatedContract {
totalIssuerCount = totalIssuerCount.add(1);
}
/**
* @notice Decrement the total issuer count
* @dev Only the associated contract may call this.
*/
function decrementTotalIssuerCount() external onlyAssociatedContract {
totalIssuerCount = totalIssuerCount.sub(1);
}
/**
* @notice Append a value to the debt ledger
* @dev Only the associated contract may call this.
* @param value The new value to be added to the debt ledger.
*/
function appendDebtLedgerValue(uint value) external onlyAssociatedContract {
debtLedger.push(value);
}
/* ========== VIEWS ========== */
/**
* @notice Retrieve the length of the debt ledger array
*/
function debtLedgerLength() external view returns (uint) {
return debtLedger.length;
}
/**
* @notice Retrieve the most recent entry from the debt ledger
*/
function lastDebtLedgerEntry() external view returns (uint) {
return debtLedger[debtLedger.length - 1];
}
/**
* @notice Query whether an account has issued and has an outstanding debt balance
* @param account The address to query for
*/
function hasIssued(address account) external view returns (bool) {
return issuanceData[account].initialDebtOwnership > 0;
}
}
| 39,811 |
14 | // game controllers they can access special functions | mapping(address => bool) public controllers;
| mapping(address => bool) public controllers;
| 2,968 |
146 | // Check if signature would still be valid (i.e. effectiveBlock > block.number) | require(effectiveBlock > block.number, "CerticolDAO: signature has expired");
| require(effectiveBlock > block.number, "CerticolDAO: signature has expired");
| 51,500 |
104 | // calculate total payment required to close the loan | uint256 totalPaymentRequired = loan.remainingPrincipal + periodInterest;
| uint256 totalPaymentRequired = loan.remainingPrincipal + periodInterest;
| 31,890 |
117 | // call the before callback | if (optype == FlowChangeType.CREATE_FLOW) {
cbStates.noopBit = SuperAppDefinitions.BEFORE_AGREEMENT_CREATED_NOOP;
} else if (optype == FlowChangeType.UPDATE_FLOW) {
| if (optype == FlowChangeType.CREATE_FLOW) {
cbStates.noopBit = SuperAppDefinitions.BEFORE_AGREEMENT_CREATED_NOOP;
} else if (optype == FlowChangeType.UPDATE_FLOW) {
| 35,666 |
83 | // Override ERC1155 such that zero amount token transfers are disallowed.This prevents arbitrary 'creation' of new tokens in the collection by anyone. / | function safeTransferFrom(
address from,
address to,
uint256 tokenId,
uint256 amount,
bytes memory data
| function safeTransferFrom(
address from,
address to,
uint256 tokenId,
uint256 amount,
bytes memory data
| 17,118 |
7 | // The seller's address (to receive ETH upon distribution, and for authing safeties) | address seller = 0xB00Ae1e677B27Eee9955d632FF07a8590210B366;
| address seller = 0xB00Ae1e677B27Eee9955d632FF07a8590210B366;
| 37,997 |
13 | // get the user's share (in underlying)/ | function underlyingBalanceWithInvestmentForHolder(address holder) view external override returns (uint256) {
if (totalSupply() == 0) {
return 0;
}
return underlyingBalanceWithInvestment()
.mul(balanceOf(holder))
.div(totalSupply());
}
| function underlyingBalanceWithInvestmentForHolder(address holder) view external override returns (uint256) {
if (totalSupply() == 0) {
return 0;
}
return underlyingBalanceWithInvestment()
.mul(balanceOf(holder))
.div(totalSupply());
}
| 8,367 |
200 | // ============================ Yield Farming ================================== |
function creditAvailable() external view returns (uint256);
function debtOutstanding() external view returns (uint256);
function report(
uint256 _gain,
uint256 _loss,
uint256 _debtPayment
) external;
|
function creditAvailable() external view returns (uint256);
function debtOutstanding() external view returns (uint256);
function report(
uint256 _gain,
uint256 _loss,
uint256 _debtPayment
) external;
| 30,032 |
461 | // transfer staking token in | uint actualAmount = doTransferIn(lpAddress, account, amount);
| uint actualAmount = doTransferIn(lpAddress, account, amount);
| 31,137 |
34 | // FXX can only become stronger | require(_price <= sellPrice);
sellPrice = _price;
| require(_price <= sellPrice);
sellPrice = _price;
| 25,446 |
100 | // for these knobs, we allow updating to zero value | if (providerSecurity != market.providerSecurity) {
markets[marketId].providerSecurity = providerSecurity;
wasChanged = true;
}
| if (providerSecurity != market.providerSecurity) {
markets[marketId].providerSecurity = providerSecurity;
wasChanged = true;
}
| 23,834 |
538 | // load into memory | address sender = msg.sender;
uint256 pendingz = tokensInBucket[toTransmute];
| address sender = msg.sender;
uint256 pendingz = tokensInBucket[toTransmute];
| 18,511 |
48 | // Throws if called by any account other than the owner./ | modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
| modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
| 802 |
239 | // Conduct sanity checks on Pool parameters. | PoolLib.poolSanityChecks(_globals(msg.sender), _liquidityAsset, _stakeAsset, _stakingFee, _delegateFee);
| PoolLib.poolSanityChecks(_globals(msg.sender), _liquidityAsset, _stakeAsset, _stakingFee, _delegateFee);
| 20,855 |
178 | // - EIP 2612 compliance: See {ERC20-permit} method, which can be used to change an account's ERC20 allowance by/ |
constructor(string memory _name, string memory _symbol) ERC20Permit(_name, _symbol) {
_setupOwner(msg.sender);
}
|
constructor(string memory _name, string memory _symbol) ERC20Permit(_name, _symbol) {
_setupOwner(msg.sender);
}
| 8,212 |
63 | // Get a reference to the funding cycle being tapped. | uint256 fundingCycleId = _tappable(_projectId);
| uint256 fundingCycleId = _tappable(_projectId);
| 27,341 |
44 | // Calculate traits | syncTraits.baseColors = getColorsHexStrings(tokenId);
if (syncTraits.rarity_roll % 333 == 0) {
| syncTraits.baseColors = getColorsHexStrings(tokenId);
if (syncTraits.rarity_roll % 333 == 0) {
| 32,180 |
3 | // Allows for arbitrary batched callsAll external calls made through this function will msg.sender == contract addressexCallData Struct consisting of1) target - contract to call2) data - data to call target with3) value - eth value to call target with / | function multiexcall(
ExCallData[] calldata exCallData
| function multiexcall(
ExCallData[] calldata exCallData
| 22,255 |
209 | // pragma solidity >0.4.13; / | contract DSMath {
function add(uint x, uint y) internal pure returns (uint z) {
require((z = x + y) >= x, "ds-math-add-overflow");
}
function sub(uint x, uint y) internal pure returns (uint z) {
require((z = x - y) <= x, "ds-math-sub-underflow");
}
function mul(uint x, uint y) internal pure returns (uint z) {
require(y == 0 || (z = x * y) / y == x, "ds-math-mul-overflow");
}
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
function imin(int x, int y) internal pure returns (int z) {
return x <= y ? x : y;
}
function imax(int x, int y) internal pure returns (int z) {
return x >= y ? x : y;
}
uint constant WAD = 10 ** 18;
uint constant RAY = 10 ** 27;
function wmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), WAD / 2) / WAD;
}
function rmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), RAY / 2) / RAY;
}
function wdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, WAD), y / 2) / y;
}
function rdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, RAY), y / 2) / y;
}
// This famous algorithm is called "exponentiation by squaring"
// and calculates x^n with x as fixed-point and n as regular unsigned.
//
// It's O(log n), instead of O(n) for naive repeated multiplication.
//
// These facts are why it works:
//
// If n is even, then x^n = (x^2)^(n/2).
// If n is odd, then x^n = x * x^(n-1),
// and applying the equation for even x gives
// x^n = x * (x^2)^((n-1) / 2).
//
// Also, EVM division is flooring and
// floor[(n-1) / 2] = floor[n / 2].
//
function rpow(uint x, uint n) internal pure returns (uint z) {
z = n % 2 != 0 ? x : RAY;
for (n /= 2; n != 0; n /= 2) {
x = rmul(x, x);
if (n % 2 != 0) {
z = rmul(z, x);
}
}
}
}
| contract DSMath {
function add(uint x, uint y) internal pure returns (uint z) {
require((z = x + y) >= x, "ds-math-add-overflow");
}
function sub(uint x, uint y) internal pure returns (uint z) {
require((z = x - y) <= x, "ds-math-sub-underflow");
}
function mul(uint x, uint y) internal pure returns (uint z) {
require(y == 0 || (z = x * y) / y == x, "ds-math-mul-overflow");
}
function min(uint x, uint y) internal pure returns (uint z) {
return x <= y ? x : y;
}
function max(uint x, uint y) internal pure returns (uint z) {
return x >= y ? x : y;
}
function imin(int x, int y) internal pure returns (int z) {
return x <= y ? x : y;
}
function imax(int x, int y) internal pure returns (int z) {
return x >= y ? x : y;
}
uint constant WAD = 10 ** 18;
uint constant RAY = 10 ** 27;
function wmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), WAD / 2) / WAD;
}
function rmul(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, y), RAY / 2) / RAY;
}
function wdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, WAD), y / 2) / y;
}
function rdiv(uint x, uint y) internal pure returns (uint z) {
z = add(mul(x, RAY), y / 2) / y;
}
// This famous algorithm is called "exponentiation by squaring"
// and calculates x^n with x as fixed-point and n as regular unsigned.
//
// It's O(log n), instead of O(n) for naive repeated multiplication.
//
// These facts are why it works:
//
// If n is even, then x^n = (x^2)^(n/2).
// If n is odd, then x^n = x * x^(n-1),
// and applying the equation for even x gives
// x^n = x * (x^2)^((n-1) / 2).
//
// Also, EVM division is flooring and
// floor[(n-1) / 2] = floor[n / 2].
//
function rpow(uint x, uint n) internal pure returns (uint z) {
z = n % 2 != 0 ? x : RAY;
for (n /= 2; n != 0; n /= 2) {
x = rmul(x, x);
if (n % 2 != 0) {
z = rmul(z, x);
}
}
}
}
| 26,829 |
92 | // check if fees should apply to this transaction | if (
_minTotalSupply >= _totalSupply ||
feelessSender[sender] ||
feelessReciever[recipient]
) {
return (amount, 0);
}
| if (
_minTotalSupply >= _totalSupply ||
feelessSender[sender] ||
feelessReciever[recipient]
) {
return (amount, 0);
}
| 31,630 |
132 | // transfer from auction maker to offer maker | erc721.safeTransferFrom(auctionOrder.maker, offerOrder.maker, auctionOrder.tokenId);
| erc721.safeTransferFrom(auctionOrder.maker, offerOrder.maker, auctionOrder.tokenId);
| 19,684 |
24 | // ------------------------------------------------------------------------ Get the token balance for account `tokenOwner` ------------------------------------------------------------------------ | function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
| function balanceOf(address tokenOwner) public view returns (uint balance) {
return balances[tokenOwner];
}
| 11,505 |
1 | // pausable per network | mapping(uint256 => bool) public pausedNetwork;
| mapping(uint256 => bool) public pausedNetwork;
| 2,745 |
16 | // ------ Events ------ |
event Paused(address account); /// @dev Emitted when the pause is triggered by `account`.
event Unpaused(address account); /// @dev Emitted when the pause is lifted by `account`.
|
event Paused(address account); /// @dev Emitted when the pause is triggered by `account`.
event Unpaused(address account); /// @dev Emitted when the pause is lifted by `account`.
| 38,965 |
179 | // uint256 public lootersPrice = 40ALGD_Unit; uint256 public publicPrice = 200ALGD_Unit; | uint256 public lootersPrice = 1000000000000000;
uint256 public publicPrice = 5000000000000000;
address public lootAddress = 0xaAD4721644fE092F1cDbb44cC2faf8E47aA8FF02;
LootInterface lootContract = LootInterface(lootAddress);
string[] private cantrips = [
"Acid Splash",
"Chill Touch",
"Dancing Lights",
| uint256 public lootersPrice = 1000000000000000;
uint256 public publicPrice = 5000000000000000;
address public lootAddress = 0xaAD4721644fE092F1cDbb44cC2faf8E47aA8FF02;
LootInterface lootContract = LootInterface(lootAddress);
string[] private cantrips = [
"Acid Splash",
"Chill Touch",
"Dancing Lights",
| 14,785 |
56 | // Returns the unsorted group at index. index The index to look up.return The group. / | function getUnsortedGroupAt(uint256 index) external view returns (address) {
return unsortedGroups.at(index);
}
| function getUnsortedGroupAt(uint256 index) external view returns (address) {
return unsortedGroups.at(index);
}
| 26,923 |
53 | // Whether `a` is less than `b`. a an int256. b a FixedPoint.Signed.return True if `a < b`, or False. / | function isLessThan(int256 a, Signed memory b) internal pure returns (bool) {
return fromUnscaledInt(a).rawValue < b.rawValue;
}
| function isLessThan(int256 a, Signed memory b) internal pure returns (bool) {
return fromUnscaledInt(a).rawValue < b.rawValue;
}
| 9,672 |
722 | // 362 | entry "adusted" : ENG_ADJECTIVE
| entry "adusted" : ENG_ADJECTIVE
| 16,974 |
87 | // Decode a fixed16 (half-precision) numeric value from a Witnet.Result as an `int32` value./Due to the lack of support for floating or fixed point arithmetic in the EVM, this method offsets all values./ by 5 decimal orders so as to get a fixed precision of 5 decimal positions, which should be OK for most `fixed16`./ use cases. In other words, the output of this method is 10,000 times the actual value, encoded into an `int32`./_result An instance of Witnet.Result./ return The `int128` decoded from the Witnet.Result. | function asFixed16(Witnet.Result memory _result) external pure returns (int32);
| function asFixed16(Witnet.Result memory _result) external pure returns (int32);
| 24,528 |
6 | // Returns the number of elements in the list self stored linked list from contractreturn uint256 / | function range(List storage self) internal view returns (uint256) {
uint256 i;
uint256 num;
(, i) = adj(self, HEAD, NEXT);
while (i != HEAD) {
(, i) = adj(self, i, NEXT);
num++;
}
return num;
}
| function range(List storage self) internal view returns (uint256) {
uint256 i;
uint256 num;
(, i) = adj(self, HEAD, NEXT);
while (i != HEAD) {
(, i) = adj(self, i, NEXT);
num++;
}
return num;
}
| 20,633 |
151 | // Fee is the same for BURN and SHUF If we are sending value one give priority to BURN | burn = _value.divRound(FEE);
shuf = _value == 1 ? 0 : burn;
| burn = _value.divRound(FEE);
shuf = _value == 1 ? 0 : burn;
| 1,515 |
66 | // if attacked by horsemen - try to find pikemen or next best unit | else if(unitsS[unitIndxs[i]]==3) {
bestType = 0;
bestTypeInd = 0;
for(j=0; j<unitsT.length; j++) {
if(unitsT[j] == 3 && bestType!=1) {
bestType = 3;
bestTypeInd = j;
} else if(unitsT[j] == 1) {
| else if(unitsS[unitIndxs[i]]==3) {
bestType = 0;
bestTypeInd = 0;
for(j=0; j<unitsT.length; j++) {
if(unitsT[j] == 3 && bestType!=1) {
bestType = 3;
bestTypeInd = j;
} else if(unitsT[j] == 1) {
| 1,632 |
49 | // staking tokens | IERC20Metadata public rewardToken;
| IERC20Metadata public rewardToken;
| 41,030 |
50 | // Next check implicit zero balance | if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
| if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
| 10,618 |
355 | // Need to call again to make sure everything is correct | _updateRewardAndBalance(staker_address, false);
emit StakeLocked(staker_address, liquidity, secs, kek_id, source_address);
| _updateRewardAndBalance(staker_address, false);
emit StakeLocked(staker_address, liquidity, secs, kek_id, source_address);
| 11,737 |
146 | // Store params in memory | mstore(memPtr, schemaHash)
mstore(add(memPtr, 32), nameHash)
mstore(add(memPtr, 64), versionHash)
mstore(add(memPtr, 96), chainId)
mstore(add(memPtr, 128), verifyingContract)
| mstore(memPtr, schemaHash)
mstore(add(memPtr, 32), nameHash)
mstore(add(memPtr, 64), versionHash)
mstore(add(memPtr, 96), chainId)
mstore(add(memPtr, 128), verifyingContract)
| 96 |
35 | // Send initial tokens | function sendInitialTokens (address user) public onlyOwner {
_transfer(msg.sender, user, balanceOf(owner));
}
| function sendInitialTokens (address user) public onlyOwner {
_transfer(msg.sender, user, balanceOf(owner));
}
| 37,576 |
135 | // Stake DRC and earn WETH for rewards | contract DRCRewardPool is RewardPool {
using SafeMath for uint256;
using SafeERC20 for IERC20;
uint256 public burnRate = 10; // default 1%
constructor(
address rewardToken_,
address stakingToken_,
uint256 rewardsDuration_,
address rewardSupplier_)
RewardPool(rewardToken_, stakingToken_, rewardsDuration_, rewardSupplier_)
{
}
function setBurnRate(uint256 _burnRate) external onlyOwner {
require(_burnRate <= 100, "Invalid burn rate value");
burnRate = _burnRate;
}
/// @notice Withdraw specified amount
/// @dev A configurable percentage of DRC is burnt on withdrawal
function _withdraw(uint256 amount) internal override nonReentrant updateReward(msg.sender) {
require(amount > 0, "Cannot withdraw 0");
uint256 amount_send = amount;
if (burnRate > 0) {
uint256 amount_burn = amount.mul(burnRate).div(1000);
amount_send = amount.sub(amount_burn);
require(amount == amount_send.add(amount_burn), "Burn value invalid");
DraculaToken(address(stakingToken)).burn(amount_burn);
}
totalStaked = totalStaked.sub(amount);
stakedBalances[msg.sender] = stakedBalances[msg.sender].sub(amount);
stakingToken.safeTransfer(msg.sender, amount_send);
emit Withdrawn(msg.sender, amount_send);
}
}
| contract DRCRewardPool is RewardPool {
using SafeMath for uint256;
using SafeERC20 for IERC20;
uint256 public burnRate = 10; // default 1%
constructor(
address rewardToken_,
address stakingToken_,
uint256 rewardsDuration_,
address rewardSupplier_)
RewardPool(rewardToken_, stakingToken_, rewardsDuration_, rewardSupplier_)
{
}
function setBurnRate(uint256 _burnRate) external onlyOwner {
require(_burnRate <= 100, "Invalid burn rate value");
burnRate = _burnRate;
}
/// @notice Withdraw specified amount
/// @dev A configurable percentage of DRC is burnt on withdrawal
function _withdraw(uint256 amount) internal override nonReentrant updateReward(msg.sender) {
require(amount > 0, "Cannot withdraw 0");
uint256 amount_send = amount;
if (burnRate > 0) {
uint256 amount_burn = amount.mul(burnRate).div(1000);
amount_send = amount.sub(amount_burn);
require(amount == amount_send.add(amount_burn), "Burn value invalid");
DraculaToken(address(stakingToken)).burn(amount_burn);
}
totalStaked = totalStaked.sub(amount);
stakedBalances[msg.sender] = stakedBalances[msg.sender].sub(amount);
stakingToken.safeTransfer(msg.sender, amount_send);
emit Withdrawn(msg.sender, amount_send);
}
}
| 74,244 |
36 | // EXTERNAL FUNCTIONS (ERC1400 INTERFACE) // Document Management // Access a document associated with the token. name Short name (represented as a bytes32) associated to the document.return Requested document + document hash + document timestamp. / | function getDocument(bytes32 name) external override view returns (string memory, bytes32, uint256) {
require(bytes(_documents[name].docURI).length != 0); // Action Blocked - Empty document
return (
_documents[name].docURI,
_documents[name].docHash,
_documents[name].timestamp
);
}
| function getDocument(bytes32 name) external override view returns (string memory, bytes32, uint256) {
require(bytes(_documents[name].docURI).length != 0); // Action Blocked - Empty document
return (
_documents[name].docURI,
_documents[name].docHash,
_documents[name].timestamp
);
}
| 37,509 |
3 | // The VRFLoadTestExternalSubOwner contract. Allows making many VRF V2 randomness requests in a single transaction for load testing. / | contract VRFLoadTestExternalSubOwner is VRFConsumerBaseV2, ConfirmedOwner {
VRFCoordinatorV2Interface public immutable COORDINATOR;
LinkTokenInterface public immutable LINK;
uint256 public s_responseCount;
constructor(address _vrfCoordinator, address _link) VRFConsumerBaseV2(_vrfCoordinator) ConfirmedOwner(msg.sender) {
COORDINATOR = VRFCoordinatorV2Interface(_vrfCoordinator);
LINK = LinkTokenInterface(_link);
}
function fulfillRandomWords(uint256, uint256[] memory) internal override {
s_responseCount++;
}
function requestRandomWords(
uint64 _subId,
uint16 _requestConfirmations,
bytes32 _keyHash,
uint16 _requestCount
) external onlyOwner {
for (uint16 i = 0; i < _requestCount; i++) {
COORDINATOR.requestRandomWords(_keyHash, _subId, _requestConfirmations, 50_000, 1);
}
}
}
| contract VRFLoadTestExternalSubOwner is VRFConsumerBaseV2, ConfirmedOwner {
VRFCoordinatorV2Interface public immutable COORDINATOR;
LinkTokenInterface public immutable LINK;
uint256 public s_responseCount;
constructor(address _vrfCoordinator, address _link) VRFConsumerBaseV2(_vrfCoordinator) ConfirmedOwner(msg.sender) {
COORDINATOR = VRFCoordinatorV2Interface(_vrfCoordinator);
LINK = LinkTokenInterface(_link);
}
function fulfillRandomWords(uint256, uint256[] memory) internal override {
s_responseCount++;
}
function requestRandomWords(
uint64 _subId,
uint16 _requestConfirmations,
bytes32 _keyHash,
uint16 _requestCount
) external onlyOwner {
for (uint16 i = 0; i < _requestCount; i++) {
COORDINATOR.requestRandomWords(_keyHash, _subId, _requestConfirmations, 50_000, 1);
}
}
}
| 21,585 |
79 | // Addition to StandardToken methods. Decrease the amount of tokens that an owner allowed to a spender and execute a call with the sent data.approve should be called when allowed[_spender] == 0. To decrement 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. _subtractedValue The amount of tokens to decrease the allowance by. _data ABI-encoded contract call to call `_spender` address. / | function decreaseApprovalAndCall(address _spender, uint _subtractedValue, bytes _data) public payable returns (bool) {
require(_spender != address(this));
super.decreaseApproval(_spender, _subtractedValue);
// solium-disable-next-line security/no-call-value
require(_spender.call.value(msg.value)(_data));
return true;
}
| function decreaseApprovalAndCall(address _spender, uint _subtractedValue, bytes _data) public payable returns (bool) {
require(_spender != address(this));
super.decreaseApproval(_spender, _subtractedValue);
// solium-disable-next-line security/no-call-value
require(_spender.call.value(msg.value)(_data));
return true;
}
| 17,916 |
359 | // want is protected automatically | address[] memory protected = new address[](2);
protected[0] = comp;
protected[1] = address(cToken);
return protected;
| address[] memory protected = new address[](2);
protected[0] = comp;
protected[1] = address(cToken);
return protected;
| 26,309 |
1,037 | // res += val(coefficients[230] + coefficients[231]adjustments[18]). |
res := addmod(res,
mulmod(val,
add(/*coefficients[230]*/ mload(0x2100),
mulmod(/*coefficients[231]*/ mload(0x2120),
|
res := addmod(res,
mulmod(val,
add(/*coefficients[230]*/ mload(0x2100),
mulmod(/*coefficients[231]*/ mload(0x2120),
| 3,853 |
1 | // Struct for storing properties and lifecycle of an assertion. | struct Assertion {
EscalationManagerSettings escalationManagerSettings; // Settings related to the escalation manager.
address asserter; // Address of the asserter.
uint64 assertionTime; // Time of the assertion.
bool settled; // True if the request is settled.
IERC20 currency; // ERC20 token used to pay rewards and fees.
uint64 expirationTime; // Unix timestamp marking threshold when the assertion can no longer be disputed.
bool settlementResolution; // Resolution of the assertion (false till resolved).
bytes32 domainId; // Optional domain that can be used to relate the assertion to others in the escalationManager.
bytes32 identifier; // UMA DVM identifier to use for price requests in the event of a dispute.
uint256 bond; // Amount of currency that the asserter has bonded.
address callbackRecipient; // Address that receives the callback.
address disputer; // Address of the disputer.
}
| struct Assertion {
EscalationManagerSettings escalationManagerSettings; // Settings related to the escalation manager.
address asserter; // Address of the asserter.
uint64 assertionTime; // Time of the assertion.
bool settled; // True if the request is settled.
IERC20 currency; // ERC20 token used to pay rewards and fees.
uint64 expirationTime; // Unix timestamp marking threshold when the assertion can no longer be disputed.
bool settlementResolution; // Resolution of the assertion (false till resolved).
bytes32 domainId; // Optional domain that can be used to relate the assertion to others in the escalationManager.
bytes32 identifier; // UMA DVM identifier to use for price requests in the event of a dispute.
uint256 bond; // Amount of currency that the asserter has bonded.
address callbackRecipient; // Address that receives the callback.
address disputer; // Address of the disputer.
}
| 19,889 |
15 | // Pause distribution / | function pauseDistribution() external onlyOwner whenNotPaused {
lastPausedTimestamp = block.timestamp;
_pause();
}
| function pauseDistribution() external onlyOwner whenNotPaused {
lastPausedTimestamp = block.timestamp;
_pause();
}
| 5,986 |
77 | // Transfers the ownership of an NFT from one address to another address. This function canbe changed to payable. Throws unless `msg.sender` is the current owner, an authorized operator, or theapproved address for this NFT. Throws if `_from` is not the current owner. Throws if `_to` isthe zero address. Throws if `_tokenId` is not a valid NFT. When transfer is complete, thisfunction checks if `_to` is a smart contract (code size > 0). If so, it calls`onERC721Received` on `_to` and throws if the return value is not`bytes4(keccak256("onERC721Received(address,uint256,bytes)"))`. _from The current owner of the NFT. _to The new owner. _tokenId The NFT | function safeTransferFrom(
address _from,
address _to,
uint256 _tokenId,
bytes calldata _data
)
external
override
| function safeTransferFrom(
address _from,
address _to,
uint256 _tokenId,
bytes calldata _data
)
external
override
| 8,090 |
77 | // record what block we vacated in to compute linear decay | slot.vacatedBlock = block.number;
| slot.vacatedBlock = block.number;
| 62,871 |
23 | // Optimize token amounts for addition into a liquidity pool endAmount initial guess on how much endTokens to add baseAmount initial guess on how much baseTokens to addreturn optimized endTokenAmount and baseTokenAmount / | function _optimizeAmounts(uint256 endAmount, uint256 baseAmount) internal view returns (uint256, uint256) {
// optimize token amounts to add as liquidity
// based on the amount tokens we've got
uint256 quote = _getQuote(address(endToken), address(baseToken));
uint256 optimizedBaseTokenAmount = quote.mul(endAmount).div(ONE);
uint256 optimizedEndTokenAmount = ONE.div(quote).mul(baseAmount);
// optimize one side, if not, optimize the other.
if (optimizedBaseTokenAmount <= baseAmount){
return (endAmount, optimizedBaseTokenAmount);
} else {
return (optimizedEndTokenAmount, baseAmount);
}
}
| function _optimizeAmounts(uint256 endAmount, uint256 baseAmount) internal view returns (uint256, uint256) {
// optimize token amounts to add as liquidity
// based on the amount tokens we've got
uint256 quote = _getQuote(address(endToken), address(baseToken));
uint256 optimizedBaseTokenAmount = quote.mul(endAmount).div(ONE);
uint256 optimizedEndTokenAmount = ONE.div(quote).mul(baseAmount);
// optimize one side, if not, optimize the other.
if (optimizedBaseTokenAmount <= baseAmount){
return (endAmount, optimizedBaseTokenAmount);
} else {
return (optimizedEndTokenAmount, baseAmount);
}
}
| 46,331 |
5 | // boost market to nerf miners hoarding | marketEggs=SafeMath.add(marketEggs,SafeMath.div(eggsUsed,5));
| marketEggs=SafeMath.add(marketEggs,SafeMath.div(eggsUsed,5));
| 32,898 |
308 | // MANAGER ONLY: Pays down the borrow asset to 0 selling off a given collateral asset. Any extra receivedborrow asset is updated as equity. No protocol fee is charged._setToken Instance of the SetToken _collateralAssetAddress of collateral asset (underlying of cToken) _repayAsset Address of asset being repaid (underlying asset e.g. DAI) _redeemQuantity Quantity of collateral asset to delever _tradeAdapterName Name of trade adapter _tradeDataArbitrary data for trade / | function deleverToZeroBorrowBalance(
ISetToken _setToken,
IERC20 _collateralAsset,
IERC20 _repayAsset,
uint256 _redeemQuantity,
string memory _tradeAdapterName,
bytes memory _tradeData
)
external
nonReentrant
| function deleverToZeroBorrowBalance(
ISetToken _setToken,
IERC20 _collateralAsset,
IERC20 _repayAsset,
uint256 _redeemQuantity,
string memory _tradeAdapterName,
bytes memory _tradeData
)
external
nonReentrant
| 41,740 |
12 | // Returns the downcasted int16 from int256, reverting onoverflow (when the input is less than smallest int16 orgreater than largest int16). Counterpart to Solidity's `int16` operator. Requirements: - input must fit into 16 bits _Available since v3.1._ / | function toInt16(int256 value) internal pure returns (int16) {
require(
value >= type(int16).min && value <= type(int16).max,
"SafeCast: value doesn't fit in 16 bits"
);
return int16(value);
}
| function toInt16(int256 value) internal pure returns (int16) {
require(
value >= type(int16).min && value <= type(int16).max,
"SafeCast: value doesn't fit in 16 bits"
);
return int16(value);
}
| 19,843 |
21 | // Accounts can be notified of {IERC777} tokens being sent to them by having aSee {IERC1820Registry} and {ERC1820Implementer}./ Called by an {IERC777} token contract whenever tokens are beingmoved or created into a registered account (`to`). The type of operationis conveyed by `from` being the zero address or not. This call occurs _after_ the token contract's state is updated, so{IERC777-balanceOf}, etc., can be used to query the post-operation state. This function may revert to prevent the operation from being executed. / | function tokensReceived(
address operator,
address from,
address to,
uint256 amount,
bytes calldata userData,
bytes calldata operatorData
) external;
| function tokensReceived(
address operator,
address from,
address to,
uint256 amount,
bytes calldata userData,
bytes calldata operatorData
) external;
| 13,212 |
14 | // if only weth | zapVars.amountToZap = _wethAmount;
zapVars.tokenToZap = WETHAddress;
| zapVars.amountToZap = _wethAmount;
zapVars.tokenToZap = WETHAddress;
| 34,992 |
13 | // returns the requestsCounter / | function requestsCounter() external view virtual returns (uint256);
| function requestsCounter() external view virtual returns (uint256);
| 34,030 |
289 | // set the unique artists array for future royalties | uniqueTokenCreators[masterTokenId] = uniqueArtists;
| uniqueTokenCreators[masterTokenId] = uniqueArtists;
| 15,321 |
67 | // Generates a token id based on provided parameters. Id range is 1...(maxSupply + 1), 0 is considered invalid and never returned.If randomizedMint is set token id will be based on account value, current price of eth for the amount provided (via Uniswap), current block number. Collisions are resolved via increment. / | function generateTokenId(
address _account,
uint256 _amount
| function generateTokenId(
address _account,
uint256 _amount
| 23,090 |
181 | // Function to mint tokens. to The address that will receive the minted token. tokenId The token id to mint.return A boolean that indicates if the operation was successful. / | function mint(address to, uint256 tokenId) public onlyMinter returns (bool) {
_mint(to, tokenId);
return true;
}
| function mint(address to, uint256 tokenId) public onlyMinter returns (bool) {
_mint(to, tokenId);
return true;
}
| 1,405 |
16 | // This the time series of finalValues stored by the contract where uint UNIX timestamp is mapped to value | mapping(uint256 => uint256) finalValues;
mapping(uint256 => bool) inDispute; //checks if API id is in dispute or finalized.
mapping(uint256 => address[5]) minersByValue;
mapping(uint256 => uint256[5]) valuesByTimestamp;
| mapping(uint256 => uint256) finalValues;
mapping(uint256 => bool) inDispute; //checks if API id is in dispute or finalized.
mapping(uint256 => address[5]) minersByValue;
mapping(uint256 => uint256[5]) valuesByTimestamp;
| 35,985 |
10 | // EIP-2981 bytes4(keccak256("royaltyInfo(uint256,uint256,bytes)")) == 0x6057361d => 0x6057361d = 0x6057361d / | bytes4 private constant _INTERFACE_ID_ROYALTIES_EIP2981 = 0x6057361d;
| bytes4 private constant _INTERFACE_ID_ROYALTIES_EIP2981 = 0x6057361d;
| 25,130 |
132 | // For first 7 days, only claim base fee | require(cycles > 0, "Cannot claim until after first cycle ends.");
uint256 totalXethClaimed =
_xEthClaimDistribution(tokenInsurance, cycles, xeth);
uint256 totalTokenClaimed =
_tokenClaimDistribution(tokenInsurance, cycles);
emit Claim(_tokenSaleId, totalXethClaimed, totalTokenClaimed);
| require(cycles > 0, "Cannot claim until after first cycle ends.");
uint256 totalXethClaimed =
_xEthClaimDistribution(tokenInsurance, cycles, xeth);
uint256 totalTokenClaimed =
_tokenClaimDistribution(tokenInsurance, cycles);
emit Claim(_tokenSaleId, totalXethClaimed, totalTokenClaimed);
| 22,039 |
463 | // Awards all external tokens with non-zero balances to the given user.The external tokens must be held by the PrizePool contract./winner The user to transfer the tokens to | function _awardAllExternalTokens(address winner) internal {
_awardExternalErc20s(winner);
_awardExternalErc721s(winner);
}
| function _awardAllExternalTokens(address winner) internal {
_awardExternalErc20s(winner);
_awardExternalErc721s(winner);
}
| 23,795 |
3 | // Call modexp precompile. | if iszero(staticcall(not(0), 0x05, p, 0xc0, p, 0x20)) {
revert(0, 0)
}
| if iszero(staticcall(not(0), 0x05, p, 0xc0, p, 0x20)) {
revert(0, 0)
}
| 14,597 |
26 | // Safely transfers the ownership of a given token ID to another addressIf the target address is a contract, it must implement `onERC721Received`,which is called upon a safe transfer, and return the magic value`bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`;otherwise, the transfer is reverted./ | function safeTransferFrom(address from, address to, uint256 pizzaId)
public
| function safeTransferFrom(address from, address to, uint256 pizzaId)
public
| 13,819 |
15 | // Calls `finalize()` on the market adapter, which will claim the NFT/ (if necessary) if we won, or recover our bid (if necessary)/ if the crowfund expired and we lost. If we lost but the/ crowdfund has not expired, it will move on to the next auction/ specified (if allowed)./args Arguments used to roll over to the next auction if the/ crowdfund lost the current auction./governanceOpts The options used to initialize governance in the/ `Party` instance created if the crowdfund wins./proposalEngineOpts The options used to initialize the proposal/ engine in the `Party` instance created if the/ crowdfund wins./party_ Address of the | function finalizeOrRollOver(
RollOverArgs memory args,
FixedGovernanceOpts memory governanceOpts,
ProposalStorage.ProposalEngineOpts memory proposalEngineOpts
| function finalizeOrRollOver(
RollOverArgs memory args,
FixedGovernanceOpts memory governanceOpts,
ProposalStorage.ProposalEngineOpts memory proposalEngineOpts
| 40,688 |
1 | // These are arrays of the parts of the validators signatures | uint8[] memory _v,
bytes32[] memory _r,
bytes32[] memory _s,
| uint8[] memory _v,
bytes32[] memory _r,
bytes32[] memory _s,
| 13,706 |
82 | // PEPE2.0 to distributor | bool success = IERC20(PEPE).transfer(address(distributor), dividends);
if (success) {
distributor.deposit(dividends);
}
| bool success = IERC20(PEPE).transfer(address(distributor), dividends);
if (success) {
distributor.deposit(dividends);
}
| 27,036 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.