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 |
|---|---|---|---|---|
27 | // Tick/Contains functions for managing tick processes and relevant calculations | library Tick {
using SafeCastUni for int256;
using SafeCastUni for uint256;
int24 public constant MAXIMUM_TICK_SPACING = 16384;
// info stored for each initialized individual tick
struct Info {
/// @dev the total position liquidity that references this tick (either as tick lower or tick upper)
uint128 liquidityGross;
/// @dev amount of net liquidity added (subtracted) when tick is crossed from left to right (right to left),
int128 liquidityNet;
/// @dev fee growth per unit of liquidity on the _other_ side of this tick (relative to the current tick)
/// @dev only has relative meaning, not absolute — the value depends on when the tick is initialized
int256 fixedTokenGrowthOutsideX128;
int256 variableTokenGrowthOutsideX128;
uint256 feeGrowthOutsideX128;
/// @dev true iff the tick is initialized, i.e. the value is exactly equivalent to the expression liquidityGross != 0
/// @dev these 8 bits are set to prevent fresh sstores when crossing newly initialized ticks
bool initialized;
}
/// @notice Derives max liquidity per tick from given tick spacing
/// @dev Executed within the pool constructor
/// @param tickSpacing The amount of required tick separation, realized in multiples of `tickSpacing`
/// e.g., a tickSpacing of 3 requires ticks to be initialized every 3rd tick i.e., ..., -6, -3, 0, 3, 6, ...
/// @return The max liquidity per tick
function tickSpacingToMaxLiquidityPerTick(int24 tickSpacing)
internal
pure
returns (uint128)
{
int24 minTick = TickMath.MIN_TICK - (TickMath.MIN_TICK % tickSpacing);
int24 maxTick = -minTick;
uint24 numTicks = uint24((maxTick - minTick) / tickSpacing) + 1;
return type(uint128).max / numTicks;
}
/// @dev Common checks for valid tick inputs.
function checkTicks(int24 tickLower, int24 tickUpper) internal pure {
require(tickLower < tickUpper, "TLU");
require(tickLower >= TickMath.MIN_TICK, "TLM");
require(tickUpper <= TickMath.MAX_TICK, "TUM");
}
struct FeeGrowthInsideParams {
int24 tickLower;
int24 tickUpper;
int24 tickCurrent;
uint256 feeGrowthGlobalX128;
}
function _getGrowthInside(
int24 _tickLower,
int24 _tickUpper,
int24 _tickCurrent,
int256 _growthGlobalX128,
int256 _lowerGrowthOutsideX128,
int256 _upperGrowthOutsideX128
) private pure returns (int256) {
// calculate the growth below
int256 _growthBelowX128;
if (_tickCurrent >= _tickLower) {
_growthBelowX128 = _lowerGrowthOutsideX128;
} else {
_growthBelowX128 = _growthGlobalX128 - _lowerGrowthOutsideX128;
}
// calculate the growth above
int256 _growthAboveX128;
if (_tickCurrent < _tickUpper) {
_growthAboveX128 = _upperGrowthOutsideX128;
} else {
_growthAboveX128 = _growthGlobalX128 - _upperGrowthOutsideX128;
}
int256 _growthInsideX128;
_growthInsideX128 =
_growthGlobalX128 -
(_growthBelowX128 + _growthAboveX128);
return _growthInsideX128;
}
function getFeeGrowthInside(
mapping(int24 => Tick.Info) storage self,
FeeGrowthInsideParams memory params
) internal view returns (uint256 feeGrowthInsideX128) {
unchecked {
Info storage lower = self[params.tickLower];
Info storage upper = self[params.tickUpper];
feeGrowthInsideX128 = uint256(
_getGrowthInside(
params.tickLower,
params.tickUpper,
params.tickCurrent,
params.feeGrowthGlobalX128.toInt256(),
lower.feeGrowthOutsideX128.toInt256(),
upper.feeGrowthOutsideX128.toInt256()
)
);
}
}
struct VariableTokenGrowthInsideParams {
int24 tickLower;
int24 tickUpper;
int24 tickCurrent;
int256 variableTokenGrowthGlobalX128;
}
function getVariableTokenGrowthInside(
mapping(int24 => Tick.Info) storage self,
VariableTokenGrowthInsideParams memory params
) internal view returns (int256 variableTokenGrowthInsideX128) {
Info storage lower = self[params.tickLower];
Info storage upper = self[params.tickUpper];
variableTokenGrowthInsideX128 = _getGrowthInside(
params.tickLower,
params.tickUpper,
params.tickCurrent,
params.variableTokenGrowthGlobalX128,
lower.variableTokenGrowthOutsideX128,
upper.variableTokenGrowthOutsideX128
);
}
struct FixedTokenGrowthInsideParams {
int24 tickLower;
int24 tickUpper;
int24 tickCurrent;
int256 fixedTokenGrowthGlobalX128;
}
function getFixedTokenGrowthInside(
mapping(int24 => Tick.Info) storage self,
FixedTokenGrowthInsideParams memory params
) internal view returns (int256 fixedTokenGrowthInsideX128) {
Info storage lower = self[params.tickLower];
Info storage upper = self[params.tickUpper];
// do we need an unchecked block in here (given we are dealing with an int256)?
fixedTokenGrowthInsideX128 = _getGrowthInside(
params.tickLower,
params.tickUpper,
params.tickCurrent,
params.fixedTokenGrowthGlobalX128,
lower.fixedTokenGrowthOutsideX128,
upper.fixedTokenGrowthOutsideX128
);
}
/// @notice Updates a tick and returns true if the tick was flipped from initialized to uninitialized, or vice versa
/// @param self The mapping containing all tick information for initialized ticks
/// @param tick The tick that will be updated
/// @param tickCurrent The current tick
/// @param liquidityDelta A new amount of liquidity to be added (subtracted) when tick is crossed from left to right (right to left)
/// @param fixedTokenGrowthGlobalX128 The fixed token growth accumulated per unit of liquidity for the entire life of the vamm
/// @param variableTokenGrowthGlobalX128 The variable token growth accumulated per unit of liquidity for the entire life of the vamm
/// @param upper true for updating a position's upper tick, or false for updating a position's lower tick
/// @param maxLiquidity The maximum liquidity allocation for a single tick
/// @return flipped Whether the tick was flipped from initialized to uninitialized, or vice versa
function update(
mapping(int24 => Tick.Info) storage self,
int24 tick,
int24 tickCurrent,
int128 liquidityDelta,
int256 fixedTokenGrowthGlobalX128,
int256 variableTokenGrowthGlobalX128,
uint256 feeGrowthGlobalX128,
bool upper,
uint128 maxLiquidity
) internal returns (bool flipped) {
Tick.Info storage info = self[tick];
uint128 liquidityGrossBefore = info.liquidityGross;
require(
int128(info.liquidityGross) + liquidityDelta >= 0,
"not enough liquidity to burn"
);
uint128 liquidityGrossAfter = LiquidityMath.addDelta(
liquidityGrossBefore,
liquidityDelta
);
require(liquidityGrossAfter <= maxLiquidity, "LO");
flipped = (liquidityGrossAfter == 0) != (liquidityGrossBefore == 0);
if (liquidityGrossBefore == 0) {
// by convention, we assume that all growth before a tick was initialized happened _below_ the tick
if (tick <= tickCurrent) {
info.feeGrowthOutsideX128 = feeGrowthGlobalX128;
info.fixedTokenGrowthOutsideX128 = fixedTokenGrowthGlobalX128;
info
.variableTokenGrowthOutsideX128 = variableTokenGrowthGlobalX128;
}
info.initialized = true;
}
/// check shouldn't we unintialize the tick if liquidityGrossAfter = 0?
info.liquidityGross = liquidityGrossAfter;
/// add comments
// when the lower (upper) tick is crossed left to right (right to left), liquidity must be added (removed)
info.liquidityNet = upper
? info.liquidityNet - liquidityDelta
: info.liquidityNet + liquidityDelta;
}
/// @notice Clears tick data
/// @param self The mapping containing all initialized tick information for initialized ticks
/// @param tick The tick that will be cleared
function clear(mapping(int24 => Tick.Info) storage self, int24 tick)
internal
{
delete self[tick];
}
/// @notice Transitions to next tick as needed by price movement
/// @param self The mapping containing all tick information for initialized ticks
/// @param tick The destination tick of the transition
/// @param fixedTokenGrowthGlobalX128 The fixed token growth accumulated per unit of liquidity for the entire life of the vamm
/// @param variableTokenGrowthGlobalX128 The variable token growth accumulated per unit of liquidity for the entire life of the vamm
/// @param feeGrowthGlobalX128 The fee growth collected per unit of liquidity for the entire life of the vamm
/// @return liquidityNet The amount of liquidity added (subtracted) when tick is crossed from left to right (right to left)
function cross(
mapping(int24 => Tick.Info) storage self,
int24 tick,
int256 fixedTokenGrowthGlobalX128,
int256 variableTokenGrowthGlobalX128,
uint256 feeGrowthGlobalX128
) internal returns (int128 liquidityNet) {
Tick.Info storage info = self[tick];
info.feeGrowthOutsideX128 =
feeGrowthGlobalX128 -
info.feeGrowthOutsideX128;
info.fixedTokenGrowthOutsideX128 =
fixedTokenGrowthGlobalX128 -
info.fixedTokenGrowthOutsideX128;
info.variableTokenGrowthOutsideX128 =
variableTokenGrowthGlobalX128 -
info.variableTokenGrowthOutsideX128;
liquidityNet = info.liquidityNet;
}
}
| library Tick {
using SafeCastUni for int256;
using SafeCastUni for uint256;
int24 public constant MAXIMUM_TICK_SPACING = 16384;
// info stored for each initialized individual tick
struct Info {
/// @dev the total position liquidity that references this tick (either as tick lower or tick upper)
uint128 liquidityGross;
/// @dev amount of net liquidity added (subtracted) when tick is crossed from left to right (right to left),
int128 liquidityNet;
/// @dev fee growth per unit of liquidity on the _other_ side of this tick (relative to the current tick)
/// @dev only has relative meaning, not absolute — the value depends on when the tick is initialized
int256 fixedTokenGrowthOutsideX128;
int256 variableTokenGrowthOutsideX128;
uint256 feeGrowthOutsideX128;
/// @dev true iff the tick is initialized, i.e. the value is exactly equivalent to the expression liquidityGross != 0
/// @dev these 8 bits are set to prevent fresh sstores when crossing newly initialized ticks
bool initialized;
}
/// @notice Derives max liquidity per tick from given tick spacing
/// @dev Executed within the pool constructor
/// @param tickSpacing The amount of required tick separation, realized in multiples of `tickSpacing`
/// e.g., a tickSpacing of 3 requires ticks to be initialized every 3rd tick i.e., ..., -6, -3, 0, 3, 6, ...
/// @return The max liquidity per tick
function tickSpacingToMaxLiquidityPerTick(int24 tickSpacing)
internal
pure
returns (uint128)
{
int24 minTick = TickMath.MIN_TICK - (TickMath.MIN_TICK % tickSpacing);
int24 maxTick = -minTick;
uint24 numTicks = uint24((maxTick - minTick) / tickSpacing) + 1;
return type(uint128).max / numTicks;
}
/// @dev Common checks for valid tick inputs.
function checkTicks(int24 tickLower, int24 tickUpper) internal pure {
require(tickLower < tickUpper, "TLU");
require(tickLower >= TickMath.MIN_TICK, "TLM");
require(tickUpper <= TickMath.MAX_TICK, "TUM");
}
struct FeeGrowthInsideParams {
int24 tickLower;
int24 tickUpper;
int24 tickCurrent;
uint256 feeGrowthGlobalX128;
}
function _getGrowthInside(
int24 _tickLower,
int24 _tickUpper,
int24 _tickCurrent,
int256 _growthGlobalX128,
int256 _lowerGrowthOutsideX128,
int256 _upperGrowthOutsideX128
) private pure returns (int256) {
// calculate the growth below
int256 _growthBelowX128;
if (_tickCurrent >= _tickLower) {
_growthBelowX128 = _lowerGrowthOutsideX128;
} else {
_growthBelowX128 = _growthGlobalX128 - _lowerGrowthOutsideX128;
}
// calculate the growth above
int256 _growthAboveX128;
if (_tickCurrent < _tickUpper) {
_growthAboveX128 = _upperGrowthOutsideX128;
} else {
_growthAboveX128 = _growthGlobalX128 - _upperGrowthOutsideX128;
}
int256 _growthInsideX128;
_growthInsideX128 =
_growthGlobalX128 -
(_growthBelowX128 + _growthAboveX128);
return _growthInsideX128;
}
function getFeeGrowthInside(
mapping(int24 => Tick.Info) storage self,
FeeGrowthInsideParams memory params
) internal view returns (uint256 feeGrowthInsideX128) {
unchecked {
Info storage lower = self[params.tickLower];
Info storage upper = self[params.tickUpper];
feeGrowthInsideX128 = uint256(
_getGrowthInside(
params.tickLower,
params.tickUpper,
params.tickCurrent,
params.feeGrowthGlobalX128.toInt256(),
lower.feeGrowthOutsideX128.toInt256(),
upper.feeGrowthOutsideX128.toInt256()
)
);
}
}
struct VariableTokenGrowthInsideParams {
int24 tickLower;
int24 tickUpper;
int24 tickCurrent;
int256 variableTokenGrowthGlobalX128;
}
function getVariableTokenGrowthInside(
mapping(int24 => Tick.Info) storage self,
VariableTokenGrowthInsideParams memory params
) internal view returns (int256 variableTokenGrowthInsideX128) {
Info storage lower = self[params.tickLower];
Info storage upper = self[params.tickUpper];
variableTokenGrowthInsideX128 = _getGrowthInside(
params.tickLower,
params.tickUpper,
params.tickCurrent,
params.variableTokenGrowthGlobalX128,
lower.variableTokenGrowthOutsideX128,
upper.variableTokenGrowthOutsideX128
);
}
struct FixedTokenGrowthInsideParams {
int24 tickLower;
int24 tickUpper;
int24 tickCurrent;
int256 fixedTokenGrowthGlobalX128;
}
function getFixedTokenGrowthInside(
mapping(int24 => Tick.Info) storage self,
FixedTokenGrowthInsideParams memory params
) internal view returns (int256 fixedTokenGrowthInsideX128) {
Info storage lower = self[params.tickLower];
Info storage upper = self[params.tickUpper];
// do we need an unchecked block in here (given we are dealing with an int256)?
fixedTokenGrowthInsideX128 = _getGrowthInside(
params.tickLower,
params.tickUpper,
params.tickCurrent,
params.fixedTokenGrowthGlobalX128,
lower.fixedTokenGrowthOutsideX128,
upper.fixedTokenGrowthOutsideX128
);
}
/// @notice Updates a tick and returns true if the tick was flipped from initialized to uninitialized, or vice versa
/// @param self The mapping containing all tick information for initialized ticks
/// @param tick The tick that will be updated
/// @param tickCurrent The current tick
/// @param liquidityDelta A new amount of liquidity to be added (subtracted) when tick is crossed from left to right (right to left)
/// @param fixedTokenGrowthGlobalX128 The fixed token growth accumulated per unit of liquidity for the entire life of the vamm
/// @param variableTokenGrowthGlobalX128 The variable token growth accumulated per unit of liquidity for the entire life of the vamm
/// @param upper true for updating a position's upper tick, or false for updating a position's lower tick
/// @param maxLiquidity The maximum liquidity allocation for a single tick
/// @return flipped Whether the tick was flipped from initialized to uninitialized, or vice versa
function update(
mapping(int24 => Tick.Info) storage self,
int24 tick,
int24 tickCurrent,
int128 liquidityDelta,
int256 fixedTokenGrowthGlobalX128,
int256 variableTokenGrowthGlobalX128,
uint256 feeGrowthGlobalX128,
bool upper,
uint128 maxLiquidity
) internal returns (bool flipped) {
Tick.Info storage info = self[tick];
uint128 liquidityGrossBefore = info.liquidityGross;
require(
int128(info.liquidityGross) + liquidityDelta >= 0,
"not enough liquidity to burn"
);
uint128 liquidityGrossAfter = LiquidityMath.addDelta(
liquidityGrossBefore,
liquidityDelta
);
require(liquidityGrossAfter <= maxLiquidity, "LO");
flipped = (liquidityGrossAfter == 0) != (liquidityGrossBefore == 0);
if (liquidityGrossBefore == 0) {
// by convention, we assume that all growth before a tick was initialized happened _below_ the tick
if (tick <= tickCurrent) {
info.feeGrowthOutsideX128 = feeGrowthGlobalX128;
info.fixedTokenGrowthOutsideX128 = fixedTokenGrowthGlobalX128;
info
.variableTokenGrowthOutsideX128 = variableTokenGrowthGlobalX128;
}
info.initialized = true;
}
/// check shouldn't we unintialize the tick if liquidityGrossAfter = 0?
info.liquidityGross = liquidityGrossAfter;
/// add comments
// when the lower (upper) tick is crossed left to right (right to left), liquidity must be added (removed)
info.liquidityNet = upper
? info.liquidityNet - liquidityDelta
: info.liquidityNet + liquidityDelta;
}
/// @notice Clears tick data
/// @param self The mapping containing all initialized tick information for initialized ticks
/// @param tick The tick that will be cleared
function clear(mapping(int24 => Tick.Info) storage self, int24 tick)
internal
{
delete self[tick];
}
/// @notice Transitions to next tick as needed by price movement
/// @param self The mapping containing all tick information for initialized ticks
/// @param tick The destination tick of the transition
/// @param fixedTokenGrowthGlobalX128 The fixed token growth accumulated per unit of liquidity for the entire life of the vamm
/// @param variableTokenGrowthGlobalX128 The variable token growth accumulated per unit of liquidity for the entire life of the vamm
/// @param feeGrowthGlobalX128 The fee growth collected per unit of liquidity for the entire life of the vamm
/// @return liquidityNet The amount of liquidity added (subtracted) when tick is crossed from left to right (right to left)
function cross(
mapping(int24 => Tick.Info) storage self,
int24 tick,
int256 fixedTokenGrowthGlobalX128,
int256 variableTokenGrowthGlobalX128,
uint256 feeGrowthGlobalX128
) internal returns (int128 liquidityNet) {
Tick.Info storage info = self[tick];
info.feeGrowthOutsideX128 =
feeGrowthGlobalX128 -
info.feeGrowthOutsideX128;
info.fixedTokenGrowthOutsideX128 =
fixedTokenGrowthGlobalX128 -
info.fixedTokenGrowthOutsideX128;
info.variableTokenGrowthOutsideX128 =
variableTokenGrowthGlobalX128 -
info.variableTokenGrowthOutsideX128;
liquidityNet = info.liquidityNet;
}
}
| 3,419 |
10 | // return the address where funds are collected. / | function wallet() public view returns(address) {
return _wallet;
}
| function wallet() public view returns(address) {
return _wallet;
}
| 31 |
32 | // Check voting period has not expired. | require(votes[_participant].endOfVotingBlockNumber >= block.number);
| require(votes[_participant].endOfVotingBlockNumber >= block.number);
| 51,212 |
396 | // Revokes `role` from the calling account. Roles are often managed via {grantRole} and {revokeRole}: this function'spurpose is to provide a mechanism for accounts to lose their privilegesif they are compromised (such as when a trusted device is misplaced). If the calling account had been granted `role`, emits a {RoleRevoked}event. Requirements: - the caller must be `account`. / | function renounceRole(bytes32 role, address account) external;
| function renounceRole(bytes32 role, address account) external;
| 19,266 |
708 | // Address to call setMigrated on the old voting contract. | address public setMigratedAddress;
| address public setMigratedAddress;
| 9,308 |
73 | // Create a uniswap pair for this new token0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D0x10ED43C718714eb63d5aA57B78B54704E256024E | address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = _uniswapV2Pair;
_isExcludedFromFees[owner()]=true;
_totalSupply = (1*10**11) * (10**18);
_balances[owner()] = (1*10**11) * (10**18);
emit Transfer(address(0), owner(), (1*10**11) * (10**18));
| address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
.createPair(address(this), _uniswapV2Router.WETH());
uniswapV2Router = _uniswapV2Router;
uniswapV2Pair = _uniswapV2Pair;
_isExcludedFromFees[owner()]=true;
_totalSupply = (1*10**11) * (10**18);
_balances[owner()] = (1*10**11) * (10**18);
emit Transfer(address(0), owner(), (1*10**11) * (10**18));
| 44,468 |
2 | // Mints tokens and adds them to the balance of the `to` address. This method should be permissioned to only allow designated parties to mint tokens. / | function mint(address to, uint256 value) external returns (bool);
| function mint(address to, uint256 value) external returns (bool);
| 18,145 |
275 | // Called during each token transfer to set the 24bit `extraData` field.Intended to be overridden by the cosumer contract. `previousExtraData` - the value of `extraData` before transfer. Calling conditions: - When `from` and `to` are both non-zero, `from`'s `tokenId` will betransferred to `to`.- When `from` is zero, `tokenId` will be minted for `to`.- When `to` is zero, `tokenId` will be burned by `from`.- `from` and `to` are never both zero. / | function _extraData(
address from,
address to,
uint24 previousExtraData
| function _extraData(
address from,
address to,
uint24 previousExtraData
| 601 |
168 | // Otherwise, use consideration token and related values. | token = parameters.considerationToken;
identifier = parameters.considerationIdentifier;
amount = parameters.considerationAmount;
| token = parameters.considerationToken;
identifier = parameters.considerationIdentifier;
amount = parameters.considerationAmount;
| 23,132 |
7 | // Since the user can only bridge one token, allow only single token to be specified. | require(destinationPayload[DESTINATION_PAYLOAD_INPUTS_LEN_INDEX] == 1, "Only single token input allowed in destination");
| require(destinationPayload[DESTINATION_PAYLOAD_INPUTS_LEN_INDEX] == 1, "Only single token input allowed in destination");
| 18,912 |
183 | // Removes given addresses from the active reporters control list./Can only be called from the owner address./Emits the `ReportersUnset` event. | function unsetReporters(address[] calldata reporters) external;
| function unsetReporters(address[] calldata reporters) external;
| 19,875 |
0 | // for testing functions with modifiers | uint public counter;
| uint public counter;
| 37,870 |
182 | // The deadline is the first extra argument at the end of the original calldata. | return uint256(_decodeExtraCalldataWord(0));
| return uint256(_decodeExtraCalldataWord(0));
| 82,061 |
146 | // Helper function to parse spend and incoming assets from encoded call args/ during claimRewardsAndReinvest() calls. | function __parseAssetsForClaimRewardsAndReinvest(bytes calldata _encodedCallArgs)
private
view
returns (
IIntegrationManager.SpendAssetsHandleType spendAssetsHandleType_,
address[] memory spendAssets_,
uint256[] memory spendAssetAmounts_,
address[] memory incomingAssets_,
uint256[] memory minIncomingAssetAmounts_
)
| function __parseAssetsForClaimRewardsAndReinvest(bytes calldata _encodedCallArgs)
private
view
returns (
IIntegrationManager.SpendAssetsHandleType spendAssetsHandleType_,
address[] memory spendAssets_,
uint256[] memory spendAssetAmounts_,
address[] memory incomingAssets_,
uint256[] memory minIncomingAssetAmounts_
)
| 60,828 |
14 | // Contracts that should not own Ether Remco Bloemen <remco@2π.com> This tries to block incoming ether to prevent accidental loss of Ether. Should Ether end upin the contract, it will allow the owner to reclaim this ether. Ether can still be sent to this contract by:calling functions labeled `payable``selfdestruct(contract_address)`mining directly to the contract address / | contract HasNoEther is Ownable {
/**
* @dev Constructor that rejects incoming Ether
* The `payable` flag is added so we can access `msg.value` without compiler warning. If we
* leave out payable, then Solidity will allow inheriting contracts to implement a payable
* constructor. By doing it this way we prevent a payable constructor from working. Alternatively
* we could use assembly to access msg.value.
*/
constructor() public payable {
require(msg.value == 0);
}
/**
* @dev Disallows direct send by settings a default function without the `payable` flag.
*/
function() external {
}
/**
* @dev Transfer all Ether held by the contract to the owner.
*/
function reclaimEther() external onlyOwner {
owner.transfer(address(this).balance);
}
}
| contract HasNoEther is Ownable {
/**
* @dev Constructor that rejects incoming Ether
* The `payable` flag is added so we can access `msg.value` without compiler warning. If we
* leave out payable, then Solidity will allow inheriting contracts to implement a payable
* constructor. By doing it this way we prevent a payable constructor from working. Alternatively
* we could use assembly to access msg.value.
*/
constructor() public payable {
require(msg.value == 0);
}
/**
* @dev Disallows direct send by settings a default function without the `payable` flag.
*/
function() external {
}
/**
* @dev Transfer all Ether held by the contract to the owner.
*/
function reclaimEther() external onlyOwner {
owner.transfer(address(this).balance);
}
}
| 35,428 |
57 | // Bytes32Set | struct Bytes32Set {
Set _inner;
}
| struct Bytes32Set {
Set _inner;
}
| 25,856 |
0 | // |
event SaleEntered(address indexed user, uint256 amount);
event SaleClaimed(address indexed user, uint256 amount);
event TokensSupplied(uint256 amount);
event ProceedsWithdrawn(uint256 amount);
/*/////////////////////////////////////////////////
STATE
|
event SaleEntered(address indexed user, uint256 amount);
event SaleClaimed(address indexed user, uint256 amount);
event TokensSupplied(uint256 amount);
event ProceedsWithdrawn(uint256 amount);
/*/////////////////////////////////////////////////
STATE
| 34,943 |
95 | // Gives permission to `to` to transfer `tokenId` token to another account.The approval is cleared when the token is transferred. Only a single account can be approved at a time, so approving the zero address clears previous approvals. Requirements: - The caller must own the token or be an approved operator.- `tokenId` must exist. Emits an {Approval} event. / | function approve(address to, uint256 tokenId) external;
| function approve(address to, uint256 tokenId) external;
| 2,283 |
51 | // Here we are loading the last 32 bytes. We exploit the fact that 'mload' will pad with zeroes if we overread. There is no 'mload8' to do this, but that would be nicer. | v := byte(0, mload(add(sig, 96)))
| v := byte(0, mload(add(sig, 96)))
| 478 |
0 | // modifier to check if caller is the lottery operator | modifier isOperator() {
require(
(msg.sender == lotteryOperator),
"Caller is not the lottery operator"
);
_;
}
| modifier isOperator() {
require(
(msg.sender == lotteryOperator),
"Caller is not the lottery operator"
);
_;
}
| 1,336 |
4 | // Grab the next token ID being minted. | uint256 tokenId = nextTokenIdToMint();
| uint256 tokenId = nextTokenIdToMint();
| 11,975 |
19 | // TODO: Clear timestamps | paused = false;
| paused = false;
| 3,032 |
153 | // The block number when MUSHROOM mining starts. | uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
MushroomToken _mushroom,
address _devaddr,
address _feeAddress,
| uint256 public startBlock;
event Deposit(address indexed user, uint256 indexed pid, uint256 amount);
event Withdraw(address indexed user, uint256 indexed pid, uint256 amount);
event EmergencyWithdraw(address indexed user, uint256 indexed pid, uint256 amount);
constructor(
MushroomToken _mushroom,
address _devaddr,
address _feeAddress,
| 19,936 |
161 | // Claim up to 50 tokens at once / | function claimTokens(uint16 animal,uint256 amount)
external
payable
callerIsUser
claimStarted
| function claimTokens(uint16 animal,uint256 amount)
external
payable
callerIsUser
claimStarted
| 67,045 |
31 | // Admin Events // Event emitted when pendingAdmin is changed / | event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);
| event NewPendingAdmin(address oldPendingAdmin, address newPendingAdmin);
| 4,136 |
4 | // Create a dispute. Must be called by the arbitrable contract. Must be paid at least arbitrationCost(_extraData)._choices Amount of choices the arbitrator can make in this dispute._extraData Can be used to give additional info on the dispute to be created. return disputeID ID of the dispute created. / | function createDispute(uint _choices, bytes calldata _extraData) external payable returns(uint disputeID);
| function createDispute(uint _choices, bytes calldata _extraData) external payable returns(uint disputeID);
| 48,522 |
1 | // create edition | if (bytes(_editionUri).length > 0) {
Address.functionDelegateCall(
implementation_,
abi.encodeWithSignature(
"createEdition(string,uint256,address,(address,uint16),bytes)",
_editionUri,
editionSize,
_editionTokenManager,
editionRoyalty,
mintVectorData
| if (bytes(_editionUri).length > 0) {
Address.functionDelegateCall(
implementation_,
abi.encodeWithSignature(
"createEdition(string,uint256,address,(address,uint16),bytes)",
_editionUri,
editionSize,
_editionTokenManager,
editionRoyalty,
mintVectorData
| 13,672 |
69 | // reject buy tokens requestnonce request recorded at this particular noncereason reason for rejection/ | function rejectMint(uint256 nonce, uint256 reason)
external
onlyValidator
| function rejectMint(uint256 nonce, uint256 reason)
external
onlyValidator
| 48,212 |
0 | // ECR20 standard token interface | contract Token {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function balanceOf(address _owner) constant returns (uint256 balance);
function transfer(address _to, uint256 _value) returns (bool success);
function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
function approve(address _spender, uint256 _value) returns (bool success);
function allowance(address _owner, address _spender) constant returns (uint256 remaining);
}
| contract Token {
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
function balanceOf(address _owner) constant returns (uint256 balance);
function transfer(address _to, uint256 _value) returns (bool success);
function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
function approve(address _spender, uint256 _value) returns (bool success);
function allowance(address _owner, address _spender) constant returns (uint256 remaining);
}
| 11,636 |
111 | // totalSupply for ERC20 compatibility | function totalSupply() public view returns (uint256) {
return totalAsset.base;
}
| function totalSupply() public view returns (uint256) {
return totalAsset.base;
}
| 9,168 |
60 | // Returns the implementer of `interfaceHash` for `account`. If no suchimplementer is registered, returns the zero address. If `interfaceHash` is an {IERC165} interface id (i.e. it ends with 28zeroes), `account` will be queried for support of it. `account` being the zero address is an alias for the caller's address. / | function getInterfaceImplementer(address account, bytes32 interfaceHash) external view returns (address);
| function getInterfaceImplementer(address account, bytes32 interfaceHash) external view returns (address);
| 5,394 |
990 | // firstUnstakeRequest is stored at unstakeRequests[0].next | uint public lastUnstakeRequestId;
uint public processedToStakerIndex; // we processed the action up this staker
bool public isContractStakeCalculated; // flag to indicate whether staked amount is up to date or not
| uint public lastUnstakeRequestId;
uint public processedToStakerIndex; // we processed the action up this staker
bool public isContractStakeCalculated; // flag to indicate whether staked amount is up to date or not
| 13,519 |
64 | // This condition checks if there are any rewards to pay after the cliff | if (currInterval >= intervalsAtVest && !rewardGenerationComplete) {
rewardCat[0] = tokensOwedByInterval(founderCat[0], intervalsAtVest, currInterval);
rewardCat[1] = rewardCat[0] / 2;
| if (currInterval >= intervalsAtVest && !rewardGenerationComplete) {
rewardCat[0] = tokensOwedByInterval(founderCat[0], intervalsAtVest, currInterval);
rewardCat[1] = rewardCat[0] / 2;
| 11,147 |
24 | // Mapping from the change in the underlying variable (as defined by the oracle)/ and the initial collateral split to the final collateral split/Should be resolved through CollateralSplitRegistry contract/ return collateral split symbol | function collateralSplitSymbol() external view returns (bytes32);
| function collateralSplitSymbol() external view returns (bytes32);
| 31,691 |
55 | // Throws if called by any account other than the masterMinter / | modifier onlyMasterMinter() {
require(
msg.sender == masterMinter,
"FiatToken: caller is not the masterMinter"
);
_;
}
| modifier onlyMasterMinter() {
require(
msg.sender == masterMinter,
"FiatToken: caller is not the masterMinter"
);
_;
}
| 23,129 |
537 | // IERC20Metadata/Alchemix Finance | interface IERC20Metadata {
/// @notice Gets the name of the token.
///
/// @return The name.
function name() external view returns (string memory);
/// @notice Gets the symbol of the token.
///
/// @return The symbol.
function symbol() external view returns (string memory);
/// @notice Gets the number of decimals that the token has.
///
/// @return The number of decimals.
function decimals() external view returns (uint8);
} | interface IERC20Metadata {
/// @notice Gets the name of the token.
///
/// @return The name.
function name() external view returns (string memory);
/// @notice Gets the symbol of the token.
///
/// @return The symbol.
function symbol() external view returns (string memory);
/// @notice Gets the number of decimals that the token has.
///
/// @return The number of decimals.
function decimals() external view returns (uint8);
} | 44,464 |
293 | // IErc20Permit/Paul Razvan Berg/Extension of Erc20 that allows token holders to use their tokens without sending any/ transactions by setting the allowance with a signature using the `permit` method, and then spend/ them via `transferFrom`./See https:eips.ethereum.org/EIPS/eip-2612. | interface IErc20Permit is IErc20 {
/// NON-CONSTANT FUNCTIONS ///
/// @notice Sets `amount` as the allowance of `spender` over `owner`'s tokens, assuming the latter's
/// signed approval.
///
/// @dev Emits an {Approval} event.
///
/// IMPORTANT: The same issues Erc20 `approve` has related to transaction
/// ordering also apply here.
///
/// Requirements:
///
/// - `owner` cannot be the zero address.
/// - `spender` cannot be the zero address.
/// - `deadline` must be a timestamp in the future.
/// - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` over the Eip712-formatted
/// function arguments.
/// - The signature must use `owner`'s current nonce.
function permit(
address owner,
address spender,
uint256 amount,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/// CONSTANT FUNCTIONS ///
/// @notice The Eip712 domain's keccak256 hash.
function DOMAIN_SEPARATOR() external view returns (bytes32);
/// @notice Provides replay protection.
function nonces(address account) external view returns (uint256);
/// @notice keccak256("Permit(address owner,address spender,uint256 amount,uint256 nonce,uint256 deadline)");
function PERMIT_TYPEHASH() external view returns (bytes32);
/// @notice Eip712 version of this implementation.
function version() external view returns (string memory);
}
| interface IErc20Permit is IErc20 {
/// NON-CONSTANT FUNCTIONS ///
/// @notice Sets `amount` as the allowance of `spender` over `owner`'s tokens, assuming the latter's
/// signed approval.
///
/// @dev Emits an {Approval} event.
///
/// IMPORTANT: The same issues Erc20 `approve` has related to transaction
/// ordering also apply here.
///
/// Requirements:
///
/// - `owner` cannot be the zero address.
/// - `spender` cannot be the zero address.
/// - `deadline` must be a timestamp in the future.
/// - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` over the Eip712-formatted
/// function arguments.
/// - The signature must use `owner`'s current nonce.
function permit(
address owner,
address spender,
uint256 amount,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/// CONSTANT FUNCTIONS ///
/// @notice The Eip712 domain's keccak256 hash.
function DOMAIN_SEPARATOR() external view returns (bytes32);
/// @notice Provides replay protection.
function nonces(address account) external view returns (uint256);
/// @notice keccak256("Permit(address owner,address spender,uint256 amount,uint256 nonce,uint256 deadline)");
function PERMIT_TYPEHASH() external view returns (bytes32);
/// @notice Eip712 version of this implementation.
function version() external view returns (string memory);
}
| 81,852 |
2 | // Multiply by 4/3 rounded up. The `shl(2, ...)` is equivalent to multiplying by 4. | let encodedLength := shl(2, div(add(dataLength, 2), 3))
| let encodedLength := shl(2, div(add(dataLength, 2), 3))
| 22,446 |
91 | // convert any crv that was directly added | uint256 crvBal = IERC20(crv).balanceOf(address(this));
if (crvBal > 0) {
ICrvDepositor(crvDeposit).deposit(crvBal, true);
}
| uint256 crvBal = IERC20(crv).balanceOf(address(this));
if (crvBal > 0) {
ICrvDepositor(crvDeposit).deposit(crvBal, true);
}
| 25,665 |
84 | // Internal Functions //Returns if the call has enough ether to pay the minting fee/_numberOfItemsToMint Number of items to mint/_received The amount that was received/ return If the minting fee can be payed | function _canPayMintFee(uint _numberOfItemsToMint, uint _received) internal view returns (bool) {
return _received >= _getMintFee(_numberOfItemsToMint);
}
| function _canPayMintFee(uint _numberOfItemsToMint, uint _received) internal view returns (bool) {
return _received >= _getMintFee(_numberOfItemsToMint);
}
| 52,226 |
13 | // Reverts if the sender doesn't own the split `split`split Address to check for control / | modifier onlySplitController(address split) {
if (msg.sender != splits[split].controller) revert Unauthorized(msg.sender);
_;
}
| modifier onlySplitController(address split) {
if (msg.sender != splits[split].controller) revert Unauthorized(msg.sender);
_;
}
| 25,507 |
301 | // And what effect does this percentage change have on the global debt holding of other issuers? The delta specifically needs to not take into account any existing debt as it's already accounted for in the delta from when they issued previously. | delta = SafeDecimalMath.preciseUnit().add(debtPercentage);
| delta = SafeDecimalMath.preciseUnit().add(debtPercentage);
| 9,715 |
345 | // Ticket scanned | event txScan(address originAddress, address indexed ticketIssuer, uint256 indexed nftIndex, uint _timestamp);
function changeFuel(IERC20 _fuelAddress) public {
require(gAC.hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "changeFuel: must have admin role to change fuel");
FUELTOKEN = IERC20(_fuelAddress);
}
| event txScan(address originAddress, address indexed ticketIssuer, uint256 indexed nftIndex, uint _timestamp);
function changeFuel(IERC20 _fuelAddress) public {
require(gAC.hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "changeFuel: must have admin role to change fuel");
FUELTOKEN = IERC20(_fuelAddress);
}
| 25,451 |
70 | // poolId1 count from 1, subtraction 1 before using with poolInfo | mapping(address => uint256) public poolId1;
| mapping(address => uint256) public poolId1;
| 43,309 |
668 | // Returns the subtraction of two unsigned integers, reverting on overflow (when the result is negative). Counterpart to Solidity's `-` operator. Requirements: - Subtraction cannot overflow./ | function sub(uint128 a, uint128 b) internal pure returns (uint128) {
require(b <= a, "SafeMath: subtraction overflow");
uint128 c = a - b;
return c;
}
| function sub(uint128 a, uint128 b) internal pure returns (uint128) {
require(b <= a, "SafeMath: subtraction overflow");
uint128 c = a - b;
return c;
}
| 13,353 |
126 | // Check if a contract address is a module, Set, resource, factory or controller _contractAddress The contract address to check / | function isSystemContract(address _contractAddress) external view returns (bool) {
return (
isSet[_contractAddress] ||
isModule[_contractAddress] ||
isResource[_contractAddress] ||
isFactory[_contractAddress] ||
_contractAddress == address(this)
);
}
| function isSystemContract(address _contractAddress) external view returns (bool) {
return (
isSet[_contractAddress] ||
isModule[_contractAddress] ||
isResource[_contractAddress] ||
isFactory[_contractAddress] ||
_contractAddress == address(this)
);
}
| 47,749 |
174 | // pull the amount we flash loaned in collateral to be able to payback the debt | DSProxy(payable(_proxy)).execute(
AAVE_BASIC_PROXY,
abi.encodeWithSignature(
"withdraw(address,address,uint256)",
_market,
_exchangeData.srcAddr,
valueToWithdraw
)
);
| DSProxy(payable(_proxy)).execute(
AAVE_BASIC_PROXY,
abi.encodeWithSignature(
"withdraw(address,address,uint256)",
_market,
_exchangeData.srcAddr,
valueToWithdraw
)
);
| 81,140 |
54 | // ==== CONVERT GWEI TO/FROM TOKEN ==== | function toGwei(uint256 _token) internal view returns(uint256) {
return _token * 10 ** decimals;
}
| function toGwei(uint256 _token) internal view returns(uint256) {
return _token * 10 ** decimals;
}
| 27,179 |
482 | // initializes a reserve_reserve the address of the reserve_aTokenAddress the address of the overlying aToken contract_decimals the decimals of the reserve currency_interestRateStrategyAddress the address of the interest rate strategy contract/ | ) external onlyLendingPoolConfigurator {
reserves[_reserve].init(_aTokenAddress, _decimals, _interestRateStrategyAddress);
addReserveToListInternal(_reserve);
}
| ) external onlyLendingPoolConfigurator {
reserves[_reserve].init(_aTokenAddress, _decimals, _interestRateStrategyAddress);
addReserveToListInternal(_reserve);
}
| 16,357 |
238 | // These fields are not accessible from assembly | bytes memory array = msg.data;
uint256 index = msg.data.length;
| bytes memory array = msg.data;
uint256 index = msg.data.length;
| 16,412 |
100 | // Transfer tokens from the vault to the supporter while releasing proportional amount of ether to BitMED`s wallet.Can be triggerd by the supporter only | function claimTokens(uint256 tokensToClaim) isKycComplete public {
require(tokensToClaim != 0);
address supporter = msg.sender;
require(depositedToken[supporter] > 0);
uint256 depositedTokenValue = depositedToken[supporter];
uint256 depositedETHValue = depositedETH[supporter];
require(tokensToClaim <= depositedTokenValue);
uint256 claimedETH = tokensToClaim.mul(depositedETHValue).div(depositedTokenValue);
assert(claimedETH > 0);
depositedETH[supporter] = depositedETHValue.sub(claimedETH);
depositedToken[supporter] = depositedTokenValue.sub(tokensToClaim);
token.transfer(supporter, tokensToClaim);
TokensClaimed(supporter, tokensToClaim);
}
| function claimTokens(uint256 tokensToClaim) isKycComplete public {
require(tokensToClaim != 0);
address supporter = msg.sender;
require(depositedToken[supporter] > 0);
uint256 depositedTokenValue = depositedToken[supporter];
uint256 depositedETHValue = depositedETH[supporter];
require(tokensToClaim <= depositedTokenValue);
uint256 claimedETH = tokensToClaim.mul(depositedETHValue).div(depositedTokenValue);
assert(claimedETH > 0);
depositedETH[supporter] = depositedETHValue.sub(claimedETH);
depositedToken[supporter] = depositedTokenValue.sub(tokensToClaim);
token.transfer(supporter, tokensToClaim);
TokensClaimed(supporter, tokensToClaim);
}
| 32,981 |
34 | // get parent id from parent id to move to the next level | _currentPetId = _parentId;
| _currentPetId = _parentId;
| 52,584 |
29 | // pre-definition for loans without interest rates | rates[0].chi = ONE;
rates[0].ratePerSecond = ONE;
wards[msg.sender] = 1;
emit Rely(msg.sender);
| rates[0].chi = ONE;
rates[0].ratePerSecond = ONE;
wards[msg.sender] = 1;
emit Rely(msg.sender);
| 10,330 |
75 | // Helper function that gets NFT count of owner. This is needed for overriding in enumerableextension to remove double storage (gas optimization) of owner NFT count. _owner Address for whom to query the count.return Number of _owner NFTs. / | function _getOwnerNFTCount(
address _owner
)
internal
virtual
view
returns (uint256)
| function _getOwnerNFTCount(
address _owner
)
internal
virtual
view
returns (uint256)
| 25,128 |
19 | // SafeMath.sub will throw if there is not enough balance. |
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
|
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
| 40,916 |
0 | // converting address type to string | function addressToString(address a) public pure returns(string memory){
string memory str = new string(42);
bytes memory b = new bytes(40);
bytes1[] memory charArray = bytes20ToCharArray(bytes20(a));
for (uint i = 0; i<40; i++) {
b[i] = charArray[i];
}
str = string(abi.encodePacked(bytes("0x"), b));
return str;
}
| function addressToString(address a) public pure returns(string memory){
string memory str = new string(42);
bytes memory b = new bytes(40);
bytes1[] memory charArray = bytes20ToCharArray(bytes20(a));
for (uint i = 0; i<40; i++) {
b[i] = charArray[i];
}
str = string(abi.encodePacked(bytes("0x"), b));
return str;
}
| 29,743 |
21 | // harvests | stakingContract.deposit(PID, 0);
| stakingContract.deposit(PID, 0);
| 507 |
109 | // e.g. 8e181e18 = 8e36 | uint256 z = x.mul(FULL_SCALE);
| uint256 z = x.mul(FULL_SCALE);
| 11,361 |
83 | // Get the next token id that will be minted. (unless max supply exceeded) | function getNextToken() external view returns (uint256) {
return _nextTokenId();
}
| function getNextToken() external view returns (uint256) {
return _nextTokenId();
}
| 14,149 |
134 | // Update level in multiplier contract | uint256 newBoostedBalance = deflector.updateLevel(msg.sender, _token, _newLevel, _balances[msg.sender].balance);
| uint256 newBoostedBalance = deflector.updateLevel(msg.sender, _token, _newLevel, _balances[msg.sender].balance);
| 12,320 |
390 | // target contract address changed -> close proposal without execution. | if (targetContractAddress != proposals[_proposalId].targetContractAddress) {
outcome = Outcome.TargetContractAddressChanged;
}
| if (targetContractAddress != proposals[_proposalId].targetContractAddress) {
outcome = Outcome.TargetContractAddressChanged;
}
| 55,983 |
299 | // update next unlock index | userBalance.nextUnlockIndex = nextUnlockIndex;
| userBalance.nextUnlockIndex = nextUnlockIndex;
| 47,850 |
135 | // Convert from seconds to ledger timer ticks | _delay *= 10;
bytes memory nbytes = new bytes(1);
nbytes[0] = byte(_nbytes);
bytes memory unonce = new bytes(32);
bytes memory sessionKeyHash = new bytes(32);
bytes32 sessionKeyHash_bytes32 = oraclize_randomDS_getSessionPubKeyHash();
assembly {
mstore(unonce, 0x20)
| _delay *= 10;
bytes memory nbytes = new bytes(1);
nbytes[0] = byte(_nbytes);
bytes memory unonce = new bytes(32);
bytes memory sessionKeyHash = new bytes(32);
bytes32 sessionKeyHash_bytes32 = oraclize_randomDS_getSessionPubKeyHash();
assembly {
mstore(unonce, 0x20)
| 52,399 |
2 | // 函数修饰符 限定创建者调用 | modifier onlyOwner{
require(msg.sender == owner);
_;
}
| modifier onlyOwner{
require(msg.sender == owner);
_;
}
| 1,287 |
637 | // send upfront to buyer | _valueWithoutFee = _valueWithoutFee.sub(_transferImmediatelyToBuyerAmount);
uint _transferImmediatelyToBuyerAmountWithoutFee = _takeWithdrawalFee(_token, _transferImmediatelyToBuyerAmount, _feeStatus);
_token.transfer(_buyer, _transferImmediatelyToBuyerAmountWithoutFee);
| _valueWithoutFee = _valueWithoutFee.sub(_transferImmediatelyToBuyerAmount);
uint _transferImmediatelyToBuyerAmountWithoutFee = _takeWithdrawalFee(_token, _transferImmediatelyToBuyerAmount, _feeStatus);
_token.transfer(_buyer, _transferImmediatelyToBuyerAmountWithoutFee);
| 50,075 |
292 | // Supports ERC721, ERC165 | function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC165Upgradeable, IERC165Upgradeable)
returns (bool)
| function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(ERC165Upgradeable, IERC165Upgradeable)
returns (bool)
| 53,606 |
68 | // Initializes the contract in unpaused state. Assigns the Pauser roleto the deployer. / | function initialize(address sender) public initializer {
PauserRole.initialize(sender);
_paused = false;
}
| function initialize(address sender) public initializer {
PauserRole.initialize(sender);
_paused = false;
}
| 10,168 |
55 | // Returns a memory pointer to the data portion of the provided bytes array. bts Memory byte array / | function dataPtr(bytes memory bts) internal pure returns (uint256 addr) {
assembly {
addr := add(bts, /*BYTES_HEADER_SIZE*/ 32)
}
}
| function dataPtr(bytes memory bts) internal pure returns (uint256 addr) {
assembly {
addr := add(bts, /*BYTES_HEADER_SIZE*/ 32)
}
}
| 58,141 |
438 | // add stake to the pool (following day) | hdrnPoolPoints[currentDay + 1] += stakePoints;
| hdrnPoolPoints[currentDay + 1] += stakePoints;
| 36,192 |
71 | // True if the contract was properly initialized and the LP seeded, meaning no more tokens can be minted. See also {initialize} | bool public initialized;
| bool public initialized;
| 39,777 |
1 | // address(bytes20(keccak256('nuts.finance.custodian'))) | return 0xDbE7A2544eeFfec81A7D898Ac08075e0D56FEac6;
| return 0xDbE7A2544eeFfec81A7D898Ac08075e0D56FEac6;
| 44,483 |
41 | // Keep track of EOS->EOSclassic claims | mapping (address => bool) public eosClassicClaimed;
| mapping (address => bool) public eosClassicClaimed;
| 11,933 |
6 | // BlacklistedRole Blacklisted accounts have been forbidden by a BlacklistAdmin to perform certain actions (e.g. participate in acrowdsale). This role is special in that the only accounts that can add it are BlacklistAdmins (who can also removeit), and not Blacklisteds themselves. / | contract BlacklistedRole is BlacklistAdminRole {
using Roles for Roles.Role;
event BlacklistedAdded(address indexed account);
event BlacklistedRemoved(address indexed account);
Roles.Role private _blacklisteds;
modifier onlyNotBlacklisted() {
require(!isBlacklisted(msg.sender));
_;
}
function isBlacklisted(address account) public view returns (bool) {
return _blacklisteds.has(account);
}
function addBlacklisted(address account) public onlyBlacklistAdmin {
_addBlacklisted(account);
}
function removeBlacklisted(address account) public onlyBlacklistAdmin {
_removeBlacklisted(account);
}
function _addBlacklisted(address account) internal {
_blacklisteds.add(account);
emit BlacklistedAdded(account);
}
function _removeBlacklisted(address account) internal {
_blacklisteds.remove(account);
emit BlacklistedRemoved(account);
}
}
| contract BlacklistedRole is BlacklistAdminRole {
using Roles for Roles.Role;
event BlacklistedAdded(address indexed account);
event BlacklistedRemoved(address indexed account);
Roles.Role private _blacklisteds;
modifier onlyNotBlacklisted() {
require(!isBlacklisted(msg.sender));
_;
}
function isBlacklisted(address account) public view returns (bool) {
return _blacklisteds.has(account);
}
function addBlacklisted(address account) public onlyBlacklistAdmin {
_addBlacklisted(account);
}
function removeBlacklisted(address account) public onlyBlacklistAdmin {
_removeBlacklisted(account);
}
function _addBlacklisted(address account) internal {
_blacklisteds.add(account);
emit BlacklistedAdded(account);
}
function _removeBlacklisted(address account) internal {
_blacklisteds.remove(account);
emit BlacklistedRemoved(account);
}
}
| 9,409 |
14 | // (1) copy incoming call data | calldatacopy(ptr, 0, calldatasize())
| calldatacopy(ptr, 0, calldatasize())
| 30,474 |
466 | // Returns a uint16 containing the hex-encoded byte. _byte The bytereturn _encoded The hex-encoded byte / | function _byteHex(uint8 _byte) private pure returns (uint16 _encoded) {
_encoded |= _nibbleHex(_byte >> 4); // top 4 bits
_encoded <<= 8;
_encoded |= _nibbleHex(_byte); // lower 4 bits
}
| function _byteHex(uint8 _byte) private pure returns (uint16 _encoded) {
_encoded |= _nibbleHex(_byte >> 4); // top 4 bits
_encoded <<= 8;
_encoded |= _nibbleHex(_byte); // lower 4 bits
}
| 22,498 |
197 | // checks if amount is greater that 10000 | modifier checkPrice(uint256 _amount) {
require(
_amount > 10000,
"MarketPlace: Amount should be minimum 10000 wei."
);
_;
}
| modifier checkPrice(uint256 _amount) {
require(
_amount > 10000,
"MarketPlace: Amount should be minimum 10000 wei."
);
_;
}
| 32,687 |
28 | // Send 10% to the treasury | IERC20(WETH).safeTransferFrom(address(this), treasury, wethBalance.preciseMul(feeDistributionWeights[0]));
totalStats[1] = totalStats[1].add(wethBalance.preciseMul(feeDistributionWeights[0]));
| IERC20(WETH).safeTransferFrom(address(this), treasury, wethBalance.preciseMul(feeDistributionWeights[0]));
totalStats[1] = totalStats[1].add(wethBalance.preciseMul(feeDistributionWeights[0]));
| 37,951 |
94 | // Permits this contract to spend a given token from `msg.sender`/The `owner` is always msg.sender and the `spender` is always address(this)./ Can be used instead of selfPermit to prevent calls from failing due to a frontrun of a call to selfPermit/token The address of the token spent/value The amount that can be spent of token/deadline A timestamp, the current blocktime must be less than or equal to this timestamp/v Must produce valid secp256k1 signature from the holder along with `r` and `s`/r Must produce valid secp256k1 signature from the holder along with `v` and `s`/s Must produce valid secp256k1 signature from | function selfPermitIfNecessary(
address token,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external payable;
| function selfPermitIfNecessary(
address token,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external payable;
| 32,675 |
21 | // Cached copy of the same value on the RiskFramework contract. | function G_LIQUIDITY_HAIRCUT() public view returns (uint128) {
return EscrowStorageSlot._liquidityHaircut();
}
| function G_LIQUIDITY_HAIRCUT() public view returns (uint128) {
return EscrowStorageSlot._liquidityHaircut();
}
| 32,811 |
9 | // An event that's emitted when a member is whitelisted | event MemberWhitelisted(address indexed member);
| event MemberWhitelisted(address indexed member);
| 41,822 |
50 | // Constructor - send initial supply to owner | function CostumeToken() public {
balances[msg.sender] = initialSupply;
}
| function CostumeToken() public {
balances[msg.sender] = initialSupply;
}
| 31,620 |
224 | // Only minter can repay Kine MCD on behalf of borrower to the protocol borrower Account with the MCD being payed off repayAmount The amount to repay / | function repayBorrowBehalf(address borrower, uint repayAmount) onlyMinter external {
repayBorrowBehalfInternal(borrower, repayAmount);
}
| function repayBorrowBehalf(address borrower, uint repayAmount) onlyMinter external {
repayBorrowBehalfInternal(borrower, repayAmount);
}
| 68,296 |
184 | // checkMESP balance sender | uint tokenCount = MESP.balanceOf(_holder);
uint tokenAvailable = 0;
| uint tokenCount = MESP.balanceOf(_holder);
uint tokenAvailable = 0;
| 13,176 |
19 | // We're just validating here that the swap has not been completed and gas has been funded before moving forward. | require(
!swap.isComplete && !swap.isRefunded && swap.isSendGasFunded,
'swap has already been completed, refunded, or gas has not been funded'
);
| require(
!swap.isComplete && !swap.isRefunded && swap.isSendGasFunded,
'swap has already been completed, refunded, or gas has not been funded'
);
| 15,831 |
54 | // Any transaction of less than 1 szabo is likely to be worth less than the gas used to send it. | if (msg.value < 0.000001 ether || msg.value > 1000000 ether)
revert();
| if (msg.value < 0.000001 ether || msg.value > 1000000 ether)
revert();
| 33,634 |
32 | // ability to destroy the contract and remove it from the blockchain if necessary | function kill() external onlyOwner
| function kill() external onlyOwner
| 24,670 |
75 | // Intentionally commented out so users can pay gas for others claims require(account == msg.sender, "TokenDistributor: Can only claim for own account."); | require(getCurrentRewardsRate() > 0, "TokenDistributor: Past rewards claim period.");
require(!isClaimed(index), "TokenDistributor: Drop already claimed.");
| require(getCurrentRewardsRate() > 0, "TokenDistributor: Past rewards claim period.");
require(!isClaimed(index), "TokenDistributor: Drop already claimed.");
| 19,321 |
18 | // Updates the price for Tier 2./_tier2 The new price for Tier 2./This function can only be called by the contract's admin. | function updateTierTwoPrice(uint256 _tier2) external onlyAdmin {
tierInfo[2].price = _tier2;
emit TierPriceUpdated(2, _tier2);
}
| function updateTierTwoPrice(uint256 _tier2) external onlyAdmin {
tierInfo[2].price = _tier2;
emit TierPriceUpdated(2, _tier2);
}
| 34,699 |
8 | // Deposit into Aave | targets[2] = address(lendingPool);
data[2] = abi.encodeWithSelector(lendingPool.deposit.selector, _underlying, _amount, referralCode);
return(targets, data);
| targets[2] = address(lendingPool);
data[2] = abi.encodeWithSelector(lendingPool.deposit.selector, _underlying, _amount, referralCode);
return(targets, data);
| 27,269 |
163 | // Send token to refund addressIf eligible (price not 0 either dev mint or transfer)Calling conditions: - `from` is address of the refunder- `to` is the address where refunded token will go- `tokenId` is the queried tokenId / | function _refund(
address from,
address to,
uint256 tokenId
| function _refund(
address from,
address to,
uint256 tokenId
| 58,394 |
1 | // An account's balance | mapping(address => uint256) public balanceOf;
| mapping(address => uint256) public balanceOf;
| 17,821 |
12 | // validates the minimum contribution amount is sent to the Campaign contract | require(
msg.value >= minimumContribution,
"You must contribute a minimum amount of wei"
);
| require(
msg.value >= minimumContribution,
"You must contribute a minimum amount of wei"
);
| 20,979 |
43 | // Returns the name of the token. / | function name() external view virtual returns (string memory) {
return _name;
}
| function name() external view virtual returns (string memory) {
return _name;
}
| 21,141 |
183 | // PLUME tokens created per block. | uint256 public plumePerBlock;
| uint256 public plumePerBlock;
| 21,233 |
233 | // only owner - withdraw contract balance to wallet | function withdraw()
public
payable
onlyOwner
| function withdraw()
public
payable
onlyOwner
| 57,647 |
141 | // This implements an optional extension of {ERC721} defined in the EIP that adds Mapping from owner to list of owned token IDs | mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
| mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
| 243 |
50 | // Check that the last token in the path is the tokenOut and update the new best option if neccesary | if (_tokenOut == tokenOut && amountOut > bestAmountOut) {
if (newOffer.gasEstimate > bestOption.gasEstimate) {
uint256 gasCostDiff = (_tknOutPriceNwei * (newOffer.gasEstimate - bestOption.gasEstimate)) /
1e9;
uint256 priceDiff = amountOut - bestAmountOut;
if (gasCostDiff > priceDiff) {
continue;
}
| if (_tokenOut == tokenOut && amountOut > bestAmountOut) {
if (newOffer.gasEstimate > bestOption.gasEstimate) {
uint256 gasCostDiff = (_tknOutPriceNwei * (newOffer.gasEstimate - bestOption.gasEstimate)) /
1e9;
uint256 priceDiff = amountOut - bestAmountOut;
if (gasCostDiff > priceDiff) {
continue;
}
| 23,655 |
52 | // Changes the name for Hashmask tokenId / | function changeName(uint256 tokenId, string memory newName) public {
address owner = ownerOf(tokenId);
require(_msgSender() == owner, "ERC721: caller is not the owner");
require(validateName(newName) == true, "Not a valid new name");
require(sha256(bytes(newName)) != sha256(bytes(_tokenName[tokenId])), "New name is same as the current one");
require(isNameReserved(newName) == false, "Name already reserved");
IERC20(_nctAddress).transferFrom(msg.sender, address(this), NAME_CHANGE_PRICE);
// If already named, dereserve old name
if (bytes(_tokenName[tokenId]).length > 0) {
toggleReserveName(_tokenName[tokenId], false);
}
toggleReserveName(newName, true);
_tokenName[tokenId] = newName;
IERC20(_nctAddress).burn(NAME_CHANGE_PRICE);
emit NameChange(tokenId, newName);
}
| function changeName(uint256 tokenId, string memory newName) public {
address owner = ownerOf(tokenId);
require(_msgSender() == owner, "ERC721: caller is not the owner");
require(validateName(newName) == true, "Not a valid new name");
require(sha256(bytes(newName)) != sha256(bytes(_tokenName[tokenId])), "New name is same as the current one");
require(isNameReserved(newName) == false, "Name already reserved");
IERC20(_nctAddress).transferFrom(msg.sender, address(this), NAME_CHANGE_PRICE);
// If already named, dereserve old name
if (bytes(_tokenName[tokenId]).length > 0) {
toggleReserveName(_tokenName[tokenId], false);
}
toggleReserveName(newName, true);
_tokenName[tokenId] = newName;
IERC20(_nctAddress).burn(NAME_CHANGE_PRICE);
emit NameChange(tokenId, newName);
}
| 4,073 |
43 | // reward rate 72.00% per year | uint public constant rewardRate = 7200;
uint public constant rewardInterval = 365 days; // 0.2% per week
| uint public constant rewardRate = 7200;
uint public constant rewardInterval = 365 days; // 0.2% per week
| 17,407 |
26 | // removeDispenserContract Removes an address from the list of dispensers_dispenser address Contract to be removed / | function removeDispenserContract(address _dispenser)
external
onlyRouterOwner
| function removeDispenserContract(address _dispenser)
external
onlyRouterOwner
| 24,761 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.