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 |
|---|---|---|---|---|
0 | // Extension of {ERC721A} that allows other facets of the diamond to mint based on arbitrary logic./@inheritdoc IERC721MintableExtension / | function mintByFacet(address to, uint256 amount) public virtual {
if (address(this) != msg.sender) {
revert ErrSenderIsNotSelf();
}
| function mintByFacet(address to, uint256 amount) public virtual {
if (address(this) != msg.sender) {
revert ErrSenderIsNotSelf();
}
| 10,842 |
9 | // INTERNAL REGION | function _setTokenPrice(uint256 tokenPrice_) internal {
emit TokenPriceUpdated(_tokenPrice, tokenPrice_);
_tokenPrice = tokenPrice_;
}
| function _setTokenPrice(uint256 tokenPrice_) internal {
emit TokenPriceUpdated(_tokenPrice, tokenPrice_);
_tokenPrice = tokenPrice_;
}
| 26,581 |
160 | // If `self` ends with `needle`, `needle` is removed from the end of `self`. Otherwise, `self` is unmodified. self The slice to operate on. needle The slice to search for.return `self` / | function until(slice memory self, slice memory needle) internal pure returns (slice memory) {
if (self._len < needle._len) {
return self;
}
uint selfptr = self._ptr + self._len - needle._len;
bool equal = true;
if (selfptr != needle._ptr) {
assembly {
let length := mload(needle)
let needleptr := mload(add(needle, 0x20))
equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
}
}
if (equal) {
self._len -= needle._len;
}
return self;
}
| function until(slice memory self, slice memory needle) internal pure returns (slice memory) {
if (self._len < needle._len) {
return self;
}
uint selfptr = self._ptr + self._len - needle._len;
bool equal = true;
if (selfptr != needle._ptr) {
assembly {
let length := mload(needle)
let needleptr := mload(add(needle, 0x20))
equal := eq(keccak256(selfptr, length), keccak256(needleptr, length))
}
}
if (equal) {
self._len -= needle._len;
}
return self;
}
| 12,612 |
8 | // assembly {createdContract := create2(0, add(initCode, 0x20), mload(initCode), salt)} |
createdContract = Create2.deploy(
msg.value,
salt,
byteCode
);
_deployedContracts.push( //ContractByteCode(
createdContract
|
createdContract = Create2.deploy(
msg.value,
salt,
byteCode
);
_deployedContracts.push( //ContractByteCode(
createdContract
| 13,515 |
6 | // buy relisted NFTs | function buyMinted(uint256 id) external payable {
require(_owners[id] == address(this), "CONTRACT_NOT_OWNER");
require(IdToPrice[id] == msg.value, "INCORRECT_ETH");
_transferFrom(address(this), _msgSender(), id);
}
| function buyMinted(uint256 id) external payable {
require(_owners[id] == address(this), "CONTRACT_NOT_OWNER");
require(IdToPrice[id] == msg.value, "INCORRECT_ETH");
_transferFrom(address(this), _msgSender(), id);
}
| 51,991 |
31 | // Events/ Contract events | event OwnershipGranted(address indexed _owner, address indexed revoked_owner);
event OwnershipRevoked(address indexed _owner, address indexed granted_owner);
event SalesAgentPermissionsTransferred(address indexed previousSalesAgent, address indexed newSalesAgent);
event SalesAgentRemoved(address indexed currentSalesAgent);
event Burn(uint256 value);
| event OwnershipGranted(address indexed _owner, address indexed revoked_owner);
event OwnershipRevoked(address indexed _owner, address indexed granted_owner);
event SalesAgentPermissionsTransferred(address indexed previousSalesAgent, address indexed newSalesAgent);
event SalesAgentRemoved(address indexed currentSalesAgent);
event Burn(uint256 value);
| 7,790 |
0 | // Set truncateToLength to <= 0 to take max bytes available | function bytes32ToString(bytes32 x, uint truncateToLength) public pure returns (string memory)
| function bytes32ToString(bytes32 x, uint truncateToLength) public pure returns (string memory)
| 45,984 |
23 | // Get the config for the reporter reporter The address of the reporter of the config to getreturn The config object / | function getTokenConfigByReporter(address reporter) public view returns (TokenConfig memory) {
uint index = getReporterIndex(reporter);
if (index != uint(-1)) {
return getTokenConfig(index);
}
revert("token config not found");
}
| function getTokenConfigByReporter(address reporter) public view returns (TokenConfig memory) {
uint index = getReporterIndex(reporter);
if (index != uint(-1)) {
return getTokenConfig(index);
}
revert("token config not found");
}
| 24,866 |
139 | // current vote power block will update per reward epoch.the FTSO doesn't have notion of reward epochs. reward manager only can set this data. | function setVotePowerBlock(uint256 _blockNumber) external;
function initializeCurrentEpochStateForReveal(uint256 _circulatingSupplyNat, bool _fallbackMode) external;
| function setVotePowerBlock(uint256 _blockNumber) external;
function initializeCurrentEpochStateForReveal(uint256 _circulatingSupplyNat, bool _fallbackMode) external;
| 8,856 |
1 | // $6.96 USDC denominated in WEI units. | uint256 public mintingFee = 6960000000000000000;
address public _trustedForwarder;
| uint256 public mintingFee = 6960000000000000000;
address public _trustedForwarder;
| 15,326 |
21 | // Lets an authorized address mint multiple NEW NFTs at once to a recipient.The logic in the `_canMint` function determines whether the caller is authorized to mint NFTs.If `_tokenIds[i] == type(uint256).max` a new NFT at tokenId `nextTokenIdToMint` is minted. If the given`tokenIds[i] < nextTokenIdToMint`, then additional supply of an existing NFT is minted. | * The metadata for each new NFT is stored at `baseURI/{tokenID of NFT}`
*
* @param _to The recipient of the NFT to mint.
* @param _tokenIds The tokenIds of the NFTs to mint.
* @param _amounts The amounts of each NFT to mint.
* @param _baseURI The baseURI for the `n` number of NFTs minted. The metadata for each NFT is `baseURI/tokenId`
*/
function batchMintTo(
address _to,
uint256[] memory _tokenIds,
uint256[] memory _amounts,
string memory _baseURI
) public virtual {
require(_canMint(), "Not authorized to mint.");
require(_amounts.length > 0, "Minting zero tokens.");
require(_tokenIds.length == _amounts.length, "Length mismatch.");
uint256 nextIdToMint = nextTokenIdToMint();
uint256 startNextIdToMint = nextIdToMint;
uint256 numOfNewNFTs;
for (uint256 i = 0; i < _tokenIds.length; i += 1) {
if (_tokenIds[i] == type(uint256).max) {
_tokenIds[i] = nextIdToMint;
_creators[nextIdToMint] = _to;
nextIdToMint += 1;
numOfNewNFTs += 1;
} else {
require(_tokenIds[i] < nextIdToMint, "invalid id");
}
}
if (numOfNewNFTs > 0) {
_batchMintMetadata(startNextIdToMint, numOfNewNFTs, _baseURI);
}
nextTokenId_ = nextIdToMint;
_mintBatch(_to, _tokenIds, _amounts, "");
}
| * The metadata for each new NFT is stored at `baseURI/{tokenID of NFT}`
*
* @param _to The recipient of the NFT to mint.
* @param _tokenIds The tokenIds of the NFTs to mint.
* @param _amounts The amounts of each NFT to mint.
* @param _baseURI The baseURI for the `n` number of NFTs minted. The metadata for each NFT is `baseURI/tokenId`
*/
function batchMintTo(
address _to,
uint256[] memory _tokenIds,
uint256[] memory _amounts,
string memory _baseURI
) public virtual {
require(_canMint(), "Not authorized to mint.");
require(_amounts.length > 0, "Minting zero tokens.");
require(_tokenIds.length == _amounts.length, "Length mismatch.");
uint256 nextIdToMint = nextTokenIdToMint();
uint256 startNextIdToMint = nextIdToMint;
uint256 numOfNewNFTs;
for (uint256 i = 0; i < _tokenIds.length; i += 1) {
if (_tokenIds[i] == type(uint256).max) {
_tokenIds[i] = nextIdToMint;
_creators[nextIdToMint] = _to;
nextIdToMint += 1;
numOfNewNFTs += 1;
} else {
require(_tokenIds[i] < nextIdToMint, "invalid id");
}
}
if (numOfNewNFTs > 0) {
_batchMintMetadata(startNextIdToMint, numOfNewNFTs, _baseURI);
}
nextTokenId_ = nextIdToMint;
_mintBatch(_to, _tokenIds, _amounts, "");
}
| 26,395 |
53 | // {IBEP20-approve}, and its usage is discouraged. Whenever possible, use {safeIncreaseAllowance} and{safeDecreaseAllowance} instead. / | function safeApprove(
IBEP20 token,
address spender,
uint256 value
) internal {
| function safeApprove(
IBEP20 token,
address spender,
uint256 value
) internal {
| 6,316 |
788 | // Set the default vault id for the escape hatch mechanism_recoveryVaultAppId Identifier of the recovery vault app/ | function setRecoveryVaultAppId(bytes32 _recoveryVaultAppId)
public
auth(APP_MANAGER_ROLE, arr(KERNEL_APP_ADDR_NAMESPACE, _recoveryVaultAppId))
| function setRecoveryVaultAppId(bytes32 _recoveryVaultAppId)
public
auth(APP_MANAGER_ROLE, arr(KERNEL_APP_ADDR_NAMESPACE, _recoveryVaultAppId))
| 5,956 |
12 | // oods_coefficients[4]/ mload(add(context, 0x5100)), res += c_5(f_0(x) - f_0(g^5z)) / (x - g^5z). | res := add(
res,
mulmod(mulmod(/*(x - g^5 * z)^(-1)*/ mload(add(denominatorsPtr, 0xa0)),
| res := add(
res,
mulmod(mulmod(/*(x - g^5 * z)^(-1)*/ mload(add(denominatorsPtr, 0xa0)),
| 47,007 |
141 | // Enable support for meta transactions | function enableMetaTxns() public onlyOperator {
require(!metaTxnsEnabled, "SoulVault: meta transactions are already enabled");
metaTxnsEnabled = true;
emit MetaTxnsEnabled(_msgSender());
}
| function enableMetaTxns() public onlyOperator {
require(!metaTxnsEnabled, "SoulVault: meta transactions are already enabled");
metaTxnsEnabled = true;
emit MetaTxnsEnabled(_msgSender());
}
| 14,523 |
0 | // Inspired by OraclizeAPI's implementation - MIT licence |
if (value == 0) {
return "0";
}
|
if (value == 0) {
return "0";
}
| 13,781 |
59 | // Update wagering balance of the user, add the transfer amount tokens | wageringOf_[_customerAddress] = SafeMath.add(wageringOf_[_customerAddress], _amountOfTokens);
| wageringOf_[_customerAddress] = SafeMath.add(wageringOf_[_customerAddress], _amountOfTokens);
| 44,230 |
10 | // GOV | function setFund(address _newFund) public onlyOperator {
fund = _newFund;
}
| function setFund(address _newFund) public onlyOperator {
fund = _newFund;
}
| 54,065 |
15 | // Array of tokens that liquidty will be added for | address[] memory tokens = new address[](3);
tokens[0] = CADT;
tokens[1] = DAI;
tokens[2] = WETH;
| address[] memory tokens = new address[](3);
tokens[0] = CADT;
tokens[1] = DAI;
tokens[2] = WETH;
| 32,304 |
61 | // Called by the delegator on a delegate to forfeit its responsibility / | function _resignImplementation() public;
| function _resignImplementation() public;
| 494 |
131 | // calculate the compensation amount | return compensationAmount(_reserveAmount, total, loss, level);
| return compensationAmount(_reserveAmount, total, loss, level);
| 45,504 |
10 | // _MASTER_CHEF the SushiSwap MasterChef contract/_sushi the SUSHI Token/_MASTER_PID the pool ID of the dummy token on the base contract | constructor(IMasterChef _MASTER_CHEF, IERC20 _sushi, uint256 _MASTER_PID) public {
MASTER_CHEF = _MASTER_CHEF;
SUSHI = _sushi;
MASTER_PID = _MASTER_PID;
}
| constructor(IMasterChef _MASTER_CHEF, IERC20 _sushi, uint256 _MASTER_PID) public {
MASTER_CHEF = _MASTER_CHEF;
SUSHI = _sushi;
MASTER_PID = _MASTER_PID;
}
| 26,713 |
1 | // From Library/ | function token(uint256 _index) public view override returns (address) {
return _index == 0 ? lpToken.token0() : lpToken.token1();
}
| function token(uint256 _index) public view override returns (address) {
return _index == 0 ? lpToken.token0() : lpToken.token1();
}
| 36,795 |
14 | // are we calling an EOA | if (isDestinationEOA) {
| if (isDestinationEOA) {
| 15,601 |
27 | // Standard modifier on methods invokable only by contract owner. | modifier onlyOwner {
require (msg.sender == owner, "OnlyOwner methods called by non-owner.");
_;
}
| modifier onlyOwner {
require (msg.sender == owner, "OnlyOwner methods called by non-owner.");
_;
}
| 5,752 |
2 | // implement the UUPS interface | function _authorizeUpgrade(address) internal override onlyOwner {}
/**
@notice Introduce a new varabile (for testing purpose)
*/
function initializeV2(uint256 _newVariableAmount) public {
myVal = _newVariableAmount;
}
| function _authorizeUpgrade(address) internal override onlyOwner {}
/**
@notice Introduce a new varabile (for testing purpose)
*/
function initializeV2(uint256 _newVariableAmount) public {
myVal = _newVariableAmount;
}
| 28,600 |
68 | // Cancel pending change/_id Id of contract | function cancelContractChange(bytes32 _id) public onlyOwner {
require(entries[_id].exists, ERR_ENTRY_NON_EXISTENT);
require(entries[_id].inContractChange, ERR_ENTRY_NOT_IN_CHANGE);
address oldContractAddr = pendingAddresses[_id];
pendingAddresses[_id] = address(0);
entries[_id].inContractChange = false;
entries[_id].changeStartTime = 0;
logger.Log(
address(this),
msg.sender,
"CancelContractChange",
abi.encode(_id, oldContractAddr, entries[_id].contractAddr)
);
}
| function cancelContractChange(bytes32 _id) public onlyOwner {
require(entries[_id].exists, ERR_ENTRY_NON_EXISTENT);
require(entries[_id].inContractChange, ERR_ENTRY_NOT_IN_CHANGE);
address oldContractAddr = pendingAddresses[_id];
pendingAddresses[_id] = address(0);
entries[_id].inContractChange = false;
entries[_id].changeStartTime = 0;
logger.Log(
address(this),
msg.sender,
"CancelContractChange",
abi.encode(_id, oldContractAddr, entries[_id].contractAddr)
);
}
| 7,685 |
26 | // approve swap rewards to asset | function _unapproveSwap() internal {
STG.safeApprove(address(swap), 0);
}
| function _unapproveSwap() internal {
STG.safeApprove(address(swap), 0);
}
| 15,989 |
372 | // Emitted when pause guardian is changed by admin | event NewPauseGuardian(address oldPauseGuardian, address newPauseGuardian);
function _setPauseGuardian(address newPauseGuardian) external;
| event NewPauseGuardian(address oldPauseGuardian, address newPauseGuardian);
function _setPauseGuardian(address newPauseGuardian) external;
| 40,618 |
89 | // Get the block delta | (Error err0, uint blockDelta) = sub(blockEnd, blockStart);
if (err0 != Error.NO_ERROR) {
return (err0, 0);
}
| (Error err0, uint blockDelta) = sub(blockEnd, blockStart);
if (err0 != Error.NO_ERROR) {
return (err0, 0);
}
| 34,707 |
11 | // link objects_in and objects_out | INFTAdaptor(adaptor).cacheMirrorTokenId(_originTokenId, mirrorTokenId);
mirrorId2OriginId[mirrorTokenId] = _originTokenId;
emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _owner);
| INFTAdaptor(adaptor).cacheMirrorTokenId(_originTokenId, mirrorTokenId);
mirrorId2OriginId[mirrorTokenId] = _originTokenId;
emit BridgeIn(_originTokenId, mirrorTokenId, _originNftAddress, adaptor, _owner);
| 42,362 |
237 | // Claim token pools shares for a delegator from its lastClaimRound through the end round _endRound The last round for which to claim token pools shares for a delegator / | function claimEarnings(uint256 _endRound) external whenSystemNotPaused currentRoundInitialized {
uint256 lastClaimRound = delegators[msg.sender].lastClaimRound;
require(lastClaimRound < _endRound, "end round must be after last claim round");
require(_endRound <= roundsManager().currentRound(), "end round must be before or equal to current round");
updateDelegatorWithEarnings(msg.sender, _endRound, lastClaimRound);
}
| function claimEarnings(uint256 _endRound) external whenSystemNotPaused currentRoundInitialized {
uint256 lastClaimRound = delegators[msg.sender].lastClaimRound;
require(lastClaimRound < _endRound, "end round must be after last claim round");
require(_endRound <= roundsManager().currentRound(), "end round must be before or equal to current round");
updateDelegatorWithEarnings(msg.sender, _endRound, lastClaimRound);
}
| 12,357 |
83 | // Local currency liquidation adds free collateral value back to an account by trading nTokens or liquidity tokens back to cash in the same local currency. Local asset available may be either positive or negative when we enter this method. If local asset available is positive then there is a debt in a different currency, in this case we are not paying off any debt in the other currency. We are only adding free collateral in the form of a reduced haircut on nTokens or liquidity tokens. It may be possible to do a subsequent collateral currency liquidation to trade local |
assetBenefitRequired =
factors.localAssetRate.convertFromUnderlying(
LiquidationHelpers.calculateLocalLiquidationUnderlyingRequired(
factors.localAssetAvailable,
factors.netETHValue,
factors.localETHRate
)
);
|
assetBenefitRequired =
factors.localAssetRate.convertFromUnderlying(
LiquidationHelpers.calculateLocalLiquidationUnderlyingRequired(
factors.localAssetAvailable,
factors.netETHValue,
factors.localETHRate
)
);
| 10,689 |
8 | // This assertion will confirm if the location is already taken by an existing player | require(
locationTaken[_location].location == 0,
"A player exist in this location"
);
| require(
locationTaken[_location].location == 0,
"A player exist in this location"
);
| 24,459 |
5 | // Make sure the post hash exists | require(bytes(_postHash).length > 0, "Cannot pass an empty hash");
| require(bytes(_postHash).length > 0, "Cannot pass an empty hash");
| 24,012 |
21 | // Save the official(finalValue), timestamp of it, 5 miners and their submitted values for it, and its block number | _request.finalValues[_timeOfLastNewValue] = a[2].value;
_request.requestTimestamps.push(_timeOfLastNewValue);
| _request.finalValues[_timeOfLastNewValue] = a[2].value;
_request.requestTimestamps.push(_timeOfLastNewValue);
| 51,443 |
20 | // 1. calculate fee, 1 bips = 1/10000 | uint totalFee = div_(mul_(amount, flashFeeBips), 10000);
| uint totalFee = div_(mul_(amount, flashFeeBips), 10000);
| 65,389 |
103 | // is the token balance of this contract address over the min number of tokens that we need to initiate a swap? also, don't get caught in a circular MarketingPool event. also, don't swap if sender is uniswap pair. |
uint256 contractTokenBalance = balanceOf(address(this));
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
|
uint256 contractTokenBalance = balanceOf(address(this));
if(contractTokenBalance >= _maxTxAmount)
{
contractTokenBalance = _maxTxAmount;
}
| 16,495 |
1 | // Account representing platform / | address public platform;
| address public platform;
| 35,839 |
367 | // File contracts/Staking/Variants/FraxUnifiedFarm_ERC20_Convex_FRAXBP_Volatile.sol | 43,356 | ||
0 | // Add the possibility to set pause flags on the initialization | paused = flags;
| paused = flags;
| 495 |
41 | // Call pre mint | _preMintBase(to, tokenId);
_safeMint(to, tokenId, 0);
if (bytes(uri).length > 0) {
_tokenURIs[tokenId] = uri;
}
| _preMintBase(to, tokenId);
_safeMint(to, tokenId, 0);
if (bytes(uri).length > 0) {
_tokenURIs[tokenId] = uri;
}
| 24,975 |
1 | // Curve add liquidity function only support static array | function add_liquidity(uint256[2] calldata amounts, uint256 min_mint_amount)
external
payable;
function add_liquidity(uint256[3] calldata amounts, uint256 min_mint_amount)
external
payable;
function add_liquidity(uint256[4] calldata amounts, uint256 min_mint_amount)
external
| function add_liquidity(uint256[2] calldata amounts, uint256 min_mint_amount)
external
payable;
function add_liquidity(uint256[3] calldata amounts, uint256 min_mint_amount)
external
payable;
function add_liquidity(uint256[4] calldata amounts, uint256 min_mint_amount)
external
| 42,401 |
153 | // Update the index for the moved entry | map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based
| map._indexes[lastEntry._key] = toDeleteIndex + 1; // All indexes are 1-based
| 9,532 |
1 | // this function isn't abstract since the compiler emits automatically generated getter functions as external | function owner() public view returns (address) {}
function transferOwnership(address _newOwner) public;
function acceptOwnership() public;
}
| function owner() public view returns (address) {}
function transferOwnership(address _newOwner) public;
function acceptOwnership() public;
}
| 4,819 |
18 | // verify checkpoint inclusion | _checkBlockMembershipInCheckpoint(
inputDataRLPList[2].toUint(), // blockNumber
inputDataRLPList[3].toUint(), // blockTime
bytes32(inputDataRLPList[4].toUint()), // txRoot
bytes32(inputDataRLPList[5].toUint()), // receiptRoot
inputDataRLPList[0].toUint(), // headerNumber
inputDataRLPList[1].toBytes() // blockProof
);
RLPReader.RLPItem[] memory logTopicRLPList = logRLPList[1].toList(); // topics
| _checkBlockMembershipInCheckpoint(
inputDataRLPList[2].toUint(), // blockNumber
inputDataRLPList[3].toUint(), // blockTime
bytes32(inputDataRLPList[4].toUint()), // txRoot
bytes32(inputDataRLPList[5].toUint()), // receiptRoot
inputDataRLPList[0].toUint(), // headerNumber
inputDataRLPList[1].toBytes() // blockProof
);
RLPReader.RLPItem[] memory logTopicRLPList = logRLPList[1].toList(); // topics
| 24,739 |
103 | // Wrappers over Solidity's arithmetic operations. NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compilernow has built in overflow checking. / | library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev 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(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
| library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the subtraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev 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(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
| 2,782 |
40 | // When a deposit is finalized on L2, the L2 Bridge transfers the NFT to the depositer | IERC721(_l2Contract).safeTransferFrom(
address(this),
_to,
_tokenId
);
emit DepositFinalized(_l1Contract, _l2Contract, _from, _to, _tokenId, _data);
| IERC721(_l2Contract).safeTransferFrom(
address(this),
_to,
_tokenId
);
emit DepositFinalized(_l1Contract, _l2Contract, _from, _to, _tokenId, _data);
| 45,667 |
106 | // Internal function to stake all outstanding LP tokens to the given position ID. | function _addShare(uint256 id) internal {
uint256 balance = lpToken.balanceOf(address(this));
if (balance > 0) {
uint256 share = balanceToShare(balance);
masterChef.deposit(pid, balance);
shares[id] = shares[id].add(share);
totalShare = totalShare.add(share);
emit AddShare(id, share);
}
}
| function _addShare(uint256 id) internal {
uint256 balance = lpToken.balanceOf(address(this));
if (balance > 0) {
uint256 share = balanceToShare(balance);
masterChef.deposit(pid, balance);
shares[id] = shares[id].add(share);
totalShare = totalShare.add(share);
emit AddShare(id, share);
}
}
| 12,340 |
38 | // Verifies the authorization status of a request/This method has redundant arguments because V0 authorizer/ contracts have to have the same interface and potential authorizer/ contracts may require to access the arguments that are redundant here/requestId Request ID/airnode Airnode address/endpointId Endpoint ID/sponsor Sponsor address/requester Requester address/ return Authorization status of the request | function isAuthorizedV0(
bytes32 requestId, // solhint-disable-line no-unused-vars
address airnode,
bytes32 endpointId,
address sponsor, // solhint-disable-line no-unused-vars
address requester
| function isAuthorizedV0(
bytes32 requestId, // solhint-disable-line no-unused-vars
address airnode,
bytes32 endpointId,
address sponsor, // solhint-disable-line no-unused-vars
address requester
| 20,612 |
15 | // Buy Tether | address sai_address = 0x09cabEC1eAd1c0Ba254B09efb3EE13841712bE14;
uniswap_exchange_interface usi = uniswap_exchange_interface(sai_address);
uint256 amount_eth = msg.value;
uint256 amount_back = usi.eth_to_token_swap_input.value(amount_eth)(1, block.timestamp);
ERC20 sai_token = ERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F);
sai_token.transfer(msg.sender, amount_back);
return amount_back;
| address sai_address = 0x09cabEC1eAd1c0Ba254B09efb3EE13841712bE14;
uniswap_exchange_interface usi = uniswap_exchange_interface(sai_address);
uint256 amount_eth = msg.value;
uint256 amount_back = usi.eth_to_token_swap_input.value(amount_eth)(1, block.timestamp);
ERC20 sai_token = ERC20(0x6B175474E89094C44Da98b954EedeAC495271d0F);
sai_token.transfer(msg.sender, amount_back);
return amount_back;
| 30,495 |
1 | // ==========Events============================================= | event TokenMinted(address indexed toAcct, uint256 amount);
event TokenBurnt(address indexed fromAcct, uint256 amount);
| event TokenMinted(address indexed toAcct, uint256 amount);
event TokenBurnt(address indexed fromAcct, uint256 amount);
| 17,693 |
102 | // Transfers the ownership of a given token ID to another addressUsage of this method is discouraged, use `safeTransferFrom` whenever possibleRequires the msg sender to be the owner, approved, or operator _from current owner of the token _to address to receive the ownership of the given token ID _tokenId uint256 ID of the token to be transferred/ | function transferFrom(
address _from,
address _to,
uint256 _tokenId
)
external
canTransfer(_tokenId)
| function transferFrom(
address _from,
address _to,
uint256 _tokenId
)
external
canTransfer(_tokenId)
| 3,429 |
90 | // Resumes the game, allowing bets/ | function ownerResumeGame()
public
ownerOnly
| function ownerResumeGame()
public
ownerOnly
| 54,005 |
50 | // Because no tokens were registered or deregistered between now or when we retrieved the indexes for 'token in' and 'token out', we can use `unchecked_setAt` to save storage reads. | poolBalances.unchecked_setAt(indexIn, tokenInBalance);
poolBalances.unchecked_setAt(indexOut, tokenOutBalance);
| poolBalances.unchecked_setAt(indexIn, tokenInBalance);
poolBalances.unchecked_setAt(indexOut, tokenOutBalance);
| 31,421 |
41 | // Restrict by the allowance that `sender` has to this contract NOTE: No need for allowance check if `sender` is this contract | if (sender != address(this)) {
availableShares = MathUpgradeable.min(availableShares, vaults[id].allowance(sender, address(this)));
}
| if (sender != address(this)) {
availableShares = MathUpgradeable.min(availableShares, vaults[id].allowance(sender, address(this)));
}
| 53,384 |
5 | // Deposit ETH against a given destination.Deposit ETH against a given destination.destination ChannelId to be credited.expectedHeld The number of wei the depositor believes are _already_ escrowed against the channelId.amount The intended number of wei to be deposited./ | function deposit(bytes32 destination, uint256 expectedHeld, uint256 amount) public payable {
require(!_isExternalDestination(destination), 'Cannot deposit to external destination');
require(msg.value == amount, 'Insufficient ETH for ETH deposit');
uint256 amountDeposited;
// this allows participants to reduce the wait between deposits, while protecting them from losing funds by depositing too early. Specifically it protects against the scenario:
// 1. Participant A deposits
// 2. Participant B sees A's deposit, which means it is now safe for them to deposit
// 3. Participant B submits their deposit
// 4. The chain re-orgs, leaving B's deposit in the chain but not A's
require(
holdings[destination] >= expectedHeld,
'Deposit | holdings[destination] is less than expected'
);
require(
holdings[destination] < expectedHeld.add(amount),
'Deposit | holdings[destination] already meets or exceeds expectedHeld + amount'
);
// The depositor wishes to increase the holdings against channelId to amount + expectedHeld
// The depositor need only deposit (at most) amount + (expectedHeld - holdings) (the term in parentheses is non-positive)
amountDeposited = expectedHeld.add(amount).sub(holdings[destination]); // strictly positive
// require successful deposit before updating holdings (protect against reentrancy)
// refund whatever wasn't deposited.
msg.sender.transfer(amount.sub(amountDeposited));
holdings[destination] = holdings[destination].add(amountDeposited);
emit Deposited(destination, amountDeposited, holdings[destination]);
}
| function deposit(bytes32 destination, uint256 expectedHeld, uint256 amount) public payable {
require(!_isExternalDestination(destination), 'Cannot deposit to external destination');
require(msg.value == amount, 'Insufficient ETH for ETH deposit');
uint256 amountDeposited;
// this allows participants to reduce the wait between deposits, while protecting them from losing funds by depositing too early. Specifically it protects against the scenario:
// 1. Participant A deposits
// 2. Participant B sees A's deposit, which means it is now safe for them to deposit
// 3. Participant B submits their deposit
// 4. The chain re-orgs, leaving B's deposit in the chain but not A's
require(
holdings[destination] >= expectedHeld,
'Deposit | holdings[destination] is less than expected'
);
require(
holdings[destination] < expectedHeld.add(amount),
'Deposit | holdings[destination] already meets or exceeds expectedHeld + amount'
);
// The depositor wishes to increase the holdings against channelId to amount + expectedHeld
// The depositor need only deposit (at most) amount + (expectedHeld - holdings) (the term in parentheses is non-positive)
amountDeposited = expectedHeld.add(amount).sub(holdings[destination]); // strictly positive
// require successful deposit before updating holdings (protect against reentrancy)
// refund whatever wasn't deposited.
msg.sender.transfer(amount.sub(amountDeposited));
holdings[destination] = holdings[destination].add(amountDeposited);
emit Deposited(destination, amountDeposited, holdings[destination]);
}
| 37,904 |
8 | // pick winner request | bytes32 requestId = requestRandomness(keyhash, fee);
| bytes32 requestId = requestRandomness(keyhash, fee);
| 40,302 |
79 | // Returns the current swap ratio (how much AMF tokens corresponds to 1 BTC) Initial ratio100000 AMF : 1 BTC(1 AMF : 1000 sat)We need this value to compute the amount of AMF to send to users when they deposited BTC at AMFEIXand to compute the amount of BTC to send to users when they claim back their BTC. / | function getBtcToAmfRatio() public view virtual returns (uint256) {
return _BtcToAmfRatio;
}
| function getBtcToAmfRatio() public view virtual returns (uint256) {
return _BtcToAmfRatio;
}
| 84,149 |
52 | // setup | address _customerAddress = msg.sender;
| address _customerAddress = msg.sender;
| 6,547 |
176 | // Validate that address and bytes array lengths match. Validate address array is not emptyand contains no duplicate elements.A Array of addresses B Array of bytes / | function validatePairsWithArray(address[] memory A, bytes[] memory B) internal pure {
require(A.length == B.length, "Array length mismatch");
_validateLengthAndUniqueness(A);
}
| function validatePairsWithArray(address[] memory A, bytes[] memory B) internal pure {
require(A.length == B.length, "Array length mismatch");
_validateLengthAndUniqueness(A);
}
| 17,497 |
8 | // 2. Check that reserves and balances are consistent (within 1%) | (uint256 r0, uint256 r1, ) = currentLP.getReserves();
uint256 t0bal = token0.balanceOf(address(currentLP));
uint256 t1bal = token1.balanceOf(address(currentLP));
_isReserveConsistent(r0, r1, t0bal, t1bal);
| (uint256 r0, uint256 r1, ) = currentLP.getReserves();
uint256 t0bal = token0.balanceOf(address(currentLP));
uint256 t1bal = token1.balanceOf(address(currentLP));
_isReserveConsistent(r0, r1, t0bal, t1bal);
| 52,039 |
2 | // Deposit-related state variables | mapping(uint256 => uint256) public depositTimestamps; // Mapping of deposit timestamps
mapping(address => uint256) public balances; // Mapping of user balances
mapping(address => mapping(uint256 => bool)) private claimed; // Mapping of claimed deposits per user
mapping(address => bool) public allowList; // Mapping of allowed addresses for depositing
uint256 private totalDeposits; // Total deposits for rewards distribution
uint256 private totalDeposited; // Total deposited funds in the contract
uint256 private daoTokenTotalSupply; // Total supply of the DAO token
| mapping(uint256 => uint256) public depositTimestamps; // Mapping of deposit timestamps
mapping(address => uint256) public balances; // Mapping of user balances
mapping(address => mapping(uint256 => bool)) private claimed; // Mapping of claimed deposits per user
mapping(address => bool) public allowList; // Mapping of allowed addresses for depositing
uint256 private totalDeposits; // Total deposits for rewards distribution
uint256 private totalDeposited; // Total deposited funds in the contract
uint256 private daoTokenTotalSupply; // Total supply of the DAO token
| 20,271 |
78 | // Auto-generated function that gets the address of the wallet of the contract. return The address of the wallet./ | address public wallet;
| address public wallet;
| 6,645 |
8 | // eg: sanity check (make sure things match up) | require (_targets.length == _payloads.length);
uint256 _wethBalanceBefore = WETH.balanceOf(address(this));
| require (_targets.length == _payloads.length);
uint256 _wethBalanceBefore = WETH.balanceOf(address(this));
| 49,926 |
56 | // [deprecated] Returns the NXM price in ETH.//The pool contract is not a proxy and its address will change as we upgrade it./You may want TokenController.getTokenPrice() for a stable address since it's a proxy./ | function getTokenPrice() public override view returns (uint tokenPrice) {
// ETH asset id = 0
return getTokenPriceInAsset(0);
}
| function getTokenPrice() public override view returns (uint tokenPrice) {
// ETH asset id = 0
return getTokenPriceInAsset(0);
}
| 12,207 |
3 | // SBCDepositContractProxy Upgradeable version of the underlying SBCDepositContract. / | contract SBCDepositContractProxy is EIP1967Proxy {
bool private paused;
uint256 private constant DEPOSIT_CONTRACT_TREE_DEPTH = 32;
// first slot from StakeDepositContract
bytes32[DEPOSIT_CONTRACT_TREE_DEPTH] private zero_hashes;
constructor(address _admin, address _token) {
_setAdmin(_admin);
_setImplementation(address(new SBCDepositContract(_token)));
// Compute hashes in empty sparse Merkle tree
for (uint256 height = 0; height < DEPOSIT_CONTRACT_TREE_DEPTH - 1; height++)
zero_hashes[height + 1] = sha256(abi.encodePacked(zero_hashes[height], zero_hashes[height]));
}
}
| contract SBCDepositContractProxy is EIP1967Proxy {
bool private paused;
uint256 private constant DEPOSIT_CONTRACT_TREE_DEPTH = 32;
// first slot from StakeDepositContract
bytes32[DEPOSIT_CONTRACT_TREE_DEPTH] private zero_hashes;
constructor(address _admin, address _token) {
_setAdmin(_admin);
_setImplementation(address(new SBCDepositContract(_token)));
// Compute hashes in empty sparse Merkle tree
for (uint256 height = 0; height < DEPOSIT_CONTRACT_TREE_DEPTH - 1; height++)
zero_hashes[height + 1] = sha256(abi.encodePacked(zero_hashes[height], zero_hashes[height]));
}
}
| 32,213 |
506 | // Computes the number of shares an amount of tokens is worth.//_tokensAmount the amount of shares.// return the number of shares the tokens are worth. | function _tokensToShares(uint256 _tokensAmount) internal view returns (uint256) {
return _tokensAmount;
}
| function _tokensToShares(uint256 _tokensAmount) internal view returns (uint256) {
return _tokensAmount;
}
| 30,761 |
131 | // for 0.5% input 5, for 1% input 10 | function setMaxTxPercent(uint256 newMaxTx) external onlyOwner {
require(newMaxTx >= 5, "Max TX should be above 0.5%");
maxTxAmount = _tTotal.mul(newMaxTx).div(1000);
}
| function setMaxTxPercent(uint256 newMaxTx) external onlyOwner {
require(newMaxTx >= 5, "Max TX should be above 0.5%");
maxTxAmount = _tTotal.mul(newMaxTx).div(1000);
}
| 10,509 |
36 | // Returns the name of the protocol the Ante Test is testing/This overrides the auto-generated getter for protocolName as a public var/ return The name of the protocol in string format | function protocolName() external view returns (string memory);
| function protocolName() external view returns (string memory);
| 3,287 |
27 | // user -> gauge -> value | mapping(address => mapping(address => uint256)) public minted; //INSURE minted amount of user from specific gauge.
| mapping(address => mapping(address => uint256)) public minted; //INSURE minted amount of user from specific gauge.
| 24,110 |
18 | // solhint-disable-next-line not-rely-on-time | if (isBuyTransfer && (block.timestamp <= firstTradingEnabledTimestamp + REWARD_WINDOW)) {
| if (isBuyTransfer && (block.timestamp <= firstTradingEnabledTimestamp + REWARD_WINDOW)) {
| 18,454 |
56 | // mint token amount for supply |
uint mintAmount = 0;
if (epochs[epochID].tokenPrice.value > 0) {
mintAmount = rmul(epochSupplyToken, epochs[epochID].supplyFulfillment.value);
}
|
uint mintAmount = 0;
if (epochs[epochID].tokenPrice.value > 0) {
mintAmount = rmul(epochSupplyToken, epochs[epochID].supplyFulfillment.value);
}
| 26,299 |
37 | // calculates the CREATE2 address for a pair without making any external calls | function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
| function pairFor(address factory, address tokenA, address tokenB) internal pure returns (address pair) {
(address token0, address token1) = sortTokens(tokenA, tokenB);
pair = address(uint(keccak256(abi.encodePacked(
hex'ff',
factory,
keccak256(abi.encodePacked(token0, token1)),
hex'96e8ac4277198ff8b6f785478aa9a39f403cb768dd02cbee326c3e7da348845f' // init code hash
))));
}
| 5,794 |
0 | // The interface for mintable/burnable token governance. | interface ITokenGovernance {
// The address of the mintable ERC20 token.
function token() external view returns (IMintableToken);
/// @dev Mints new tokens.
///
/// @param to Account to receive the new amount.
/// @param amount Amount to increase the supply by.
///
function mint(address to, uint256 amount) external;
/// @dev Burns tokens from the caller.
///
/// @param amount Amount to decrease the supply by.
///
function burn(uint256 amount) external;
}
| interface ITokenGovernance {
// The address of the mintable ERC20 token.
function token() external view returns (IMintableToken);
/// @dev Mints new tokens.
///
/// @param to Account to receive the new amount.
/// @param amount Amount to increase the supply by.
///
function mint(address to, uint256 amount) external;
/// @dev Burns tokens from the caller.
///
/// @param amount Amount to decrease the supply by.
///
function burn(uint256 amount) external;
}
| 29,625 |
1 | // initializes global limits | function Initialize(
GlobalLimitsData storage data,
uint256 maxFallPercent, // how much can the exchange rate collapse in a time interval in percent 1%=1e16
uint256 priceControlTimeIntervalMinutes, // time interval for price control (after this interval the next price measurement takes place)
uint256 price // initial cost
| function Initialize(
GlobalLimitsData storage data,
uint256 maxFallPercent, // how much can the exchange rate collapse in a time interval in percent 1%=1e16
uint256 priceControlTimeIntervalMinutes, // time interval for price control (after this interval the next price measurement takes place)
uint256 price // initial cost
| 29,065 |
12 | // the variable borrow index in ray | uint256 variableBorrowIndex = reserveData.variableBorrowIndex;
| uint256 variableBorrowIndex = reserveData.variableBorrowIndex;
| 15,995 |
158 | // X2, X3: A malicious token could block withdrawal of just THAT token. masterContracts may want to take care not to rely on withdraw always succeeding. | token.safeTransfer(to, amount);
| token.safeTransfer(to, amount);
| 72,942 |
0 | // address owner, | uint256 id,
uint256 amount,
string memory baseTokenURI
| uint256 id,
uint256 amount,
string memory baseTokenURI
| 25,601 |
74 | // burn fee shareholds |
taxesFeeSharehold_[msg.sender]
-= (propertyvalue_[_clearFrom][transferingPropertyid_[msg.sender]] / 100);
insuranceFeeSharehold_[msg.sender]
-= (propertyvalue_[_clearFrom][transferingPropertyid_[msg.sender]] / 100);
maintenanceFeeSharehold_[whoamaintenanceaddress_]
-= (propertyvalue_[_clearFrom][transferingPropertyid_[msg.sender]] / 100);
|
taxesFeeSharehold_[msg.sender]
-= (propertyvalue_[_clearFrom][transferingPropertyid_[msg.sender]] / 100);
insuranceFeeSharehold_[msg.sender]
-= (propertyvalue_[_clearFrom][transferingPropertyid_[msg.sender]] / 100);
maintenanceFeeSharehold_[whoamaintenanceaddress_]
-= (propertyvalue_[_clearFrom][transferingPropertyid_[msg.sender]] / 100);
| 64,186 |
70 | // getting user's maximium locked period ID. account user's account/ | // function getUserMaxPeriodId(address /*account*/)public view returns (uint256) {
// delegateToViewAndReturn();
// }
| // function getUserMaxPeriodId(address /*account*/)public view returns (uint256) {
// delegateToViewAndReturn();
// }
| 29,488 |
59 | // Registers a new borrower and sets for him a certain debt ratio | function _registerBorrower(address borrower, uint256 borrowerDebtRatio)
internal
| function _registerBorrower(address borrower, uint256 borrowerDebtRatio)
internal
| 15,335 |
2 | // Info of each user. | struct UserInfo {
uint256 amount; // How many tokens the user currently has.
uint256 referenceAmount; //this amount is used for computing releasable LP amount
uint256 rewardDebt; // Reward debt. See explanation below.
uint256 rewardLocked;
uint256 releaseTime;
//
// We do some fancy math here. Basically, any point in time, the amount of NERDs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accNerdPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws tokens to a pool. Here's what happens:
// 1. The pool's `accNerdPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
uint256 depositTime; //See explanation below.
//this is a dynamic value. It changes every time user deposit to the pool
//1. initial deposit X => deposit time is block time
//2. deposit more at time deposit2 without amount Y =>
// => compute current releasable amount R
// => compute diffTime = R*lockedPeriod/(X + Y) => this is the duration users can unlock R with new deposit amount
// => updated depositTime = (blocktime - diffTime/2)
}
| struct UserInfo {
uint256 amount; // How many tokens the user currently has.
uint256 referenceAmount; //this amount is used for computing releasable LP amount
uint256 rewardDebt; // Reward debt. See explanation below.
uint256 rewardLocked;
uint256 releaseTime;
//
// We do some fancy math here. Basically, any point in time, the amount of NERDs
// entitled to a user but is pending to be distributed is:
//
// pending reward = (user.amount * pool.accNerdPerShare) - user.rewardDebt
//
// Whenever a user deposits or withdraws tokens to a pool. Here's what happens:
// 1. The pool's `accNerdPerShare` (and `lastRewardBlock`) gets updated.
// 2. User receives the pending reward sent to his/her address.
// 3. User's `amount` gets updated.
// 4. User's `rewardDebt` gets updated.
uint256 depositTime; //See explanation below.
//this is a dynamic value. It changes every time user deposit to the pool
//1. initial deposit X => deposit time is block time
//2. deposit more at time deposit2 without amount Y =>
// => compute current releasable amount R
// => compute diffTime = R*lockedPeriod/(X + Y) => this is the duration users can unlock R with new deposit amount
// => updated depositTime = (blocktime - diffTime/2)
}
| 440 |
0 | // assign totalSupply to account creating this contract/ | constructor() public {
symbol = "TESTM";
name = "TestMainToken";
decimals = 5;
totalSupply = 5000000000000;
owner = msg.sender;
balances[msg.sender] = totalSupply;
emit Transfer(0x0, msg.sender, totalSupply);
}
| constructor() public {
symbol = "TESTM";
name = "TestMainToken";
decimals = 5;
totalSupply = 5000000000000;
owner = msg.sender;
balances[msg.sender] = totalSupply;
emit Transfer(0x0, msg.sender, totalSupply);
}
| 50,183 |
26 | // Get fee by tokenAddr and serviceType | uint fee = feeLists[tokenAddr].serviceFee[serviceType];
return ERC20I(tokenAddr).balanceOf(payer) >= fee;
| uint fee = feeLists[tokenAddr].serviceFee[serviceType];
return ERC20I(tokenAddr).balanceOf(payer) >= fee;
| 10,466 |
131 | // Sender supplies assets into the market and receives aTokens in exchange Accrues interest whether or not the operation succeeds, unless reverted mintAmount The amount of the underlying asset to supplyreturn uint 0=success, otherwise a failure (see ErrorReporter.sol for details) / | function mintInternal(uint mintAmount) internal nonReentrant returns (uint) {
uint error = accrueInterest();
if (error != uint(Error.NO_ERROR)) {
// accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed
return fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED);
}
// mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to
return mintFresh(msg.sender, mintAmount);
}
| function mintInternal(uint mintAmount) internal nonReentrant returns (uint) {
uint error = accrueInterest();
if (error != uint(Error.NO_ERROR)) {
// accrueInterest emits logs on errors, but we still want to log the fact that an attempted borrow failed
return fail(Error(error), FailureInfo.MINT_ACCRUE_INTEREST_FAILED);
}
// mintFresh emits the actual Mint event if successful and logs on errors, so we don't need to
return mintFresh(msg.sender, mintAmount);
}
| 11,370 |
83 | // This is safe because a user won't ever have a balance larger than totalSupply! | unchecked {
totalSupply -= value;
}
| unchecked {
totalSupply -= value;
}
| 4,299 |
66 | // Log the event | ExecutedBet(winner, loser, _amount);
| ExecutedBet(winner, loser, _amount);
| 32,278 |
406 | // Mapping from token id to sha256 hash of content | mapping(uint256 => bytes32) public tokenContentHashes;
| mapping(uint256 => bytes32) public tokenContentHashes;
| 22,047 |
5 | // Sets approved amount of tokens for spender. Returns success./_spender Address of allowed account./_value Number of approved tokens. | function approve(address _spender, uint256 _value) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
| function approve(address _spender, uint256 _value) returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
| 8,507 |
6 | // bytes4(keccak256('balanceOf(address)')) == 0x70a08231bytes4(keccak256('ownerOf(uint256)')) == 0x6352211ebytes4(keccak256('approve(address,uint256)')) == 0x095ea7b3bytes4(keccak256('getApproved(uint256)')) == 0x081812fcbytes4(keccak256('setApprovalForAll(address,bool)')) == 0xa22cb465bytes4(keccak256('isApprovedForAll(address,address)')) == 0xe985e9cbytes4(keccak256('transferFrom(address,address,uint256)')) == 0x23b872ddbytes4(keccak256('safeTransferFrom(address,address,uint256)')) == 0x42842e0ebytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)')) == 0xb88d4fde => 0x70a08231 ^ 0x6352211e ^ 0x095ea7b3 ^ 0x081812fc ^ 0xa22cb465 ^ 0xe985e9c ^ 0x23b872dd ^ 0x42842e0e ^ 0xb88d4fde == 0x80ac58cd / | bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;
| bytes4 private constant _INTERFACE_ID_ERC721 = 0x80ac58cd;
| 27,325 |
199 | // Allows owner to set Max mints per tx _newMaxMint maximum amount of tokens allowed to mint per tx. Must be >= 1 / | function setMaxMint(uint256 _newMaxMint) public onlyOwner {
require(_newMaxMint >= 1, "Max mint must be at least 1");
maxBatchSize = _newMaxMint;
}
| function setMaxMint(uint256 _newMaxMint) public onlyOwner {
require(_newMaxMint >= 1, "Max mint must be at least 1");
maxBatchSize = _newMaxMint;
}
| 33,721 |
13 | // Call Swap | pair.swap(amount0Out, amount1Out, address(this), new bytes(0));
| pair.swap(amount0Out, amount1Out, address(this), new bytes(0));
| 3,205 |
38 | // Storage / |
RaidenToken public token;
address public owner_address;
address public wallet_address;
address public whitelister_address;
|
RaidenToken public token;
address public owner_address;
address public wallet_address;
address public whitelister_address;
| 1,632 |
19 | // constant added to the timeLockMultiplier scaled by SCALE | uint256 public immutable timeLockConstant;
| uint256 public immutable timeLockConstant;
| 16,804 |
37 | // Function that moves tokens from user -> BalleMaster (BALLE allocation) -> Strat (compounding). / | function _deposit(uint256 _vid, uint256 _amount) internal {
updateVault(_vid);
VaultInfo storage vault = vaultInfo[_vid];
UserInfo storage user = userInfo[_vid][msg.sender];
uint256 pending = 0;
if (user.shares > 0) {
pending = (user.shares * vault.accBallePerShare) / 1e12 - user.rewardDebt;
if (pending > 0) {
safeBalleTransfer(msg.sender, pending);
}
}
if (_amount > 0 && !vault.paused && !vault.retired) {
vault.depositToken.safeTransferFrom(msg.sender, address(this), _amount);
vault.depositToken.safeIncreaseAllowance(vault.strat, _amount);
uint256 sharesAdded = IStrategy(vaultInfo[_vid].strat).deposit(msg.sender, _amount);
uint256 sharesTotal = IStrategy(vault.strat).sharesTotal();
uint256 depositTotal = IStrategy(vault.strat).depositTotal();
user.shares = user.shares + sharesAdded;
user.deposit = (user.shares * depositTotal) / sharesTotal;
}
user.rewardDebt = (user.shares * vault.accBallePerShare) / 1e12;
emit Deposit(msg.sender, _vid, _amount, pending);
}
| function _deposit(uint256 _vid, uint256 _amount) internal {
updateVault(_vid);
VaultInfo storage vault = vaultInfo[_vid];
UserInfo storage user = userInfo[_vid][msg.sender];
uint256 pending = 0;
if (user.shares > 0) {
pending = (user.shares * vault.accBallePerShare) / 1e12 - user.rewardDebt;
if (pending > 0) {
safeBalleTransfer(msg.sender, pending);
}
}
if (_amount > 0 && !vault.paused && !vault.retired) {
vault.depositToken.safeTransferFrom(msg.sender, address(this), _amount);
vault.depositToken.safeIncreaseAllowance(vault.strat, _amount);
uint256 sharesAdded = IStrategy(vaultInfo[_vid].strat).deposit(msg.sender, _amount);
uint256 sharesTotal = IStrategy(vault.strat).sharesTotal();
uint256 depositTotal = IStrategy(vault.strat).depositTotal();
user.shares = user.shares + sharesAdded;
user.deposit = (user.shares * depositTotal) / sharesTotal;
}
user.rewardDebt = (user.shares * vault.accBallePerShare) / 1e12;
emit Deposit(msg.sender, _vid, _amount, pending);
}
| 27,276 |
114 | // Allows owner to change max allowed DHV token per address._maxDHV New max DHV amount/ | function adminSetMaxDHV(uint256 _maxDHV) external onlyOwner {
maxTokensAmount = _maxDHV;
}
| function adminSetMaxDHV(uint256 _maxDHV) external onlyOwner {
maxTokensAmount = _maxDHV;
}
| 23,508 |
82 | // get the required fee for the released ETH bonus in the utility token-------------------------------------------------------------------------------param _user --> the address of the user----------------------------------------------------------returns the fee amount in the utility token and ETH / | function _calculateETHFee(uint _amount) internal view returns(uint uTokenFee, uint ethFee) {
uint fee = (_amount.mul(10)).div(100);
uint feeInUtoken = _proportion(fee, address(weth), address(uToken));
return (feeInUtoken, fee);
}
| function _calculateETHFee(uint _amount) internal view returns(uint uTokenFee, uint ethFee) {
uint fee = (_amount.mul(10)).div(100);
uint feeInUtoken = _proportion(fee, address(weth), address(uToken));
return (feeInUtoken, fee);
}
| 11,278 |
74 | // Public variables of the token // This creates an array with all balances // Events // Constuctor: Initializes contract with initial supply tokens to the creator of the contract / | function SmartOToken() public {
balances[msg.sender] = initialSupply; // Give the creator all initial tokens
totalSupply = initialSupply; // Update total supply
}
| function SmartOToken() public {
balances[msg.sender] = initialSupply; // Give the creator all initial tokens
totalSupply = initialSupply; // Update total supply
}
| 29,752 |
110 | // not using safe math because we don't want to throw; | if (spentToday + amount > dailyLimit || spentToday + amount < spentToday) {
return false;
}
| if (spentToday + amount > dailyLimit || spentToday + amount < spentToday) {
return false;
}
| 9,682 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.