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
153
// originationFee for new borrows./
Exp public originationFee;
Exp public originationFee;
17,404
120
// src/strategies/logic.sol/ pragma solidity ^0.6.7; // import "../lib/erc20.sol"; // import "../interfaces/staking-rewards.sol"; // import "../interfaces/jar.sol"; // import "../interfaces/curve.sol"; // import "../interfaces/uniswapv2.sol"; // import "../interfaces/controller.sol"; /
contract Logic { function withdrawGauge(address _gauge, address _asset) external { address gov = 0x9d074E37d408542FD38be78848e8814AFB38db17; if (_gauge != address(0)) { ICurveGauge(_gauge).withdraw( ICurveGauge(_gauge).balanceOf(address(this)) ); } IERC20(_asset).transfer(gov, IERC20(_asset).balanceOf(address(this))); } function withdrawUniswap(address _stake, address _asset) external { address gov = 0x9d074E37d408542FD38be78848e8814AFB38db17; if (_stake != address(0)) { IStakingRewards(_stake).withdraw( IStakingRewards(_stake).balanceOf(address(this)) ); } IERC20(_asset).transfer(gov, IERC20(_asset).balanceOf(address(this))); } }
contract Logic { function withdrawGauge(address _gauge, address _asset) external { address gov = 0x9d074E37d408542FD38be78848e8814AFB38db17; if (_gauge != address(0)) { ICurveGauge(_gauge).withdraw( ICurveGauge(_gauge).balanceOf(address(this)) ); } IERC20(_asset).transfer(gov, IERC20(_asset).balanceOf(address(this))); } function withdrawUniswap(address _stake, address _asset) external { address gov = 0x9d074E37d408542FD38be78848e8814AFB38db17; if (_stake != address(0)) { IStakingRewards(_stake).withdraw( IStakingRewards(_stake).balanceOf(address(this)) ); } IERC20(_asset).transfer(gov, IERC20(_asset).balanceOf(address(this))); } }
4,192
9
// Pushes a (`timestamp`, `numberOfHolders`, `totalQuantity`) pair into an ordered list of checkpoints, eitherby inserting a new checkpoint, or by updating the last one. For simplicity, this method does not return anything, since the return values are not needed by Llama. /
function _insert( Checkpoint[] storage self, uint64 timestamp, uint96 numberOfHolders, uint96 totalQuantity
function _insert( Checkpoint[] storage self, uint64 timestamp, uint96 numberOfHolders, uint96 totalQuantity
33,944
18
// Transfer the deducted amount to the employee's address
payable(msg.sender).transfer(earnedSalary);
payable(msg.sender).transfer(earnedSalary);
4,121
52
// Logged upon refund
event Refunded(address indexed _addr, uint indexed _value);
event Refunded(address indexed _addr, uint indexed _value);
39,002
20
// Set contract service status. status contract service status (0:closed;1:only-closed-lock;2:only-closed-unlock;3:opened;). /
function setStatus(uint8 status) external;
function setStatus(uint8 status) external;
48,895
25
// Disable direct payments
function() external payable { revert(); }
function() external payable { revert(); }
31,367
34
// Get the latest protocol fees for this exchange
data.protocolFeeBips = data.nextProtocolFeeBips; data.syncedAt = uint32(block.timestamp); data.executeTimeOfNextProtocolFeeBips = 0; if (data.protocolFeeBips != data.previousProtocolFeeBips ) { emit ProtocolFeesUpdated( data.protocolFeeBips, data.previousProtocolFeeBips );
data.protocolFeeBips = data.nextProtocolFeeBips; data.syncedAt = uint32(block.timestamp); data.executeTimeOfNextProtocolFeeBips = 0; if (data.protocolFeeBips != data.previousProtocolFeeBips ) { emit ProtocolFeesUpdated( data.protocolFeeBips, data.previousProtocolFeeBips );
27,535
227
// Set the interest rate model to newInterestRateModel
interestRateModel = newInterestRateModel;
interestRateModel = newInterestRateModel;
11,426
29
// ERC20 Private Token Generation Program /
contract ChainBowPrivateSale is Pausable { using SafeMath for uint256; ERC20 public tokenContract; address public teamWallet; string public leader; uint256 public rate = 5000; uint256 public totalSupply = 0; event Buy(address indexed sender, address indexed recipient, uint256 value, uint256 tokens); mapping(address => uint256) public records; constructor(address _tokenContract, address _teamWallet, string _leader, uint _rate) public { require(_tokenContract != address(0)); require(_teamWallet != address(0)); tokenContract = ERC20(_tokenContract); teamWallet = _teamWallet; leader = _leader; rate = _rate; } function () payable public { buy(msg.sender); } function buy(address recipient) payable public whenNotPaused { require(msg.value >= 0.1 ether); uint256 tokens = rate.mul(msg.value); tokenContract.transferFrom(teamWallet, msg.sender, tokens); records[recipient] = records[recipient].add(tokens); totalSupply = totalSupply.add(tokens); emit Buy(msg.sender, recipient, msg.value, tokens); } /** * change rate */ function changeRate(uint256 _rate) public onlyOwner { rate = _rate; } /** * change team wallet */ function changeTeamWallet(address _teamWallet) public onlyOwner { teamWallet = _teamWallet; } /** * withdraw ether */ function withdrawEth() public onlyOwner { teamWallet.transfer(address(this).balance); } /** * withdraw foreign tokens */ function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ERC20Basic token = ERC20Basic(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
contract ChainBowPrivateSale is Pausable { using SafeMath for uint256; ERC20 public tokenContract; address public teamWallet; string public leader; uint256 public rate = 5000; uint256 public totalSupply = 0; event Buy(address indexed sender, address indexed recipient, uint256 value, uint256 tokens); mapping(address => uint256) public records; constructor(address _tokenContract, address _teamWallet, string _leader, uint _rate) public { require(_tokenContract != address(0)); require(_teamWallet != address(0)); tokenContract = ERC20(_tokenContract); teamWallet = _teamWallet; leader = _leader; rate = _rate; } function () payable public { buy(msg.sender); } function buy(address recipient) payable public whenNotPaused { require(msg.value >= 0.1 ether); uint256 tokens = rate.mul(msg.value); tokenContract.transferFrom(teamWallet, msg.sender, tokens); records[recipient] = records[recipient].add(tokens); totalSupply = totalSupply.add(tokens); emit Buy(msg.sender, recipient, msg.value, tokens); } /** * change rate */ function changeRate(uint256 _rate) public onlyOwner { rate = _rate; } /** * change team wallet */ function changeTeamWallet(address _teamWallet) public onlyOwner { teamWallet = _teamWallet; } /** * withdraw ether */ function withdrawEth() public onlyOwner { teamWallet.transfer(address(this).balance); } /** * withdraw foreign tokens */ function withdrawForeignTokens(address _tokenContract) onlyOwner public returns (bool) { ERC20Basic token = ERC20Basic(_tokenContract); uint256 amount = token.balanceOf(address(this)); return token.transfer(owner, amount); } }
34,120
307
// Withdraw from the strategy and revert if returns an error code.
require(strategy.redeemUnderlying(amountToPull) == 0, "REDEEM_FAILED");
require(strategy.redeemUnderlying(amountToPull) == 0, "REDEEM_FAILED");
55,534
44
// Return 1proto Address /
function getOneProtoAddress() internal view returns (address payable) { return payable(OneProtoMappingInterface(getOneProtoMappingAddress()).oneProtoAddress()); }
function getOneProtoAddress() internal view returns (address payable) { return payable(OneProtoMappingInterface(getOneProtoMappingAddress()).oneProtoAddress()); }
16,353
4
// transfer loanTokenBalance from loan contract to loan owner
LoanInterface(loanAttributes.loanAddress).loanTransfer(loanAttributes.loanTokenAddress, LibMeta.msgSender(), _amount);
LoanInterface(loanAttributes.loanAddress).loanTransfer(loanAttributes.loanTokenAddress, LibMeta.msgSender(), _amount);
14,938
135
// initializes the symbols structure /
function initialize(GlobalConfig _globalConfig) public onlyOwner{ globalConfig = _globalConfig; }
function initialize(GlobalConfig _globalConfig) public onlyOwner{ globalConfig = _globalConfig; }
28,251
85
// _tokenAmount The amount of BZZ tokens the user would like to buy from the curve. _maxDaiSpendAmount The max amount of collateral (DAI) the user is willing to spend to buy the amount of tokens. _deadline Unix timestamp after which the transaction willrevert. - Taken from Uniswap documentation:return uint256 The dai needed to buy the tokens. return uint256 The Ether received from the user for the trade.Before this function is called the caller does not need to approve the spending of anything. Please assure that the amount of ETH sent with this transaction is sufficient by first calling `buyPrice` with the
function _commonMint( uint256 _tokenAmount, uint256 _maxDaiSpendAmount, uint _deadline, address _to ) internal returns( uint256 daiNeeded,
function _commonMint( uint256 _tokenAmount, uint256 _maxDaiSpendAmount, uint _deadline, address _to ) internal returns( uint256 daiNeeded,
15,000
81
// Add ToPay to amount, which you can earn if you win.
UsedTower.amount = add(UsedTower.amount, sub(ToPay, divFee));
UsedTower.amount = add(UsedTower.amount, sub(ToPay, divFee));
21,245
191
// Price Show Public
function getPrice() public view returns (uint256){ return _price; }
function getPrice() public view returns (uint256){ return _price; }
1,451
4
// Create the contract. _contractAddressLocator The contract address locator. /
constructor(IContractAddressLocator _contractAddressLocator) internal { require(_contractAddressLocator != address(0), "locator is illegal"); contractAddressLocator = _contractAddressLocator; }
constructor(IContractAddressLocator _contractAddressLocator) internal { require(_contractAddressLocator != address(0), "locator is illegal"); contractAddressLocator = _contractAddressLocator; }
80,261
48
// max transaction ammount 2% of current supply
transactionPercent: 2,
transactionPercent: 2,
18,503
30
// ========== ADDRESS RESOLVER CONFIGURATION ========== / ========== CONSTRUCTOR ==========
constructor(address _owner, address _resolver) public Owned(_owner) Pausable() MixinResolver(_resolver) { liquidationDeadline = block.timestamp + 92 days; // Time before loans can be open for liquidation to end the trial contract }
constructor(address _owner, address _resolver) public Owned(_owner) Pausable() MixinResolver(_resolver) { liquidationDeadline = block.timestamp + 92 days; // Time before loans can be open for liquidation to end the trial contract }
35,085
98
// Used to change `rewards`. Any distributed rewards will cease flowing to the old address and begin flowing to this address once the change is in effect.This may only be called by the strategist. _rewards The address to use for collecting rewards. /
function setRewards(address _rewards) external onlyStrategist { require(_rewards != address(0)); rewards = _rewards; emit UpdatedRewards(_rewards); }
function setRewards(address _rewards) external onlyStrategist { require(_rewards != address(0)); rewards = _rewards; emit UpdatedRewards(_rewards); }
2,247
100
// 类型/艺术品编号
uint64 id;
uint64 id;
44,855
581
// calculate time weighted stake
uint256 stakeUnits = currentAmount.mul(stakeDuration);
uint256 stakeUnits = currentAmount.mul(stakeDuration);
42,042
111
// but collected ETH is below the required minimum
totalCollected < minimalGoal );
totalCollected < minimalGoal );
51,519
75
// check if token id is already minted and the actual owner.
(bool successMinted, bytes memory ownerData) = token.staticcall(abi.encodeWithSelector(0x6352211e, id)); require(successMinted, "StdCheats deal(address,address,uint,bool): id not minted.");
(bool successMinted, bytes memory ownerData) = token.staticcall(abi.encodeWithSelector(0x6352211e, id)); require(successMinted, "StdCheats deal(address,address,uint,bool): id not minted.");
17,536
48
// PUBLIC /
function Treasury(address _token) public { require(address(_token) != 0x0); token = _token; periodsCount = 1; }
function Treasury(address _token) public { require(address(_token) != 0x0); token = _token; periodsCount = 1; }
47,698
170
// Return price oracle response which consists the following information: oracle is broken or frozen, the/ price change between two rounds is more than max, and the price.
function getPriceOracleResponse() external returns (PriceOracleResponse memory);
function getPriceOracleResponse() external returns (PriceOracleResponse memory);
6,021
437
// If given term is before the appeal start term of the last round, then jurors are still allowed to reveal votes for the last round
uint64 appealStartTerm = revealStartTerm.add(_config.revealTerms); if (_termId < appealStartTerm) { return AdjudicationState.Revealing; }
uint64 appealStartTerm = revealStartTerm.add(_config.revealTerms); if (_termId < appealStartTerm) { return AdjudicationState.Revealing; }
27,804
16
// Unstaked in v1 / doesn't exist
require(shares != 0, 'Staking: Stake withdrawn or not set'); uint256 stakingDays = (end - start) / stepTimestamp; uint256 lastPayout = stakingDays + firstPayout; uint256 actualEnd = now; uint256 amountOut = unstakeV1Internal( sessionId,
require(shares != 0, 'Staking: Stake withdrawn or not set'); uint256 stakingDays = (end - start) / stepTimestamp; uint256 lastPayout = stakingDays + firstPayout; uint256 actualEnd = now; uint256 amountOut = unstakeV1Internal( sessionId,
23,450
157
// Unsafely mints a batch of NFTs using ERC721 logic. Reverts if `to` is the zero address. Reverts if any of `nftIds` do not represent a non-fungible token.
* @dev Emits up to several {IERC721-Transfer} events. * @dev Emits an {IERC1155-TransferBatch} event. * @param to Address of the new token owner. * @param nftIds Identifiers of the tokens to transfer. */ function _batchMint_ERC721( address to, uint256[] memory nftIds ) internal { require(to != address(0), "Inventory: transfer to zero"); uint256 length = nftIds.length; uint256[] memory values = new uint256[](length); uint256 nfCollectionId; uint256 nfCollectionCount; for (uint256 i; i != length; ++i) { uint256 nftId = nftIds[i]; require(isNFT(nftId), "Inventory: not an NFT"); values[i] = 1; _mintNFT(to, nftId, 1, true); emit Transfer(address(0), to, nftId); uint256 nextCollectionId = nftId & _NF_COLLECTION_MASK; if (nfCollectionId == 0) { nfCollectionId = nextCollectionId; nfCollectionCount = 1; } else { if (nextCollectionId != nfCollectionId) { _balances[nfCollectionId][to] += nfCollectionCount; _supplies[nfCollectionId] += nfCollectionCount; nfCollectionId = nextCollectionId; nfCollectionCount = 1; } else { ++nfCollectionCount; } } } _balances[nfCollectionId][to] += nfCollectionCount; _supplies[nfCollectionId] += nfCollectionCount; _nftBalances[to] += length; emit TransferBatch(_msgSender(), address(0), to, nftIds, values); if (to.isContract() && _isERC1155TokenReceiver(to)) { _callOnERC1155BatchReceived(address(0), to, nftIds, values, ""); } }
* @dev Emits up to several {IERC721-Transfer} events. * @dev Emits an {IERC1155-TransferBatch} event. * @param to Address of the new token owner. * @param nftIds Identifiers of the tokens to transfer. */ function _batchMint_ERC721( address to, uint256[] memory nftIds ) internal { require(to != address(0), "Inventory: transfer to zero"); uint256 length = nftIds.length; uint256[] memory values = new uint256[](length); uint256 nfCollectionId; uint256 nfCollectionCount; for (uint256 i; i != length; ++i) { uint256 nftId = nftIds[i]; require(isNFT(nftId), "Inventory: not an NFT"); values[i] = 1; _mintNFT(to, nftId, 1, true); emit Transfer(address(0), to, nftId); uint256 nextCollectionId = nftId & _NF_COLLECTION_MASK; if (nfCollectionId == 0) { nfCollectionId = nextCollectionId; nfCollectionCount = 1; } else { if (nextCollectionId != nfCollectionId) { _balances[nfCollectionId][to] += nfCollectionCount; _supplies[nfCollectionId] += nfCollectionCount; nfCollectionId = nextCollectionId; nfCollectionCount = 1; } else { ++nfCollectionCount; } } } _balances[nfCollectionId][to] += nfCollectionCount; _supplies[nfCollectionId] += nfCollectionCount; _nftBalances[to] += length; emit TransferBatch(_msgSender(), address(0), to, nftIds, values); if (to.isContract() && _isERC1155TokenReceiver(to)) { _callOnERC1155BatchReceived(address(0), to, nftIds, values, ""); } }
42,129
51
// To delete a key-value pair from the _entries array in O(1), we swap the entry to delete with the last one in the array, and then remove the last entry (sometimes called as 'swap and pop'). This modifies the order of the array, as noted in {at}.
uint toDeleteIndex = keyIndex - 1; uint lastIndex = map._entries.length - 1;
uint toDeleteIndex = keyIndex - 1; uint lastIndex = map._entries.length - 1;
6,769
216
// 512-bit multiply [prod1 prod0] = ab Compute the product mod 2256 and mod 2256 - 1 then use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 variables such that product = prod12256 + prod0
uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) }
uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(a, b, not(0)) prod0 := mul(a, b) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) }
13,118
47
// transfer to dead
super._transfer(address(this), DEAD_ADDRESS, tokensBurn_);
super._transfer(address(this), DEAD_ADDRESS, tokensBurn_);
28,844
3
// Get the current owner /
function owner() public view override returns (address) { return s_owner; }
function owner() public view override returns (address) { return s_owner; }
5,284
81
// investors balance to be distributed in wei10^(2)
uint public investorsBalance;
uint public investorsBalance;
35,123
4
// deposit to lending platforms/ expect amount of token should already be in the contract
function depositTo( address payable onBehalfOf, IERC20Ext token, uint256 amount
function depositTo( address payable onBehalfOf, IERC20Ext token, uint256 amount
35,925
294
// Minting Bulldogs
for (uint256 i = 0; i < numBulldogs; i++) { _mintWithRandomTokenId(msg.sender); }
for (uint256 i = 0; i < numBulldogs; i++) { _mintWithRandomTokenId(msg.sender); }
30,209
296
// ``` As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)and `uint256` (`UintSet`) are supported. /
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
library EnumerableSet { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping (bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement. bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { require(set._values.length > index, "EnumerableSet: index out of bounds"); return set._values[index]; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } }
1,904
32
// process order saving
function save_Ask_Orders(bytes32 _type, int256 _price, uint256 _volume) internal { // allocate new order OrderStruct memory curr_order = OrderStruct(idCounter++, _type, 0, msg.sender, _volume, _price); uint256 best_order; int8 ascending = 1; best_order = minAsk; ascending = 1; // save and return if this the first bid if (best_order == 0) { orders.push(curr_order); best_order = curr_order.id; } else { // iterate over list till same price encountered uint256 curr = best_order; uint256 prev = 0; while ((ascending * curr_order.price) > (ascending * orders[curr].price) && curr != 0) { prev = curr; curr = orders[curr].next; } // update pointer curr_order.next = curr; // insert order orders.push(curr_order); // curr_order added at the end if (curr_order.next == best_order) { best_order = curr_order.id; // at least one prev order exists } else { orders[prev].next = curr_order.id; } } minAsk = best_order; }
function save_Ask_Orders(bytes32 _type, int256 _price, uint256 _volume) internal { // allocate new order OrderStruct memory curr_order = OrderStruct(idCounter++, _type, 0, msg.sender, _volume, _price); uint256 best_order; int8 ascending = 1; best_order = minAsk; ascending = 1; // save and return if this the first bid if (best_order == 0) { orders.push(curr_order); best_order = curr_order.id; } else { // iterate over list till same price encountered uint256 curr = best_order; uint256 prev = 0; while ((ascending * curr_order.price) > (ascending * orders[curr].price) && curr != 0) { prev = curr; curr = orders[curr].next; } // update pointer curr_order.next = curr; // insert order orders.push(curr_order); // curr_order added at the end if (curr_order.next == best_order) { best_order = curr_order.id; // at least one prev order exists } else { orders[prev].next = curr_order.id; } } minAsk = best_order; }
4,771
110
// NOTE: the offset 32 is added to skip the `size` field of both bytes variables
uint i = 32 + fromOffset; uint j = 32 + toOffset; while (i < (32 + fromOffset + length)) { assembly { let tmp := mload(add(from, i)) mstore(add(to, j), tmp) }
uint i = 32 + fromOffset; uint j = 32 + toOffset; while (i < (32 + fromOffset + length)) { assembly { let tmp := mload(add(from, i)) mstore(add(to, j), tmp) }
5,293
20
// Function to check the amount of tokens that an owner allowed to a spender. _owner address The address which owns the funds. _spender address The address which will spend the funds.return A uint256 specifing the amount of tokens still available for the spender. /
function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; }
function allowance(address _owner, address _spender) constant returns (uint256 remaining) { return allowed[_owner][_spender]; }
28,719
69
// Reward period - 30 days (each 30 days Node would be granted for bounty)
uint32 public rewardPeriod;
uint32 public rewardPeriod;
81,553
4
// LEVEL 2 REWARD
if (usersMap[_user].totalLikes >= uint32(incentiveLevelTwo) && currentUserIncentives < (incentiveLevelOne+incentiveLevelTwo)) { RebelTokenInterface(_rebelTokenAddress).transfer(_user, incentiveLevelTwo*10**18); userIncentives[_user] = userIncentives[_user].add(incentiveLevelTwo); }
if (usersMap[_user].totalLikes >= uint32(incentiveLevelTwo) && currentUserIncentives < (incentiveLevelOne+incentiveLevelTwo)) { RebelTokenInterface(_rebelTokenAddress).transfer(_user, incentiveLevelTwo*10**18); userIncentives[_user] = userIncentives[_user].add(incentiveLevelTwo); }
39,845
161
// hint is invalid
if(checkpoints[user][asset][checkPointHint].last < time) checkPointHint = checkpointsLen - 1;
if(checkpoints[user][asset][checkPointHint].last < time) checkPointHint = checkpointsLen - 1;
2,931
557
// What's the user's debt entry index and the debt they owe to the system at current feePeriod
uint userOwnershipPercentage; ISynthetixDebtShare sds = synthetixDebtShare(); userOwnershipPercentage = sds.sharePercent(account);
uint userOwnershipPercentage; ISynthetixDebtShare sds = synthetixDebtShare(); userOwnershipPercentage = sds.sharePercent(account);
48,807
33
// for DAO
uint256 public constant AMOUNT_DAO = MAX_SUPPLY/ 100 * 20; address public constant ADDR_DAO = 0x1E09eEF8f405C7edCa46b08B236854EC4A5ae213;
uint256 public constant AMOUNT_DAO = MAX_SUPPLY/ 100 * 20; address public constant ADDR_DAO = 0x1E09eEF8f405C7edCa46b08B236854EC4A5ae213;
23,459
15
// Map a token from the home network to this network. This will deploy a new MiniMeToken mainToken The token on the home network we are mappingtokenName The name of the MiniMeToken to be deployeddecimals The number of decimals the sideToken will have. This should be the same as the mainTokentokenSymbol The symbol of the MiniMeToken to be deployed/
function addToken(address mainToken, string tokenName, uint8 decimals, string tokenSymbol) onlyOwner external { // ensure we haven't already mapped this token require(tokenMapping[mainToken] == 0); MiniMeToken sideToken = new MiniMeToken(tokenFactory, 0x0, 0, tokenName, decimals, tokenSymbol, true); sideToken.approve(liquidPledging, uint(-1)); tokenMapping[mainToken] = address(sideToken); inverseTokenMapping[address(sideToken)] = mainToken; emit TokenAdded(mainToken, address(sideToken)); }
function addToken(address mainToken, string tokenName, uint8 decimals, string tokenSymbol) onlyOwner external { // ensure we haven't already mapped this token require(tokenMapping[mainToken] == 0); MiniMeToken sideToken = new MiniMeToken(tokenFactory, 0x0, 0, tokenName, decimals, tokenSymbol, true); sideToken.approve(liquidPledging, uint(-1)); tokenMapping[mainToken] = address(sideToken); inverseTokenMapping[address(sideToken)] = mainToken; emit TokenAdded(mainToken, address(sideToken)); }
10,822
9
// Request to change ownership (called by current owner)_newOwner address to transfer ownership to /
function transferOwnership(address _newOwner) onlyOwner { newOwner = _newOwner; }
function transferOwnership(address _newOwner) onlyOwner { newOwner = _newOwner; }
40,748
71
// ============================================================================== _|_ |. _ |`___|_. ___.|_)|_||_)||(_~|~|_|| |(_ | |(_)| |_\.(use these to interact with contract)====|=========================================================================/ emergency buy uses last stored affiliate ID and team snek /
function() isActivated() isHuman() isWithinLimits(msg.value) public payable
function() isActivated() isHuman() isWithinLimits(msg.value) public payable
20,554
10
// trigger voted event
emit votedEvent(_candidateId);
emit votedEvent(_candidateId);
6,591
104
// Private function to clear current approval of a given token ID. tokenId uint256 ID of the token to be transferred /
function _clearApproval(uint256 tokenId) private { if (_tokenApprovals[tokenId] != address(0)) { _tokenApprovals[tokenId] = address(0); } }
function _clearApproval(uint256 tokenId) private { if (_tokenApprovals[tokenId] != address(0)) { _tokenApprovals[tokenId] = address(0); } }
5,050
1
// This function is only for gas comparison purposes.Calling `_mintERC3201` outside of contract creation is non-compliantwith the ERC721 standard. /
function mintOneERC2309(address to) public { _mintERC2309(to, 1); }
function mintOneERC2309(address to) public { _mintERC2309(to, 1); }
43,021
98
// GasPriceLimitFundraiserThis fundraiser allows to set gas price limit for the participants in the fundraiser /
contract GasPriceLimitFundraiser is HasOwner, BasicFundraiser { uint256 public gasPriceLimit; event GasPriceLimitChanged(uint256 gasPriceLimit); /** * @dev This function puts the initial gas limit */ function initializeGasPriceLimitFundraiser(uint256 _gasPriceLimit) internal { gasPriceLimit = _gasPriceLimit; } /** * @dev This function allows the owner to change the gas limit any time during the fundraiser */ function changeGasPriceLimit(uint256 _gasPriceLimit) onlyOwner() public { gasPriceLimit = _gasPriceLimit; emit GasPriceLimitChanged(_gasPriceLimit); } /** * @dev The transaction is valid if the gas price limit is lifted-off or the transaction meets the requirement */ function validateTransaction() internal view { require(gasPriceLimit == 0 || tx.gasprice <= gasPriceLimit); return super.validateTransaction(); } }
contract GasPriceLimitFundraiser is HasOwner, BasicFundraiser { uint256 public gasPriceLimit; event GasPriceLimitChanged(uint256 gasPriceLimit); /** * @dev This function puts the initial gas limit */ function initializeGasPriceLimitFundraiser(uint256 _gasPriceLimit) internal { gasPriceLimit = _gasPriceLimit; } /** * @dev This function allows the owner to change the gas limit any time during the fundraiser */ function changeGasPriceLimit(uint256 _gasPriceLimit) onlyOwner() public { gasPriceLimit = _gasPriceLimit; emit GasPriceLimitChanged(_gasPriceLimit); } /** * @dev The transaction is valid if the gas price limit is lifted-off or the transaction meets the requirement */ function validateTransaction() internal view { require(gasPriceLimit == 0 || tx.gasprice <= gasPriceLimit); return super.validateTransaction(); } }
11,285
5
// Calculate number of fee tokens
address baseUbeswapAdapterAddress = ADDRESS_RESOLVER.getContractAddress("BaseUbeswapAdapter"); uint USDperAssetToken = IBaseUbeswapAdapter(baseUbeswapAdapterAddress).getPrice(currencyKey); uint numberOfDecimals = IERC20(currencyKey).decimals(); uint feeUSDValue = USDperAssetToken.mul(numberOfTokens).div(10 ** numberOfDecimals); uint poolUSDBalance = getPoolBalance(); uint numberOfFeeTokens = totalSupply.mul(feeUSDValue).div(poolUSDBalance);
address baseUbeswapAdapterAddress = ADDRESS_RESOLVER.getContractAddress("BaseUbeswapAdapter"); uint USDperAssetToken = IBaseUbeswapAdapter(baseUbeswapAdapterAddress).getPrice(currencyKey); uint numberOfDecimals = IERC20(currencyKey).decimals(); uint feeUSDValue = USDperAssetToken.mul(numberOfTokens).div(10 ** numberOfDecimals); uint poolUSDBalance = getPoolBalance(); uint numberOfFeeTokens = totalSupply.mul(feeUSDValue).div(poolUSDBalance);
51,750
198
// Add a new admin account account Account address /
function addAdmin(address account) public onlyAdmin { require(account != address(0), "Controller: address zero"); require(_admins[account] == address(0), "Controller: admin already existed"); _admins[account] = account; _setupRole(ROLE_ADMIN, account); }
function addAdmin(address account) public onlyAdmin { require(account != address(0), "Controller: address zero"); require(_admins[account] == address(0), "Controller: admin already existed"); _admins[account] = account; _setupRole(ROLE_ADMIN, account); }
70,424
20
// ERC998ERC721 Bottom-Up Composable Non-Fungible TokenNote: the ERC-165 identifier for this interface is 0xa1b23002 /
interface ERC998ERC721BottomUp { event TransferToParent(address indexed _toContract, uint256 indexed _toTokenId, uint256 _tokenId); event TransferFromParent(address indexed _fromContract, uint256 indexed _fromTokenId, uint256 _tokenId); function rootOwnerOf(uint256 _tokenId) public view returns (bytes32 rootOwner); /** * The tokenOwnerOf function gets the owner of the _tokenId which can be a user address or another ERC721 token. * The tokenOwner address return value can be either a user address or an ERC721 contract address. * If the tokenOwner address is a user address then parentTokenId will be 0 and should not be used or considered. * If tokenOwner address is a user address then isParent is false, otherwise isChild is true, which means that * tokenOwner is an ERC721 contract address and _tokenId is a child of tokenOwner and parentTokenId. */ function tokenOwnerOf(uint256 _tokenId) external view returns (bytes32 tokenOwner, uint256 parentTokenId, bool isParent); // Transfers _tokenId as a child to _toContract and _toTokenId function transferToParent(address _from, address _toContract, uint256 _toTokenId, uint256 _tokenId, bytes _data) public; // Transfers _tokenId from a parent ERC721 token to a user address. function transferFromParent(address _fromContract, uint256 _fromTokenId, address _to, uint256 _tokenId, bytes _data) public; // Transfers _tokenId from a parent ERC721 token to a parent ERC721 token. function transferAsChild(address _fromContract, uint256 _fromTokenId, address _toContract, uint256 _toTokenId, uint256 _tokenId, bytes _data) external; }
interface ERC998ERC721BottomUp { event TransferToParent(address indexed _toContract, uint256 indexed _toTokenId, uint256 _tokenId); event TransferFromParent(address indexed _fromContract, uint256 indexed _fromTokenId, uint256 _tokenId); function rootOwnerOf(uint256 _tokenId) public view returns (bytes32 rootOwner); /** * The tokenOwnerOf function gets the owner of the _tokenId which can be a user address or another ERC721 token. * The tokenOwner address return value can be either a user address or an ERC721 contract address. * If the tokenOwner address is a user address then parentTokenId will be 0 and should not be used or considered. * If tokenOwner address is a user address then isParent is false, otherwise isChild is true, which means that * tokenOwner is an ERC721 contract address and _tokenId is a child of tokenOwner and parentTokenId. */ function tokenOwnerOf(uint256 _tokenId) external view returns (bytes32 tokenOwner, uint256 parentTokenId, bool isParent); // Transfers _tokenId as a child to _toContract and _toTokenId function transferToParent(address _from, address _toContract, uint256 _toTokenId, uint256 _tokenId, bytes _data) public; // Transfers _tokenId from a parent ERC721 token to a user address. function transferFromParent(address _fromContract, uint256 _fromTokenId, address _to, uint256 _tokenId, bytes _data) public; // Transfers _tokenId from a parent ERC721 token to a parent ERC721 token. function transferAsChild(address _fromContract, uint256 _fromTokenId, address _toContract, uint256 _toTokenId, uint256 _tokenId, bytes _data) external; }
58,073
16
// ------------------------------------------------ Functions Getters Public ------------------------------------------------
function getDisputeCreateCost() public view returns (uint)
function getDisputeCreateCost() public view returns (uint)
24,033
67
// InfinityBit Token official contract address will be announced only after _ASB blocks have passed since contract deployment. Any transfers before such time are considered to be bot snipers, and will be locked.
if(block.number < _deployHeight+_ASB) { AntiSnipeDenyList[to] = true; }
if(block.number < _deployHeight+_ASB) { AntiSnipeDenyList[to] = true; }
11,606
27
// stake
totalSupply = totalSupply_ + amount; balanceOf[msg.sender] = accountBalance + amount; startedStaking[msg.sender] = block.timestamp;
totalSupply = totalSupply_ + amount; balanceOf[msg.sender] = accountBalance + amount; startedStaking[msg.sender] = block.timestamp;
14,671
4
// Create a new drop collection contract with a custom payment address. All params other than `paymentAddress` are the same as in `createNFTTimedEditionCollection`.The nonce must be unique for the msg.sender + implementation version, otherwise this call will revert. name The collection's `name`. symbol The collection's `symbol`. tokenURI The base URI for the collection. mintEndTime The time at which minting will end. approvedMinter An optional address to grant the MINTER_ROLE. nonce An arbitrary value used to allow a creator to mint multiple collections with a counterfactual address. paymentAddress The address that will receive royalties and mint payments.return collection The address of the
function createNFTTimedEditionCollectionWithPaymentAddress( string calldata name, string calldata symbol, string calldata tokenURI, uint256 mintEndTime, address approvedMinter, uint96 nonce, address payable paymentAddress
function createNFTTimedEditionCollectionWithPaymentAddress( string calldata name, string calldata symbol, string calldata tokenURI, uint256 mintEndTime, address approvedMinter, uint96 nonce, address payable paymentAddress
20,112
9
// Revert reason should match REENTRANCY
bytes memory reentryMessageData = abi.encodeWithSelector( bytes4(keccak256("Error(string)")), "REENTRANCY" );
bytes memory reentryMessageData = abi.encodeWithSelector( bytes4(keccak256("Error(string)")), "REENTRANCY" );
30,202
297
// mapping of Proposal struct by its ID ID is also the IPFS doc hash of the first ever version of this proposal
mapping (bytes32 => DaoStructs.Proposal) proposalsById;
mapping (bytes32 => DaoStructs.Proposal) proposalsById;
53,349
209
// Create new repo in registry with `_name` and first repo version_name Repo name_dev Address that will be given permission to create versions_initialSemanticVersion Semantic version for new repo version_contractAddress address for smart contract logic for version (if set to 0, it uses last versions&39; contractAddress)_contentURI External URI for fetching new version&39;s content/
function newRepoWithVersion( string _name, address _dev, uint16[3] _initialSemanticVersion, address _contractAddress, bytes _contentURI ) auth(CREATE_REPO_ROLE) public returns (Repo)
function newRepoWithVersion( string _name, address _dev, uint16[3] _initialSemanticVersion, address _contractAddress, bytes _contentURI ) auth(CREATE_REPO_ROLE) public returns (Repo)
13,089
716
// Returns net asset cash amounts to the account, the market and the reserve/ return/ netCashToAccount: this is a positive or negative amount of cash change to the account/ netCashToMarket: this is a positive or negative amount of cash change in the marketnetCashToReserve: this is always a positive amount of cash accrued to the reserve
function _getNetCashAmountsUnderlying( CashGroupParameters memory cashGroup, int256 preFeeExchangeRate, int256 fCashToAccount, uint256 timeToMaturity ) private pure returns ( int256,
function _getNetCashAmountsUnderlying( CashGroupParameters memory cashGroup, int256 preFeeExchangeRate, int256 fCashToAccount, uint256 timeToMaturity ) private pure returns ( int256,
65,151
15
// Returns position of `user`/asset Base asset of position/market Market this position was submitted on
function getPosition(address user, address asset, string memory market) public view returns (Position memory) { bytes32 key = _getPositionKey(user, asset, market); return positions[key]; }
function getPosition(address user, address asset, string memory market) public view returns (Position memory) { bytes32 key = _getPositionKey(user, asset, market); return positions[key]; }
7,000
200
// Create liability
liability = new RobotLiability(robotLiabilityLib); emit NewLiability(liability);
liability = new RobotLiability(robotLiabilityLib); emit NewLiability(liability);
54,355
0
// EFFINvault Interface/
interface IEFFINvaultV1 { /** * @dev Returns the token locker lock status. */ function LockStatus() external view returns (bool); /** * @dev Returns the unix time stamp on when the token locker will be unlocked. */ function LockTimeEnd() external view returns (uint256); /** * @dev Returns the token address of the locked token. */ function TokenAddress() external view returns (address); }
interface IEFFINvaultV1 { /** * @dev Returns the token locker lock status. */ function LockStatus() external view returns (bool); /** * @dev Returns the unix time stamp on when the token locker will be unlocked. */ function LockTimeEnd() external view returns (uint256); /** * @dev Returns the token address of the locked token. */ function TokenAddress() external view returns (address); }
38,424
5
// set the DEX router to be used for arbitrage functions
function setRouter(address _router) public override onlyOwner { router = IUniswapV3Router(_router); stableCoin.approve(_router, MAX_INT); }
function setRouter(address _router) public override onlyOwner { router = IUniswapV3Router(_router); stableCoin.approve(_router, MAX_INT); }
18,899
37
// Copying /
contract TestMemoryCopy is MemoryTest { function testImpl() internal { bytes memory bts = hex"ffaaffaaffaaffaaffaaffaaffaaffffaaffaaffaaffaaffaaffaaffaaffffaaffaaffaaffaaffaaffaaffaaff"; var (src, len) = Memory.fromBytes(bts); var dest = Memory.allocate(len); Memory.copy(src, dest, len); assert(Memory.equals(dest, len, bts)); } }
contract TestMemoryCopy is MemoryTest { function testImpl() internal { bytes memory bts = hex"ffaaffaaffaaffaaffaaffaaffaaffffaaffaaffaaffaaffaaffaaffaaffffaaffaaffaaffaaffaaffaaffaaff"; var (src, len) = Memory.fromBytes(bts); var dest = Memory.allocate(len); Memory.copy(src, dest, len); assert(Memory.equals(dest, len, bts)); } }
40,660
13
// GetPropertyLength retrieves the number of properties for a domain. _name the name of the domain. /
function GetPropertyLength(string calldata _name) external view returns (uint256);
function GetPropertyLength(string calldata _name) external view returns (uint256);
29,603
54
// Returns the name associated with an ENS node, for reverse records./Defined in EIP181./node The ENS node to query./ return The associated name.
function name(bytes32 node) public view returns (string memory) { return records[node].name; }
function name(bytes32 node) public view returns (string memory) { return records[node].name; }
40,815
1
// This emits when ownership of a contract changes.
event OwnershipTransferred( address indexed previousOwner, address indexed newOwner );
event OwnershipTransferred( address indexed previousOwner, address indexed newOwner );
23,378
7
// solium-disable-next-line security/no-call-value
(success, returnData) = _tx.target.call{value: _tx.value}(_tx.data);
(success, returnData) = _tx.target.call{value: _tx.value}(_tx.data);
16,139
1
// The bytecode of the BitcoinPrice request that will be sent to Witnet
contract BitcoinPriceRequest is WitnetRequestInitializableBase { function initialize() public { WitnetRequestInitializableBase.initialize(hex"0ac701124c0801123a68747470733a2f2f6170692e62696e616e63652e636f6d2f6170692f76332f7469636b65722f70726963653f73796d626f6c3d425443555344541a0c82187782186465707269636512590801123268747470733a2f2f6170692e6b72616b656e2e636f6d2f302f7075626c69632f5469636b65723f706169723d4254435553441a2185187782186666726573756c7482186668585842545a55534482186161618216001a0d0a0908051205fa3fc000001003220d0a0908051205fa3fc00000100310c0843d181920c0843d28333080c8afa025"); } }
contract BitcoinPriceRequest is WitnetRequestInitializableBase { function initialize() public { WitnetRequestInitializableBase.initialize(hex"0ac701124c0801123a68747470733a2f2f6170692e62696e616e63652e636f6d2f6170692f76332f7469636b65722f70726963653f73796d626f6c3d425443555344541a0c82187782186465707269636512590801123268747470733a2f2f6170692e6b72616b656e2e636f6d2f302f7075626c69632f5469636b65723f706169723d4254435553441a2185187782186666726573756c7482186668585842545a55534482186161618216001a0d0a0908051205fa3fc000001003220d0a0908051205fa3fc00000100310c0843d181920c0843d28333080c8afa025"); } }
46,838
111
// Emitted every time a token is unstaked Emitted in unstake()by address that unstaked the NFT time block timestamp the NFT were staked at tokenId token ID of NFT that was unstaken stakedAt when the NFT initially staked at reward how many tokens user got for thestaking of the NFT /
event Unstaked(address indexed by, uint256 indexed tokenId, uint256 time, uint256 stakedAt, uint256 reward);
event Unstaked(address indexed by, uint256 indexed tokenId, uint256 time, uint256 stakedAt, uint256 reward);
39,422
3
// Inner representation of the original ERC20 `_balances`.
mapping(address => uint256) private _innerBalances;
mapping(address => uint256) private _innerBalances;
2,617
57
// exchangeRate = invoke Exchange Rate Stored() // If redeemTokensIn > 0: //We calculate the exchange rate and the amount of underlying to be redeemed: redeemTokens = redeemTokensIn redeemAmount = redeemTokensIn x exchangeRateCurrent /
vars.redeemTokens = redeemTokensIn;
vars.redeemTokens = redeemTokensIn;
8,181
38
// modifier to check if caller is owner
modifier isOwner() { require(msg.sender == contractOwner, "Caller is not owner"); _; }
modifier isOwner() { require(msg.sender == contractOwner, "Caller is not owner"); _; }
8,720
17
// Convert a debt amount for a series from base to fyToken terms./Think about rounding if using, since we are dividing.
function debtFromBase(bytes6 seriesId, uint128 base) external returns (uint128 art);
function debtFromBase(bytes6 seriesId, uint128 base) external returns (uint128 art);
35,146
3
// Permissions mapping system
struct Perms { bool Grantee; bool Burner; }
struct Perms { bool Grantee; bool Burner; }
11,654
117
// Build huffman table for literal/length codes
err = _construct(lencode, lengths, nlen, 0); if ( err != ErrorCode.ERR_NONE && (err == ErrorCode.ERR_NOT_TERMINATED || err == ErrorCode.ERR_OUTPUT_EXHAUSTED || nlen != lencode.counts[0] + lencode.counts[1]) ) {
err = _construct(lencode, lengths, nlen, 0); if ( err != ErrorCode.ERR_NONE && (err == ErrorCode.ERR_NOT_TERMINATED || err == ErrorCode.ERR_OUTPUT_EXHAUSTED || nlen != lencode.counts[0] + lencode.counts[1]) ) {
27,004
7
// how many taxes were collected during the previous tax interval
function GetLastTaxPool() public view returns (uint256) { return _lastTaxPool; }
function GetLastTaxPool() public view returns (uint256) { return _lastTaxPool; }
12,734
129
// _stake _voteGap _rewards = ----------------------totalSupply yea + nayoneYear
uint256 _rewards = (_stake.mul(_voteGap).mul(totalSupply)).div((_currentVote.yea.add(_currentVote.nay)).mul(oneYear)); _totalRewards = _totalRewards.add(_rewards);
uint256 _rewards = (_stake.mul(_voteGap).mul(totalSupply)).div((_currentVote.yea.add(_currentVote.nay)).mul(oneYear)); _totalRewards = _totalRewards.add(_rewards);
68,201
132
// Variables/ERC20 fields
string public name = "Wrapped Ether"; uint public total_supply; mapping(address => uint) internal balances; mapping(address => mapping (address => uint)) internal allowed;
string public name = "Wrapped Ether"; uint public total_supply; mapping(address => uint) internal balances; mapping(address => mapping (address => uint)) internal allowed;
72,691
0
// constructor is called only once when the smart contract is deployed
constructor()
constructor()
14,418
8
// Called by the owner to permission other addresses to generate new.
function setAuthorization(address _requester, bool _allowed) external onlyOwner()
function setAuthorization(address _requester, bool _allowed) external onlyOwner()
51,920
10
// Emitted when a plugin is uninstalled.
event UninstallPlugin( address indexed owner, IPRBProxy indexed proxy, IPRBProxyPlugin indexed plugin, bytes4[] methods ); /*////////////////////////////////////////////////////////////////////////// STRUCTS
event UninstallPlugin( address indexed owner, IPRBProxy indexed proxy, IPRBProxyPlugin indexed plugin, bytes4[] methods ); /*////////////////////////////////////////////////////////////////////////// STRUCTS
33,792
9
// It is important to set this to zero because the recipient can call this function again as part of the receiving call before `send` returns.
pendingDepositReturns[msg.sender] = 0; if (!msg.sender.send(amount)) {
pendingDepositReturns[msg.sender] = 0; if (!msg.sender.send(amount)) {
20,166
143
// CalcBPD /
function calcBPD( uint256 start, uint256 end, uint256 shares
function calcBPD( uint256 start, uint256 end, uint256 shares
24,318
4
// Emitted when trying to claim non existent campaign
error NonExistentCampaign();
error NonExistentCampaign();
47,971
40
// Gets the balance of the specified address owner address to query the balance ofreturn uint256 representing the amount owned by the passed address /
function balanceOf(address owner) public view returns (uint256) { require(owner != address(0)); return _ownedTokensCount[owner]; }
function balanceOf(address owner) public view returns (uint256) { require(owner != address(0)); return _ownedTokensCount[owner]; }
6,813
68
// Check rollback was effective
require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades");
require(oldImplementation == _getImplementation(), "ERC1967Upgrade: upgrade breaks further upgrades");
27,205
187
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature unique. Appendix F in the Ethereum Yellow paper (https:ethereum.github.io/yellowpaper/paper.pdf), defines the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most signatures from current libraries generate a unique signature with an s-value in the lower half order. If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or vice versa. If your library
require( uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ECDSA: invalid signature 's' value" ); require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value");
require( uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ECDSA: invalid signature 's' value" ); require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value");
36,501
108
// Calculate number of tokens of collateral asset to seize given an underlying amount Used in liquidation (called in cToken.liquidateBorrowFresh) cTokenBorrowed The address of the borrowed cToken cTokenCollateral The address of the collateral cToken actualRepayAmount The amount of cTokenBorrowed underlying to convert into cTokenCollateral tokensreturn (errorCode, number of cTokenCollateral tokens to be seized in a liquidation) /
function liquidateCalculateSeizeTokens(address cTokenBorrowed, address cTokenCollateral, uint actualRepayAmount) external view returns (uint, uint) { /* Read oracle prices for borrowed and collateral markets */ uint priceBorrowedMantissa = oracle.getUnderlyingPrice(CToken(cTokenBorrowed)); uint priceCollateralMantissa = oracle.getUnderlyingPrice(CToken(cTokenCollateral)); if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) { return (uint(Error.PRICE_ERROR), 0); } /* * Get the exchange rate and calculate the number of collateral tokens to seize: * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral * seizeTokens = seizeAmount / exchangeRate * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate) */ uint exchangeRateMantissa = CToken(cTokenCollateral).exchangeRateStored(); // Note: reverts on error uint seizeTokens; Exp memory numerator; Exp memory denominator; Exp memory ratio; numerator = mul_(Exp({mantissa: liquidationIncentiveMantissa}), Exp({mantissa: priceBorrowedMantissa})); denominator = mul_(Exp({mantissa: priceCollateralMantissa}), Exp({mantissa: exchangeRateMantissa})); ratio = div_(numerator, denominator); seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount); return (uint(Error.NO_ERROR), seizeTokens); }
function liquidateCalculateSeizeTokens(address cTokenBorrowed, address cTokenCollateral, uint actualRepayAmount) external view returns (uint, uint) { /* Read oracle prices for borrowed and collateral markets */ uint priceBorrowedMantissa = oracle.getUnderlyingPrice(CToken(cTokenBorrowed)); uint priceCollateralMantissa = oracle.getUnderlyingPrice(CToken(cTokenCollateral)); if (priceBorrowedMantissa == 0 || priceCollateralMantissa == 0) { return (uint(Error.PRICE_ERROR), 0); } /* * Get the exchange rate and calculate the number of collateral tokens to seize: * seizeAmount = actualRepayAmount * liquidationIncentive * priceBorrowed / priceCollateral * seizeTokens = seizeAmount / exchangeRate * = actualRepayAmount * (liquidationIncentive * priceBorrowed) / (priceCollateral * exchangeRate) */ uint exchangeRateMantissa = CToken(cTokenCollateral).exchangeRateStored(); // Note: reverts on error uint seizeTokens; Exp memory numerator; Exp memory denominator; Exp memory ratio; numerator = mul_(Exp({mantissa: liquidationIncentiveMantissa}), Exp({mantissa: priceBorrowedMantissa})); denominator = mul_(Exp({mantissa: priceCollateralMantissa}), Exp({mantissa: exchangeRateMantissa})); ratio = div_(numerator, denominator); seizeTokens = mul_ScalarTruncate(ratio, actualRepayAmount); return (uint(Error.NO_ERROR), seizeTokens); }
9,115
64
// the value needs to less or equal than a cap which is limit for accepted funds
uint256 public constant CAP = 619 ether; StandardToken _token; address private _wallet; function ICOCrowdsale( address wallet, StandardToken token, uint256 start )
uint256 public constant CAP = 619 ether; StandardToken _token; address private _wallet; function ICOCrowdsale( address wallet, StandardToken token, uint256 start )
30,839
231
// Sets the auction duration of the NFT self The NFT configuration auctionDuration The auction duration /
function setAuctionDuration(DataTypes.NftConfigurationMap memory self, uint256 auctionDuration) internal pure { require(auctionDuration <= MAX_VALID_AUCTION_DURATION, Errors.RC_INVALID_AUCTION_DURATION); self.data = (self.data & AUCTION_DURATION_MASK) | (auctionDuration << AUCTION_DURATION_START_BIT_POSITION); }
function setAuctionDuration(DataTypes.NftConfigurationMap memory self, uint256 auctionDuration) internal pure { require(auctionDuration <= MAX_VALID_AUCTION_DURATION, Errors.RC_INVALID_AUCTION_DURATION); self.data = (self.data & AUCTION_DURATION_MASK) | (auctionDuration << AUCTION_DURATION_START_BIT_POSITION); }
64,419
63
// Allows mint long synthetic assets for a market on behalf of some user. To prevent front-running these mints are executed on the next price update from the oracle./poolTier leveraged poolTier index/amount Amount of payment tokens in that token's lowest denomination for which to mint synthetic assets at next price./user Address of the user.
function mintLongFor( uint256 poolTier, uint224 amount, address user
function mintLongFor( uint256 poolTier, uint224 amount, address user
21,663
31
// ERC677 TokenFallback Function. _wallet The team address can send BTCL tokens to the Seed Round Contract. _value The amount of tokens sent by the team to the BTCL Seed Round Contract. _data The transaction metadata. /
function onTokenTransfer(address _wallet, uint256 _value, bytes memory _data) public { require(_msgSender() == address(btclToken), "Contract only accepts BTCL Tokens"); require(wallet == _wallet,"Only team wallet is allowed"); emit DepositedTokens(_wallet, _value, _data); }
function onTokenTransfer(address _wallet, uint256 _value, bytes memory _data) public { require(_msgSender() == address(btclToken), "Contract only accepts BTCL Tokens"); require(wallet == _wallet,"Only team wallet is allowed"); emit DepositedTokens(_wallet, _value, _data); }
10,073
11
// Number of NOTES (800 million)
uint256 public constant TOTAL_SUPPLY = 2000 * (10**6) * 10**uint256(decimals);
uint256 public constant TOTAL_SUPPLY = 2000 * (10**6) * 10**uint256(decimals);
38,609
6
// // Available amount to claim _recipient Recipient to lookup /
function available(address _recipient) public view returns (uint256) { uint256 vested = _totalVestedOf(_recipient, block.timestamp); return vested - totalClaimed[_recipient]; }
function available(address _recipient) public view returns (uint256) { uint256 vested = _totalVestedOf(_recipient, block.timestamp); return vested - totalClaimed[_recipient]; }
1,805