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
|
|---|---|---|---|---|
29
|
// Set allowance for other address Allows `_spender` to spend no more than `_value` tokens in your behalf_spender The address authorized to spend _value the max amount they can spend /
|
function approve(address _spender, uint256 _value) public
|
function approve(address _spender, uint256 _value) public
| 19,762
|
519
|
// Get the duration for evaluation of remove delegator operations
|
function getRemoveDelegatorEvalDuration()
external view returns (uint256)
|
function getRemoveDelegatorEvalDuration()
external view returns (uint256)
| 3,343
|
405
|
// Initiates Default action function hashes for existing categories To be called after the contract has been upgraded by governance/
|
function updateCategoryActionHashes() external onlyOwner {
|
function updateCategoryActionHashes() external onlyOwner {
| 28,635
|
5
|
// See {ERC721Enumerable-totalSupply}.
|
uint256 public totalSupply;
|
uint256 public totalSupply;
| 11,315
|
26
|
// Returns the decimals places of the token./
|
function decimals() external view returns (uint8);
|
function decimals() external view returns (uint8);
| 9,459
|
1
|
// Sepolia LINK token contract
|
address link_token_contract = 0x779877A7B0D9E8603169DdbD7836e478b4624789;
|
address link_token_contract = 0x779877A7B0D9E8603169DdbD7836e478b4624789;
| 15,817
|
101
|
// Whether `a` is greater than or equal to `b`. a an int256. b a FixedPoint.Signed.return True if `a >= b`, or False. /
|
function isGreaterThanOrEqual(int256 a, Signed memory b) internal pure returns (bool) {
return fromUnscaledInt(a).rawValue >= b.rawValue;
}
|
function isGreaterThanOrEqual(int256 a, Signed memory b) internal pure returns (bool) {
return fromUnscaledInt(a).rawValue >= b.rawValue;
}
| 5,565
|
3
|
// Last time rewards were applicable
|
function lastTimeRewardApplicable() public view returns (uint256) {
return Math.min(block.timestamp, periodFinish);
}
|
function lastTimeRewardApplicable() public view returns (uint256) {
return Math.min(block.timestamp, periodFinish);
}
| 8,171
|
7
|
// price
|
uint256 public tombPriceOne;
uint256 public tombPriceCeiling;
uint256 public seigniorageSaved;
uint256[] public supplyTiers;
uint256[] public maxExpansionTiers;
uint256 public maxSupplyExpansionPercent;
uint256 public bondDepletionFloorPercent;
|
uint256 public tombPriceOne;
uint256 public tombPriceCeiling;
uint256 public seigniorageSaved;
uint256[] public supplyTiers;
uint256[] public maxExpansionTiers;
uint256 public maxSupplyExpansionPercent;
uint256 public bondDepletionFloorPercent;
| 18,884
|
300
|
// get the enzyme shares address
|
function _getSharesAddress() internal view virtual returns (address) {}
|
function _getSharesAddress() internal view virtual returns (address) {}
| 37,450
|
11
|
// Withdraw tokens from this contract/ tokenAddress '0' is reserved for native Eth/ Requires signatures from a threshold of current Root network validators.
|
function _withdraw(address _tokenAddress, uint128 _amount, address _recipient) internal nonReentrant {
require(withdrawalsActive, "ERC20Peg: withdrawals paused");
if (_tokenAddress == ETH_RESERVED_TOKEN_ADDRESS) {
(bool sent, ) = _recipient.call{value: _amount}("");
require(sent, "ERC20Peg: failed to send Ether");
} else {
SafeERC20.safeTransfer(IERC20(_tokenAddress), _recipient, _amount);
}
emit Withdraw(_recipient, _tokenAddress, _amount);
}
|
function _withdraw(address _tokenAddress, uint128 _amount, address _recipient) internal nonReentrant {
require(withdrawalsActive, "ERC20Peg: withdrawals paused");
if (_tokenAddress == ETH_RESERVED_TOKEN_ADDRESS) {
(bool sent, ) = _recipient.call{value: _amount}("");
require(sent, "ERC20Peg: failed to send Ether");
} else {
SafeERC20.safeTransfer(IERC20(_tokenAddress), _recipient, _amount);
}
emit Withdraw(_recipient, _tokenAddress, _amount);
}
| 16,682
|
94
|
// solhint-disable // InitializableHelper contract to support initializer functions. To use it, replacethe constructor with a function that has the `initializer` modifier.WARNING: Unlike constructors, initializer functions must be manuallyinvoked. This applies both to deploying an Initializable contract, as wellas extending an Initializable contract via inheritance.WARNING: When used with inheritance, manual care must be taken to not invokea parent initializer twice, or ensure that all initializers are idempotent,because this is not dealt with automatically as with constructors. /
|
contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
*/
bool private initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private initializing;
/**
* @dev Modifier to use in the initializer function of a contract.
*/
modifier initializer() {
require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized");
bool isTopLevelCall = !initializing;
if (isTopLevelCall) {
initializing = true;
initialized = true;
}
_;
if (isTopLevelCall) {
initializing = false;
}
}
/// @dev Returns true if and only if the function is running in the constructor
function isConstructor() private view returns (bool) {
// extcodesize checks the size of the code stored in an address, and
// address returns the current address. Since the code is still not
// deployed when running a constructor, any checks on its code size will
// yield zero, making it an effective way to detect if a contract is
// under construction or not.
address self = address(this);
uint256 cs;
assembly {
cs := extcodesize(self)
}
return cs == 0;
}
// Reserved storage space to allow for layout changes in the future.
uint256[50] private ______gap;
}
|
contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
*/
bool private initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private initializing;
/**
* @dev Modifier to use in the initializer function of a contract.
*/
modifier initializer() {
require(initializing || isConstructor() || !initialized, "Contract instance has already been initialized");
bool isTopLevelCall = !initializing;
if (isTopLevelCall) {
initializing = true;
initialized = true;
}
_;
if (isTopLevelCall) {
initializing = false;
}
}
/// @dev Returns true if and only if the function is running in the constructor
function isConstructor() private view returns (bool) {
// extcodesize checks the size of the code stored in an address, and
// address returns the current address. Since the code is still not
// deployed when running a constructor, any checks on its code size will
// yield zero, making it an effective way to detect if a contract is
// under construction or not.
address self = address(this);
uint256 cs;
assembly {
cs := extcodesize(self)
}
return cs == 0;
}
// Reserved storage space to allow for layout changes in the future.
uint256[50] private ______gap;
}
| 27,140
|
258
|
// get the size of the current bitcoin address
|
sizeCurrentBitcoinAddress = uint8(_payerRefundAddress[cursor]);
|
sizeCurrentBitcoinAddress = uint8(_payerRefundAddress[cursor]);
| 5,124
|
65
|
// Returns the downcasted int16 from int256, reverting onoverflow (when the input is less than smallest int16 orgreater than largest int16). Counterpart to Solidity's `int16` operator. Requirements: - input must fit into 16 bits /
|
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
|
function toInt16(int256 value) internal pure returns (int16 downcasted) {
downcasted = int16(value);
if (downcasted != value) {
revert SafeCastOverflowedIntDowncast(16, value);
}
}
| 37,610
|
65
|
// Can only get via view functions since need to update rewards if required
|
mapping(address => AuctionLobbyParticipate)
private auctionLobbyParticipates;
mapping(address => CycleStake[]) private cycleStakes;
mapping(address => FlipStake) flipStakes;
address[] auctionLobbyParticipaters;
address[] cycleStakers;
address[] flipStakers;
|
mapping(address => AuctionLobbyParticipate)
private auctionLobbyParticipates;
mapping(address => CycleStake[]) private cycleStakes;
mapping(address => FlipStake) flipStakes;
address[] auctionLobbyParticipaters;
address[] cycleStakers;
address[] flipStakers;
| 25,636
|
86
|
// Decrease pre-tde supply
|
PRETDESupplyRemaining = PRETDESupplyRemaining.sub(tokenCount);
|
PRETDESupplyRemaining = PRETDESupplyRemaining.sub(tokenCount);
| 7,436
|
8
|
// Define an internal function '_removeEndUser' to remove this role, called by 'removeEndUser'
|
function _removeEndUser(address account) internal {
endusers.remove(account);
emit EndUserRemoved(account);
}
|
function _removeEndUser(address account) internal {
endusers.remove(account);
emit EndUserRemoved(account);
}
| 3,828
|
13
|
// Удаление верификации/
|
function DelVer(address _address) public onlyOwner{
if(RA(_address) == true){
veruser[_address] = veruser[_address].sub(0);
}
}
|
function DelVer(address _address) public onlyOwner{
if(RA(_address) == true){
veruser[_address] = veruser[_address].sub(0);
}
}
| 19,791
|
20
|
// once this action is completed the base URI cannot be changedand contract cannot be paused.
|
_saleComplete = true;
emit CloseSale(msg.sender);
|
_saleComplete = true;
emit CloseSale(msg.sender);
| 82,134
|
40
|
// Pull all the rewards in this contract
|
IERC20(rewardToken).safeTransferFrom(creator, address(this), vars.totalRewardAmount);
vars.newPledgeID = pledges.length;
|
IERC20(rewardToken).safeTransferFrom(creator, address(this), vars.totalRewardAmount);
vars.newPledgeID = pledges.length;
| 10,647
|
8
|
// The timelock contract.
|
ICompTimelock public timelock;
|
ICompTimelock public timelock;
| 43,214
|
119
|
// deploy template contract
|
address templateContract = address(new Post());
|
address templateContract = address(new Post());
| 31,039
|
6
|
// Run over the input, 3 bytes at a time.
|
for {} 1 {} {
|
for {} 1 {} {
| 23,943
|
3
|
// /
|
setContractURI('{"collectionName": "Muallaqat Digital Asset","safelistRequestStatus": "not_requested","imageUrl": "https://ipfs.muallaqat.io/xxx","externalUrl": "https://muallaqat.io","lastIngestedAt": "2023-01-24T00:08:07.000Z"}');
|
setContractURI('{"collectionName": "Muallaqat Digital Asset","safelistRequestStatus": "not_requested","imageUrl": "https://ipfs.muallaqat.io/xxx","externalUrl": "https://muallaqat.io","lastIngestedAt": "2023-01-24T00:08:07.000Z"}');
| 24,205
|
112
|
// sweep tokens for owner
|
collectTokens(tokenIn);
collectTokens(tokenOut);
|
collectTokens(tokenIn);
collectTokens(tokenOut);
| 71,643
|
44
|
// Collection of functions related to the address type /
|
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
|
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain`call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
| 36,989
|
26
|
// _validateItemSold(_nftAddress, _tokenId, _owner, _msgSender());
|
emit ItemSold(
_owner,
_msgSender(),
_nftAddress,
_tokenId,
listedItem.quantity,
_payToken,
price / (listedItem.quantity)
);
|
emit ItemSold(
_owner,
_msgSender(),
_nftAddress,
_tokenId,
listedItem.quantity,
_payToken,
price / (listedItem.quantity)
);
| 3,855
|
120
|
// update totalMembers of this current Tier at index i
|
totalTiers[_clubId][i].totalMembers = totalTiers[_clubId][i].totalMembers - totalWipedOffMemberPerTiers;
|
totalTiers[_clubId][i].totalMembers = totalTiers[_clubId][i].totalMembers - totalWipedOffMemberPerTiers;
| 14,319
|
8
|
// `balances` is the map that tracks the balance of each address, in thiscontract when the balance changes the block number that the changeoccurred is also included in the map
|
mapping (address => Checkpoint[]) balances;
|
mapping (address => Checkpoint[]) balances;
| 16,372
|
187
|
// Mint NFT and send those to the list of given addresses/
|
function airdrop(uint256 _id, address[] memory _addresses) public onlyMinter {
require(tokenMaxSupply[_id] - tokenSupply[_id] >= _addresses.length, "Cant mint above max supply");
for (uint256 i = 0; i < _addresses.length; i++) {
mint(_addresses[i], _id, 1, "");
}
}
|
function airdrop(uint256 _id, address[] memory _addresses) public onlyMinter {
require(tokenMaxSupply[_id] - tokenSupply[_id] >= _addresses.length, "Cant mint above max supply");
for (uint256 i = 0; i < _addresses.length; i++) {
mint(_addresses[i], _id, 1, "");
}
}
| 25,979
|
29
|
// Transfer the funds to a customer for chargeback as a dipsute case got approved
|
token.transfer(
escrows[disputes[_disputeId].escrowId].buyerAdderss,
escrows[disputes[_disputeId].escrowId].amount
);
emit Refunded(
escrows[disputes[_disputeId].escrowId].buyerAdderss,
disputes[_disputeId].escrowId,
escrows[disputes[_disputeId].escrowId].amount
);
|
token.transfer(
escrows[disputes[_disputeId].escrowId].buyerAdderss,
escrows[disputes[_disputeId].escrowId].amount
);
emit Refunded(
escrows[disputes[_disputeId].escrowId].buyerAdderss,
disputes[_disputeId].escrowId,
escrows[disputes[_disputeId].escrowId].amount
);
| 13,839
|
15
|
// A Gelato Task Chain consists of 1 or more Tasks that automatically submitthe next one, after they have been executed, where the total number of tasks canbe an odd number/
|
function submitTaskChain(
|
function submitTaskChain(
| 51,342
|
27
|
// Allows the pendingOwner address to finalize the transfer./
|
function claimOwnership() public onlyPendingOwner {
emit OwnershipTransferred(owner(), pendingOwner());
addressStorage[keccak256("owner")] = addressStorage[keccak256("pendingOwner")];
addressStorage[keccak256("pendingOwner")] = address(0);
}
|
function claimOwnership() public onlyPendingOwner {
emit OwnershipTransferred(owner(), pendingOwner());
addressStorage[keccak256("owner")] = addressStorage[keccak256("pendingOwner")];
addressStorage[keccak256("pendingOwner")] = address(0);
}
| 62,503
|
5
|
// Throws if called by any account other than the owner./
|
modifier onlyOwner() {
require(owner() == msg.sender, "#OO:029");
_;
}
|
modifier onlyOwner() {
require(owner() == msg.sender, "#OO:029");
_;
}
| 31,719
|
2
|
// withdrawal variables
|
address[] public wallets;
uint256[] public walletsShares;
uint256 public totalShares;
|
address[] public wallets;
uint256[] public walletsShares;
uint256 public totalShares;
| 24,260
|
20
|
// Interface for contracts conforming to ERC-721: Non-Fungible Tokens/Dieter Shirley <dete@axiomzen.co> (https:github.com/dete)
|
contract ERC721 {
// Required methods
function balanceOf(address _owner) public view returns (uint256 balance);
function ownerOf(uint256 _assetId) public view returns (address owner);
function approve(address _to, uint256 _assetId) public;
function transfer(address _to, uint256 _assetId) public;
function transferFrom(address _from, address _to, uint256 _assetId) public;
function implementsERC721() public pure returns (bool);
function takeOwnership(uint256 _assetId) public;
function totalSupply() public view returns (uint256 total);
event Transfer(address indexed from, address indexed to, uint256 tokenId);
event Approval(address indexed owner, address indexed approved, uint256 tokenId);
// Optional
// function name() public view returns (string name);
// function symbol() public view returns (string symbol);
// function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256 tokenId);
// function tokenMetadata(uint256 _assetId) public view returns (string infoUrl);
// ERC-165 Compatibility (https://github.com/ethereum/EIPs/issues/165)
function supportsInterface(bytes4 _interfaceID) external view returns (bool);
}
|
contract ERC721 {
// Required methods
function balanceOf(address _owner) public view returns (uint256 balance);
function ownerOf(uint256 _assetId) public view returns (address owner);
function approve(address _to, uint256 _assetId) public;
function transfer(address _to, uint256 _assetId) public;
function transferFrom(address _from, address _to, uint256 _assetId) public;
function implementsERC721() public pure returns (bool);
function takeOwnership(uint256 _assetId) public;
function totalSupply() public view returns (uint256 total);
event Transfer(address indexed from, address indexed to, uint256 tokenId);
event Approval(address indexed owner, address indexed approved, uint256 tokenId);
// Optional
// function name() public view returns (string name);
// function symbol() public view returns (string symbol);
// function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256 tokenId);
// function tokenMetadata(uint256 _assetId) public view returns (string infoUrl);
// ERC-165 Compatibility (https://github.com/ethereum/EIPs/issues/165)
function supportsInterface(bytes4 _interfaceID) external view returns (bool);
}
| 1,526
|
230
|
// ============ External Functions ============ //Calculates total inflation percentage then mints new Sets to the fee recipient. Position units arethen adjusted down (in magnitude) in order to ensure full collateralization. Callable by anyone._setToken Address of SetToken /
|
function accrueFee(ISetToken _setToken) public nonReentrant onlyValidAndInitializedSet(_setToken) {
uint256 managerFee;
uint256 protocolFee;
if (_streamingFeePercentage(_setToken) > 0) {
uint256 inflationFeePercentage = _calculateStreamingFee(_setToken);
|
function accrueFee(ISetToken _setToken) public nonReentrant onlyValidAndInitializedSet(_setToken) {
uint256 managerFee;
uint256 protocolFee;
if (_streamingFeePercentage(_setToken) > 0) {
uint256 inflationFeePercentage = _calculateStreamingFee(_setToken);
| 40,902
|
0
|
// Interface of the ERC20 standard as defined in the EIP. /
|
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
|
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| 251
|
32
|
// determine if the blueprint is taking a short or long position on the ticker
|
if (_exitTkrPrice > _entryTkrPrice) {
short = false;
} else {
|
if (_exitTkrPrice > _entryTkrPrice) {
short = false;
} else {
| 20,121
|
227
|
// Pay or lockup pending cnt.
|
function payOrLockupPendingcnt(uint256 _pid,address _user) internal {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
if (user.nextHarvestUntil == 0) {
user.nextHarvestUntil = block.timestamp.add(pool.harvestInterval);
}
uint256 pending =
user.amount.mul(pool.accCNTPerShare).div(1e12).sub(user.rewardDebt);
if (canHarvest(_pid, _user)) {
if (pending > 0 || user.rewardLockedUp > 0) {
uint256 totalRewards = pending.add(user.rewardLockedUp);
// reset lockup
totalLockedUpRewards = totalLockedUpRewards.sub(
user.rewardLockedUp
);
user.rewardLockedUp = 0;
user.nextHarvestUntil = block.timestamp.add(
pool.harvestInterval
);
// send rewards
safeCNTTransfer(_user, totalRewards);
}
} else if (pending > 0) {
user.rewardLockedUp = user.rewardLockedUp.add(pending);
totalLockedUpRewards = totalLockedUpRewards.add(pending);
emit RewardLockedUp(_user, _pid, pending);
}
}
|
function payOrLockupPendingcnt(uint256 _pid,address _user) internal {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
if (user.nextHarvestUntil == 0) {
user.nextHarvestUntil = block.timestamp.add(pool.harvestInterval);
}
uint256 pending =
user.amount.mul(pool.accCNTPerShare).div(1e12).sub(user.rewardDebt);
if (canHarvest(_pid, _user)) {
if (pending > 0 || user.rewardLockedUp > 0) {
uint256 totalRewards = pending.add(user.rewardLockedUp);
// reset lockup
totalLockedUpRewards = totalLockedUpRewards.sub(
user.rewardLockedUp
);
user.rewardLockedUp = 0;
user.nextHarvestUntil = block.timestamp.add(
pool.harvestInterval
);
// send rewards
safeCNTTransfer(_user, totalRewards);
}
} else if (pending > 0) {
user.rewardLockedUp = user.rewardLockedUp.add(pending);
totalLockedUpRewards = totalLockedUpRewards.add(pending);
emit RewardLockedUp(_user, _pid, pending);
}
}
| 28,857
|
13
|
// Queues transaction in the timelock _target The address of the target contract _value The value that the transaction needs _signature The signature of the function to be executed _data The data required to execute the function _etathe eta on which the transaction will be available /
|
function queueTransaction(
address _target,
uint256 _value,
string memory _signature,
bytes memory _data,
uint256 _eta
|
function queueTransaction(
address _target,
uint256 _value,
string memory _signature,
bytes memory _data,
uint256 _eta
| 36,402
|
4
|
// Event logging
|
event LogEnrolled(address accountAddress);
event LogNewPostAdded(uint256 postId, string title, string fullName, address accountAddress);
event LogUpVote(uint256 postId, string title, uint votes, string fullName, address accountAddress);
event LogDownVote(uint256 postId, string title, uint votes, string fullName, address accountAddress);
event LogComment(uint256 postId, uint256 commentId, string commentBody, string fullName, address accountAddress);
|
event LogEnrolled(address accountAddress);
event LogNewPostAdded(uint256 postId, string title, string fullName, address accountAddress);
event LogUpVote(uint256 postId, string title, uint votes, string fullName, address accountAddress);
event LogDownVote(uint256 postId, string title, uint votes, string fullName, address accountAddress);
event LogComment(uint256 postId, uint256 commentId, string commentBody, string fullName, address accountAddress);
| 42,434
|
74
|
// keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
|
bytes32 public constant PERMIT_TYPEHASH =
0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
bytes32 public DOMAIN_SEPARATOR;
|
bytes32 public constant PERMIT_TYPEHASH =
0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
bytes32 public DOMAIN_SEPARATOR;
| 14,680
|
283
|
// Initial value of Elo.
|
uint32 _winnerElo = addressToElo[_winnerAddress];
if (_winnerElo == 0)
_winnerElo = 1500;
uint32 _loserElo = addressToElo[_loserAddress];
if (_loserElo == 0)
_loserElo = 1500;
|
uint32 _winnerElo = addressToElo[_winnerAddress];
if (_winnerElo == 0)
_winnerElo = 1500;
uint32 _loserElo = addressToElo[_loserAddress];
if (_loserElo == 0)
_loserElo = 1500;
| 36,351
|
67
|
// set the rest of the contract variables
|
uniswapV2Router = _uniswapV2Router;
deployedAtBlock = block.number;
|
uniswapV2Router = _uniswapV2Router;
deployedAtBlock = block.number;
| 37,865
|
11
|
// The timestamp when LYD mining starts.
|
uint256 public startTimestamp;
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);
event SetDevAddress(address indexed user, address indexed newAddress);
event UpdateEmissionRate(address indexed user, uint256 _lydPerSec);
constructor(
LydToken _lyd,
|
uint256 public startTimestamp;
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);
event SetDevAddress(address indexed user, address indexed newAddress);
event UpdateEmissionRate(address indexed user, uint256 _lydPerSec);
constructor(
LydToken _lyd,
| 32,019
|
37
|
// Receives arbitrator extra data at arbitrable item level. Should be called only by the arbitrable contract. _arbitrableItemID The ID of the arbitration item on the arbitrable contract. _arbitratorExtraData The extra data for the arbitrator. /
|
function receiveArbitratorExtraData(
address _arbitrable,
uint256 _arbitrableItemID,
bytes calldata _arbitratorExtraData
|
function receiveArbitratorExtraData(
address _arbitrable,
uint256 _arbitrableItemID,
bytes calldata _arbitratorExtraData
| 22,677
|
45
|
// A library for performing overflow-/underflow-safe addition and subtraction on uint224.
|
library BoringMath224 {
function add(uint224 a, uint224 b) internal pure returns (uint224 c) {
require((c = a + b) >= b, "BoringMath: Add Overflow");
}
function sub(uint224 a, uint224 b) internal pure returns (uint224 c) {
require((c = a - b) <= a, "BoringMath: Underflow");
}
function mul(uint224 a, uint224 b) internal pure returns (uint224 c) {
require(b == 0 || (c = a * b) / b == a, "BoringMath: Mul Overflow");
}
function div(uint224 a, uint224 b) internal pure returns (uint224) {
require(b > 0, "BoringMath: division by zero");
return a / b;
}
}
|
library BoringMath224 {
function add(uint224 a, uint224 b) internal pure returns (uint224 c) {
require((c = a + b) >= b, "BoringMath: Add Overflow");
}
function sub(uint224 a, uint224 b) internal pure returns (uint224 c) {
require((c = a - b) <= a, "BoringMath: Underflow");
}
function mul(uint224 a, uint224 b) internal pure returns (uint224 c) {
require(b == 0 || (c = a * b) / b == a, "BoringMath: Mul Overflow");
}
function div(uint224 a, uint224 b) internal pure returns (uint224) {
require(b > 0, "BoringMath: division by zero");
return a / b;
}
}
| 4,859
|
138
|
// Creates `_amount` token to `_to`. Must only be called by the owner (MasterChef).
|
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
|
function mint(address _to, uint256 _amount) public onlyOwner {
_mint(_to, _amount);
_moveDelegates(address(0), _delegates[_to], _amount);
}
| 5,242
|
10
|
// Return the current contract's interests rate per block./ return The amount of interests currently producing per each block.
|
function interestsPerBlock() external view returns (uint256);
|
function interestsPerBlock() external view returns (uint256);
| 4,829
|
267
|
// Delete the slot where the moved value was stored
|
set._values.pop();
|
set._values.pop();
| 48
|
85
|
// Add all permission signatures to regulator/
|
function addAllPermissions(Regulator regulator) public {
// Make this contract a temporary validator to add all permissions
regulator.addValidator(this);
regulator.addPermission(regulator.MINT_SIG(), "", "", "" );
regulator.addPermission(regulator.BURN_SIG(), "", "", "" );
regulator.addPermission(regulator.DESTROY_BLACKLISTED_TOKENS_SIG(), "", "", "" );
regulator.addPermission(regulator.APPROVE_BLACKLISTED_ADDRESS_SPENDER_SIG(), "", "", "" );
regulator.addPermission(regulator.BLACKLISTED_SIG(), "", "", "" );
regulator.addPermission(regulator.CONVERT_CARBON_DOLLAR_SIG(), "", "", "" );
regulator.addPermission(regulator.BURN_CARBON_DOLLAR_SIG(), "", "", "" );
regulator.addPermission(regulator.MINT_CUSD_SIG(), "", "", "" );
regulator.addPermission(regulator.CONVERT_WT_SIG(), "", "", "" );
regulator.removeValidator(this);
}
|
function addAllPermissions(Regulator regulator) public {
// Make this contract a temporary validator to add all permissions
regulator.addValidator(this);
regulator.addPermission(regulator.MINT_SIG(), "", "", "" );
regulator.addPermission(regulator.BURN_SIG(), "", "", "" );
regulator.addPermission(regulator.DESTROY_BLACKLISTED_TOKENS_SIG(), "", "", "" );
regulator.addPermission(regulator.APPROVE_BLACKLISTED_ADDRESS_SPENDER_SIG(), "", "", "" );
regulator.addPermission(regulator.BLACKLISTED_SIG(), "", "", "" );
regulator.addPermission(regulator.CONVERT_CARBON_DOLLAR_SIG(), "", "", "" );
regulator.addPermission(regulator.BURN_CARBON_DOLLAR_SIG(), "", "", "" );
regulator.addPermission(regulator.MINT_CUSD_SIG(), "", "", "" );
regulator.addPermission(regulator.CONVERT_WT_SIG(), "", "", "" );
regulator.removeValidator(this);
}
| 31,746
|
249
|
// _bid will throw if the bid or funds transfer fails
|
_bid(_tokenId, msg.value);
_transfer(msg.sender, _tokenId);
|
_bid(_tokenId, msg.value);
_transfer(msg.sender, _tokenId);
| 26,461
|
52
|
// Transfers `amount` tokens of token type `id` from `from` to `to`. Emits a {TransferSingle} event. Requirements: - `to` cannot be the zero address.- If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.- `from` must have a balance of tokens of type `id` of at least `amount`.- If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return theacceptance magic value. /
|
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;
|
function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;
| 4,411
|
4
|
// Returns the assigned Mint Cooldown Rate
|
function mintCooldownRate() external view returns(uint16) {
return _mintCoolRate;
}
|
function mintCooldownRate() external view returns(uint16) {
return _mintCoolRate;
}
| 20,347
|
37
|
// profit = pnl + fundingPayments
|
profit = _closePosition(lp, global, tentativeVQuoteAmount);
delete lpPosition[account];
|
profit = _closePosition(lp, global, tentativeVQuoteAmount);
delete lpPosition[account];
| 3,123
|
3
|
// Events // Modifiers /
|
modifier onlyValid(string calldata questionId) {
require(questionExist(questionId), "Cryptopati: invalid question");
_;
}
|
modifier onlyValid(string calldata questionId) {
require(questionExist(questionId), "Cryptopati: invalid question");
_;
}
| 22,301
|
0
|
// @custom:oz-upgrades-unsafe-allow constructorconstructor() initializer {}
|
function _initialize(
address _owner,
string memory _name,
string memory _symbol,
string memory _description,
string memory _url
) initializer public {
__ERC1155_init(_url);
__Ownable_init();
|
function _initialize(
address _owner,
string memory _name,
string memory _symbol,
string memory _description,
string memory _url
) initializer public {
__ERC1155_init(_url);
__Ownable_init();
| 1,276
|
94
|
// exlcude from fees
|
mapping (address => bool) private _isExcludedFromFees;
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapEthForTokens(uint256 amountIn, address[] path);
event SwapAndLiquify(uint256 tokensIntoLiqudity, uint256 ethReceived);
event ExcludeFromFees(address indexed account, bool isExcluded);
event MaxWalletAmountUpdated(uint256 prevValue, uint256 newValue);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
|
mapping (address => bool) private _isExcludedFromFees;
event SwapAndLiquifyEnabledUpdated(bool enabled);
event SwapEthForTokens(uint256 amountIn, address[] path);
event SwapAndLiquify(uint256 tokensIntoLiqudity, uint256 ethReceived);
event ExcludeFromFees(address indexed account, bool isExcluded);
event MaxWalletAmountUpdated(uint256 prevValue, uint256 newValue);
event SwapAndLiquify(
uint256 tokensSwapped,
uint256 ethReceived,
| 41,869
|
90
|
// Get someone's address from their team JUST playerbook name
|
function getAddressFromReferralName(string memory refName) public view returns (address){
return playerBook.getPlayerAddr(playerBook.pIDxName_(stringToBytes32(refName)));
}
|
function getAddressFromReferralName(string memory refName) public view returns (address){
return playerBook.getPlayerAddr(playerBook.pIDxName_(stringToBytes32(refName)));
}
| 16,377
|
8
|
// bytes32(uint256(keccak256('eip1967.Holograph.utilityToken')) - 1) /
|
bytes32 constant _utilityTokenSlot = 0xbf76518d46db472b71aa7677a0908b8016f3dee568415ffa24055f9a670f9c37;
|
bytes32 constant _utilityTokenSlot = 0xbf76518d46db472b71aa7677a0908b8016f3dee568415ffa24055f9a670f9c37;
| 25,624
|
0
|
// To specify a value at a given point in time, we need to store two values: - `time`: unit-time value to denote the first time when a value was registered - `value`: a positive numeric value to registered at a given point in timeNote that `time` does not need to refer necessarily to a timestamp value, any time unit could be used for it like block numbers, terms, etc. /
|
struct Checkpoint {
uint64 time;
uint192 value;
}
|
struct Checkpoint {
uint64 time;
uint192 value;
}
| 22,592
|
44
|
// setter who set fund collector fundCollector address of fund collector /
|
event FundCollectorSet(
address indexed setter,
address indexed fundCollector
);
|
event FundCollectorSet(
address indexed setter,
address indexed fundCollector
);
| 40,192
|
0
|
// https:github.com/dapphub/ds-pause
|
interface DSPauseAbstract {
function setOwner(address) external;
function setAuthority(address) external;
function setDelay(uint256) external;
function plans(bytes32) external view returns (bool);
function proxy() external view returns (address);
function delay() external view returns (uint256);
function plot(address, bytes32, bytes calldata, uint256) external;
function drop(address, bytes32, bytes calldata, uint256) external;
function exec(address, bytes32, bytes calldata, uint256) external returns (bytes memory);
}
|
interface DSPauseAbstract {
function setOwner(address) external;
function setAuthority(address) external;
function setDelay(uint256) external;
function plans(bytes32) external view returns (bool);
function proxy() external view returns (address);
function delay() external view returns (uint256);
function plot(address, bytes32, bytes calldata, uint256) external;
function drop(address, bytes32, bytes calldata, uint256) external;
function exec(address, bytes32, bytes calldata, uint256) external returns (bytes memory);
}
| 42,962
|
2
|
// reorder the candidate key fragments (sort)
|
bytes memory candidate_key = new bytes(candidate_key_length);
for(uint j=0; j < vote.fragments.length; j++){
candidate_key[vote.fragments[j].candidate_key_fragment_position] = bytes(vote.fragments[j].candidate_key_fragment)[0];
}
|
bytes memory candidate_key = new bytes(candidate_key_length);
for(uint j=0; j < vote.fragments.length; j++){
candidate_key[vote.fragments[j].candidate_key_fragment_position] = bytes(vote.fragments[j].candidate_key_fragment)[0];
}
| 2,494
|
57
|
// Function returns stored (without accruing) exchange rate of cpTokens for currency tokens/ return Stored exchange rate as 10-digits decimal
|
function _storedExchangeRate() internal view returns (uint256) {
if (totalSupply() == 0) {
return Decimal.ONE;
} else if (debtClaimed) {
return cash().divDecimal(totalSupply());
} else {
return (_availableToProviders(_info) + _info.borrows).divDecimal(totalSupply());
}
}
|
function _storedExchangeRate() internal view returns (uint256) {
if (totalSupply() == 0) {
return Decimal.ONE;
} else if (debtClaimed) {
return cash().divDecimal(totalSupply());
} else {
return (_availableToProviders(_info) + _info.borrows).divDecimal(totalSupply());
}
}
| 1,199
|
64
|
// this low-level function should be called from a contract which performs important safety checks
|
function mint(uint amount0Desired, uint amount1Desired, uint amount0Min, uint amount1Min, address to) external payable returns (uint128 liquidity) {
(liquidity,,) = _addLiquidity(AddLiquidityParams(token0, token1, fee, to, tickLower, tickUpper, amount0Desired, amount1Desired, amount0Min, amount1Min));
_mint(to, liquidity);
if (address(this).balance > 0) _safeTransferETH(msg.sender, address(this).balance);
}
|
function mint(uint amount0Desired, uint amount1Desired, uint amount0Min, uint amount1Min, address to) external payable returns (uint128 liquidity) {
(liquidity,,) = _addLiquidity(AddLiquidityParams(token0, token1, fee, to, tickLower, tickUpper, amount0Desired, amount1Desired, amount0Min, amount1Min));
_mint(to, liquidity);
if (address(this).balance > 0) _safeTransferETH(msg.sender, address(this).balance);
}
| 1,858
|
264
|
// Constraint expression for public_memory_value_zero: column3_row3.
|
let val := /*column3_row3*/ mload(0x1c80)
|
let val := /*column3_row3*/ mload(0x1c80)
| 32,110
|
34
|
// 1-32 teams
|
modifier validTeam(uint8 _teamId) {
require(_teamId > 0 && _teamId < 33);
_;
}
|
modifier validTeam(uint8 _teamId) {
require(_teamId > 0 && _teamId < 33);
_;
}
| 36,508
|
36
|
// revert if the strategy mutated since this tx was sent
|
if (!_equalStrategyOrders(currentOrders, orders)) {
revert OutDated();
}
|
if (!_equalStrategyOrders(currentOrders, orders)) {
revert OutDated();
}
| 13,827
|
0
|
// @TODO: see if we can just set .length =
|
function trimToSize(bytes memory b, uint newLen)
internal
pure
|
function trimToSize(bytes memory b, uint newLen)
internal
pure
| 34,922
|
34
|
// Only allows approved admins to call the specified function /
|
modifier adminRequired() {
require(owner() == msg.sender || _admins.contains(msg.sender), "AdminControl: Must be owner or admin");
_;
}
|
modifier adminRequired() {
require(owner() == msg.sender || _admins.contains(msg.sender), "AdminControl: Must be owner or admin");
_;
}
| 43,630
|
236
|
// Mints some amount of tokens to an address _toAddress of the future owner of the token _idToken ID to mint _quantityAmount of tokens to mint _dataData to pass if receiver is contract /
|
function mint(
address _to,
uint256 _id,
uint256 _quantity,
bytes memory _data
|
function mint(
address _to,
uint256 _id,
uint256 _quantity,
bytes memory _data
| 10,277
|
189
|
// Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.The call is not executed if the target address is not a contract.from address representing the previous owner of the given token ID to target address that will receive the tokens tokenId uint256 ID of the token to be transferred _data bytes optional data to send along with the callreturn bool whether the call correctly returned the expected magic value /
|
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try
IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data)
returns (bytes4 retval) {
|
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try
IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data)
returns (bytes4 retval) {
| 2,161
|
123
|
// The following assert() holds true because: - The system always contains >= 1 trove - When we close or liquidate a trove, we redistribute the pending rewards, so if all troves were closed/liquidated, rewards would’ve been emptied and totalCollateralSnapshot would be zero too./
|
assert(totalStakesSnapshot > 0);
stake = _coll.mul(totalStakesSnapshot).div(totalCollateralSnapshot);
|
assert(totalStakesSnapshot > 0);
stake = _coll.mul(totalStakesSnapshot).div(totalCollateralSnapshot);
| 4,014
|
68
|
// Remove a node from the list _id Node's id /
|
function remove(Data storage self, address _id) public {
// List must contain the node
require(contains(self, _id), "node not in list");
if (self.size > 1) {
// List contains more than a single node
if (_id == self.head) {
// The removed node is the head
// Set head to next node
self.head = self.nodes[_id].nextId;
// Set prev pointer of new head to null
self.nodes[self.head].prevId = address(0);
} else if (_id == self.tail) {
// The removed node is the tail
// Set tail to previous node
self.tail = self.nodes[_id].prevId;
// Set next pointer of new tail to null
self.nodes[self.tail].nextId = address(0);
} else {
// The removed node is neither the head nor the tail
// Set next pointer of previous node to the next node
self.nodes[self.nodes[_id].prevId].nextId = self.nodes[_id].nextId;
// Set prev pointer of next node to the previous node
self.nodes[self.nodes[_id].nextId].prevId = self.nodes[_id].prevId;
}
} else {
// List contains a single node
// Set the head and tail to null
self.head = address(0);
self.tail = address(0);
}
delete self.nodes[_id];
self.size = self.size.sub(1);
}
|
function remove(Data storage self, address _id) public {
// List must contain the node
require(contains(self, _id), "node not in list");
if (self.size > 1) {
// List contains more than a single node
if (_id == self.head) {
// The removed node is the head
// Set head to next node
self.head = self.nodes[_id].nextId;
// Set prev pointer of new head to null
self.nodes[self.head].prevId = address(0);
} else if (_id == self.tail) {
// The removed node is the tail
// Set tail to previous node
self.tail = self.nodes[_id].prevId;
// Set next pointer of new tail to null
self.nodes[self.tail].nextId = address(0);
} else {
// The removed node is neither the head nor the tail
// Set next pointer of previous node to the next node
self.nodes[self.nodes[_id].prevId].nextId = self.nodes[_id].nextId;
// Set prev pointer of next node to the previous node
self.nodes[self.nodes[_id].nextId].prevId = self.nodes[_id].prevId;
}
} else {
// List contains a single node
// Set the head and tail to null
self.head = address(0);
self.tail = address(0);
}
delete self.nodes[_id];
self.size = self.size.sub(1);
}
| 42,542
|
60
|
// Ex1: trade 50 OMG -> ETH -> EOS Step1: trade 50 OMG -> ETH Step2: trade xx ETH -> EOS "0x5b9a857e0C3F2acc5b94f6693536d3Adf5D6e6Be", "30000000000000000000", "0xd3c64BbA75859Eb808ACE6F2A6048ecdb2d70817", "1", ["0x0000000000000000000000000000000000000000", "0x5b9a857e0C3F2acc5b94f6693536d3Adf5D6e6Be", "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "0x0000000000000000000000000000000000000000", "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "0xd3c64BbA75859Eb808ACE6F2A6048ecdb2d70817"] Ex2: trade 50 OMG -> ETH -> DAI Step1: trade 50 OMG -> ETH Step2: trade xx ETH -> DAI "0x5b9a857e0C3F2acc5b94f6693536d3Adf5D6e6Be", "30000000000000000000", "0x45ad02b30930cad22ff7921c111d22943c6c822f", "1", ["0x0000000000000000000000000000000000000000", "0x5b9a857e0C3F2acc5b94f6693536d3Adf5D6e6Be", "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "0x0000000000000000000000000000000000000001", "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "0x45ad02b30930cad22ff7921c111d22943c6c822f"]
|
function tradeRoutes(
ERC20 src,
uint256 srcAmount,
ERC20 dest,
uint256 minDestAmount,
address[] _tradingPaths)
|
function tradeRoutes(
ERC20 src,
uint256 srcAmount,
ERC20 dest,
uint256 minDestAmount,
address[] _tradingPaths)
| 27,931
|
31
|
// Convert SVG to base64 to include in the metadata
|
string memory svgBase64 = Base64.encode(bytes(svgImage));
avatar = string(abi.encodePacked("data:image/svg+xml;base64,", svgBase64));
|
string memory svgBase64 = Base64.encode(bytes(svgImage));
avatar = string(abi.encodePacked("data:image/svg+xml;base64,", svgBase64));
| 27,704
|
140
|
// balance of an ERC20 token within swap contracttoken ERC20 token address
|
function balanceOfToken(address token) public view returns (uint256) {
return IERC20(token).balanceOf(address(this));
}
|
function balanceOfToken(address token) public view returns (uint256) {
return IERC20(token).balanceOf(address(this));
}
| 35,130
|
177
|
// _vault The vault where the ETH backing the pledges is stored
|
function initialize(address _vault) onlyInit public {
require(_vault != 0x0);
initialized();
vault = ILPVault(_vault);
admins.length = 1; // we reserve the 0 admin
pledges.length = 1; // we reserve the 0 pledge
}
|
function initialize(address _vault) onlyInit public {
require(_vault != 0x0);
initialized();
vault = ILPVault(_vault);
admins.length = 1; // we reserve the 0 admin
pledges.length = 1; // we reserve the 0 pledge
}
| 2,494
|
116
|
// withdraw tokens amount within vesting rules for reserved wallet /
|
function reservedWithdraw() public {
|
function reservedWithdraw() public {
| 49,875
|
27
|
// update tail of bucket
|
Bucket storage b = checkPoints[bucket];
b.tail = expireId;
if(b.head == 0){
|
Bucket storage b = checkPoints[bucket];
b.tail = expireId;
if(b.head == 0){
| 5,407
|
10
|
// Load the aggregated stats into memory; noop if no pools to finalize.
|
IStructs.AggregatedStats memory aggregatedStats = aggregatedStatsByEpoch[prevEpoch];
if (aggregatedStats.numPoolsToFinalize == 0) {
return;
}
|
IStructs.AggregatedStats memory aggregatedStats = aggregatedStatsByEpoch[prevEpoch];
if (aggregatedStats.numPoolsToFinalize == 0) {
return;
}
| 13,405
|
8
|
// Calculates the fair amount of funds to ragequit based on the token, units and loot. It takes into account the historical guild balance when the kick proposal was created.slither-disable-next-line calls-loop
|
uint256 amountToRagequit = FairShareHelper.calc(
bank.balanceOf(GUILD, token),
unitsAndLootToBurn,
initialTotalTokens
);
|
uint256 amountToRagequit = FairShareHelper.calc(
bank.balanceOf(GUILD, token),
unitsAndLootToBurn,
initialTotalTokens
);
| 9,514
|
4
|
// No zeros
|
require(quantity > 0, "Too few");
|
require(quantity > 0, "Too few");
| 27,827
|
54
|
// Checks whether a storage slot has already been retrieved, and marks it as retrieved if not. _contract Address of the contract to check. _key 32 byte storage slot key.return Whether or not the slot was already loaded. /
|
function testAndSetContractStorageLoaded(
address _contract,
bytes32 _key
)
override
public
authenticated
returns (
bool
)
|
function testAndSetContractStorageLoaded(
address _contract,
bytes32 _key
)
override
public
authenticated
returns (
bool
)
| 67,488
|
6
|
// add x% to this strategy We assume that this contract is a minter on underlying
|
ERC20Mintable(address(underlying)).mint(address(this),
balance.mul(profitRateNumerator + variation).div(profitRateDenominator));
|
ERC20Mintable(address(underlying)).mint(address(this),
balance.mul(profitRateNumerator + variation).div(profitRateDenominator));
| 27,871
|
53
|
// Called by bZx after a borrower has changed the collateral token/used for an open loan/loanOrderHash A unique hash representing the loan order/borrower The borrower/gasUsed The initial used gas, collected in a modifier in bZx, for optional gas refunds/ return Successful execution of the function
|
function didChangeCollateral(
bytes32 loanOrderHash,
address borrower,
uint gasUsed)
external
returns (bool);
|
function didChangeCollateral(
bytes32 loanOrderHash,
address borrower,
uint gasUsed)
external
returns (bool);
| 4,769
|
11
|
// Pauses the contract /
|
function pause() external onlyOwner whenNotPaused {
_pause();
}
|
function pause() external onlyOwner whenNotPaused {
_pause();
}
| 3,063
|
145
|
// The manager has control over options like fees and features
|
function setManager(address _manager) external;
function mint(
uint256[] calldata tokenIds,
uint256[] calldata amounts /* ignored for ERC721 vaults */
) external returns (uint256);
function mintTo(
uint256[] calldata tokenIds,
uint256[] calldata amounts, /* ignored for ERC721 vaults */
|
function setManager(address _manager) external;
function mint(
uint256[] calldata tokenIds,
uint256[] calldata amounts /* ignored for ERC721 vaults */
) external returns (uint256);
function mintTo(
uint256[] calldata tokenIds,
uint256[] calldata amounts, /* ignored for ERC721 vaults */
| 1,595
|
344
|
// 0 is a sentinel and therefore invalid. A valid node is the head or has a previous node.
|
return id != 0 && (id == stakeNodes[0].next || stakeNodes[id].prev != 0);
|
return id != 0 && (id == stakeNodes[0].next || stakeNodes[id].prev != 0);
| 45,646
|
245
|
// place a bid for a cat, referenced by its index in the current auction /
|
function bid(uint64 index) public payable {
(uint256 startId, uint256 endId) = auctionsState();
// bids can only be placed while in an auction
require(startId > endId, "not in auction");
// cats are referenced by their index in the auction
require(index < auctionsCatsPerAuction, "bad index");
uint256 catId = startId + index;
// users may increase their bid by sending the difference of the total amount
// they want to bid, and their current bid
uint256 newBid = bidsByTokenByAddress[catId][msg.sender] + msg.value;
// make sure their new bid covers the bid increment amount
require(
newBid >= highBidAmount[catId] + auctionsBidIncrement,
"not enough"
);
// increment the bid count
bidCount[catId] += 1;
// set the high bid amount
highBidAmount[catId] = newBid;
// set the high bid owner
highBidOwner[catId] = msg.sender;
// set the user's bid on this cat (for withdraws, later)
bidsByTokenByAddress[catId][msg.sender] = newBid;
emit Bid(msg.sender, catId, newBid, bidCount[catId]);
}
|
function bid(uint64 index) public payable {
(uint256 startId, uint256 endId) = auctionsState();
// bids can only be placed while in an auction
require(startId > endId, "not in auction");
// cats are referenced by their index in the auction
require(index < auctionsCatsPerAuction, "bad index");
uint256 catId = startId + index;
// users may increase their bid by sending the difference of the total amount
// they want to bid, and their current bid
uint256 newBid = bidsByTokenByAddress[catId][msg.sender] + msg.value;
// make sure their new bid covers the bid increment amount
require(
newBid >= highBidAmount[catId] + auctionsBidIncrement,
"not enough"
);
// increment the bid count
bidCount[catId] += 1;
// set the high bid amount
highBidAmount[catId] = newBid;
// set the high bid owner
highBidOwner[catId] = msg.sender;
// set the user's bid on this cat (for withdraws, later)
bidsByTokenByAddress[catId][msg.sender] = newBid;
emit Bid(msg.sender, catId, newBid, bidCount[catId]);
}
| 8,127
|
3
|
// Returns an `uint256[MAX_COLUMN_WORDS]` located at `slot`./
|
function getColumn(bytes32 slot) internal pure returns (bytes32[MAX_COLUMN_WORDS] storage r) {
uint256 public constant COLUMN_TYPE_UINT16 = 6;
uint256 public constant COLUMN_TYPE_UINT8 = 7;
uint256 public constant COLUMN_TYPE_NATIVE_STRING = 8;
// solhint-disable-next-line no-inline-assembly
assembly {
r.slot := slot
}
}
|
function getColumn(bytes32 slot) internal pure returns (bytes32[MAX_COLUMN_WORDS] storage r) {
uint256 public constant COLUMN_TYPE_UINT16 = 6;
uint256 public constant COLUMN_TYPE_UINT8 = 7;
uint256 public constant COLUMN_TYPE_NATIVE_STRING = 8;
// solhint-disable-next-line no-inline-assembly
assembly {
r.slot := slot
}
}
| 26,712
|
12
|
// wasnt withdrawn because validator needs to be taken of active validators
|
if (balance() == prevBalance) {
|
if (balance() == prevBalance) {
| 22,773
|
73
|
// Multiple token transfers from one address to save gas /
|
function transferMultiple(address[] _addresses, uint[] _amounts) external {
require( tradeable() );
require( _addresses.length == _amounts.length );
require( _addresses.length <= 100 );
uint i;
// check token amounts
uint tokens_to_transfer = 0;
for (i = 0; i < _addresses.length; i++) {
tokens_to_transfer = tokens_to_transfer.add(_amounts[i]);
}
require( tokens_to_transfer <= unlockedTokens(msg.sender) );
// do the transfers
for (i = 0; i < _addresses.length; i++) {
super.transfer(_addresses[i], _amounts[i]);
}
}
|
function transferMultiple(address[] _addresses, uint[] _amounts) external {
require( tradeable() );
require( _addresses.length == _amounts.length );
require( _addresses.length <= 100 );
uint i;
// check token amounts
uint tokens_to_transfer = 0;
for (i = 0; i < _addresses.length; i++) {
tokens_to_transfer = tokens_to_transfer.add(_amounts[i]);
}
require( tokens_to_transfer <= unlockedTokens(msg.sender) );
// do the transfers
for (i = 0; i < _addresses.length; i++) {
super.transfer(_addresses[i], _amounts[i]);
}
}
| 9,112
|
29
|
// Function which withdraw LP tokens to messege sender with the given amount _pid: pool ID from which the LP tokens should be withdrawn _amount: the amount of LP tokens that should be withdrawn /
|
function withdraw(uint256 _pid, uint256 _amount) public poolExists(_pid) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = (user.amount * pool.accRewardPerShare) /
1e12 -
user.rewardDebt;
safeRewardTransfer(msg.sender, pending);
emit Harvest(msg.sender, _pid, pending);
user.amount -= _amount;
user.rewardDebt = (user.amount * pool.accRewardPerShare) / 1e12;
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
|
function withdraw(uint256 _pid, uint256 _amount) public poolExists(_pid) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][msg.sender];
require(user.amount >= _amount, "withdraw: not good");
updatePool(_pid);
uint256 pending = (user.amount * pool.accRewardPerShare) /
1e12 -
user.rewardDebt;
safeRewardTransfer(msg.sender, pending);
emit Harvest(msg.sender, _pid, pending);
user.amount -= _amount;
user.rewardDebt = (user.amount * pool.accRewardPerShare) / 1e12;
pool.lpToken.safeTransfer(address(msg.sender), _amount);
emit Withdraw(msg.sender, _pid, _amount);
}
| 6,402
|
5
|
// NOTE: Only the admin can call this function. See {ProxyAdmin-getProxyImplementation}. TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the`0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc` /
|
function implementation() external ifAdmin returns (address implementation_) {
implementation_ = _implementation();
}
|
function implementation() external ifAdmin returns (address implementation_) {
implementation_ = _implementation();
}
| 25,238
|
7
|
// Sort the timestamps array
|
uint256[] memory sortedTimestamps = new uint256[](1);
sortedTimestamps[0] = timestamps;
|
uint256[] memory sortedTimestamps = new uint256[](1);
sortedTimestamps[0] = timestamps;
| 23,272
|
56
|
// calculate stakes
|
uint256 count = 0;
|
uint256 count = 0;
| 17,043
|
28
|
// keyRevisionNumber: incremented every time the public keys change
|
uint32 keyRevisionNumber;
|
uint32 keyRevisionNumber;
| 19,488
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.