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
|
|---|---|---|---|---|
4
|
// Dequeues a deposit subtree for submission to the rollup /
|
function dequeueToSubmit()
|
function dequeueToSubmit()
| 21,479
|
967
|
// Packs an uint value into a "floating point" storage slot. Used for storinglastClaimIntegralSupply values in balance storage. For these values, we don't needto maintain exact precision but we don't want to be limited by storage size overflows. A floating point value is defined by the 48 most significant bits and an 8 bit numberof bit shifts required to restore its precision. The unpacked value will always be lessthan the packed value with a maximum absolute loss of precision of (2bitShift) - 1. /
|
library FloatingPoint56 {
function packTo56Bits(uint256 value) internal pure returns (uint56) {
uint256 bitShift;
// If the value is over the uint48 max value then we will shift it down
// given the index of the most significant bit. We store this bit shift
// in the least significant byte of the 56 bit slot available.
if (value > type(uint48).max) bitShift = (Bitmap.getMSB(value) - 47);
uint256 shiftedValue = value >> bitShift;
return uint56((shiftedValue << 8) | bitShift);
}
function unpackFrom56Bits(uint256 value) internal pure returns (uint256) {
// The least significant 8 bits will be the amount to bit shift
uint256 bitShift = uint256(uint8(value));
return ((value >> 8) << bitShift);
}
}
|
library FloatingPoint56 {
function packTo56Bits(uint256 value) internal pure returns (uint56) {
uint256 bitShift;
// If the value is over the uint48 max value then we will shift it down
// given the index of the most significant bit. We store this bit shift
// in the least significant byte of the 56 bit slot available.
if (value > type(uint48).max) bitShift = (Bitmap.getMSB(value) - 47);
uint256 shiftedValue = value >> bitShift;
return uint56((shiftedValue << 8) | bitShift);
}
function unpackFrom56Bits(uint256 value) internal pure returns (uint256) {
// The least significant 8 bits will be the amount to bit shift
uint256 bitShift = uint256(uint8(value));
return ((value >> 8) << bitShift);
}
}
| 6,398
|
5
|
// Need to transfer before minting or ERC777s could reenter.
|
asset.safeTransferFrom(msg.sender, address(this), assets);
_mint(receiver, shares);
emit Deposit(msg.sender, receiver, assets, shares);
afterDeposit(assets, shares);
|
asset.safeTransferFrom(msg.sender, address(this), assets);
_mint(receiver, shares);
emit Deposit(msg.sender, receiver, assets, shares);
afterDeposit(assets, shares);
| 24,482
|
149
|
// Amount of wei raised
|
uint256 private _weiRaised;
|
uint256 private _weiRaised;
| 76,080
|
47
|
// Gets the current votes balance for `account`./account The address to get votes balance./ return The number of current votes for `account`.
|
function getCurrentVotes(address account) external view returns (uint256) {
unchecked {uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;}
}
|
function getCurrentVotes(address account) external view returns (uint256) {
unchecked {uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;}
}
| 40,262
|
120
|
// Not block locked by setts
|
if (_mintIbbtc && (_amounts[1] > 0 || _amounts[2] > 0)) {
require(
RENCRV_VAULT.blockLock(address(this)) < block.number,
"blockLocked"
);
}
|
if (_mintIbbtc && (_amounts[1] > 0 || _amounts[2] > 0)) {
require(
RENCRV_VAULT.blockLock(address(this)) < block.number,
"blockLocked"
);
}
| 49,627
|
37
|
// if silo was able to handle solvency calculations, then we can handle quoteAmount without safe math
|
quoteAmount += _swapForQuote(_assets[i], _receivedCollaterals[i]);
|
quoteAmount += _swapForQuote(_assets[i], _receivedCollaterals[i]);
| 11,016
|
83
|
// vesting token
|
IERC20 private token;
|
IERC20 private token;
| 67,784
|
259
|
// _Available since v3.1._ /
|
interface IERC1155Receiver is IERC165 {
/**
@dev Handles the receipt of a single ERC1155 token type. This function is
called at the end of a `safeTransferFrom` after the balance has been updated.
To accept the transfer, this must return
`bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
(i.e. 0xf23a6e61, or its own function selector).
@param operator The address which initiated the transfer (i.e. msg.sender)
@param from The address which previously owned the token
@param id The ID of the token being transferred
@param value The amount of tokens being transferred
@param data Additional data with no specified format
@return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
/**
@dev Handles the receipt of a multiple ERC1155 token types. This function
is called at the end of a `safeBatchTransferFrom` after the balances have
been updated. To accept the transfer(s), this must return
`bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
(i.e. 0xbc197c81, or its own function selector).
@param operator The address which initiated the batch transfer (i.e. msg.sender)
@param from The address which previously owned the token
@param ids An array containing ids of each token being transferred (order and length must match values array)
@param values An array containing amounts of each token being transferred (order and length must match ids array)
@param data Additional data with no specified format
@return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}
|
interface IERC1155Receiver is IERC165 {
/**
@dev Handles the receipt of a single ERC1155 token type. This function is
called at the end of a `safeTransferFrom` after the balance has been updated.
To accept the transfer, this must return
`bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
(i.e. 0xf23a6e61, or its own function selector).
@param operator The address which initiated the transfer (i.e. msg.sender)
@param from The address which previously owned the token
@param id The ID of the token being transferred
@param value The amount of tokens being transferred
@param data Additional data with no specified format
@return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
*/
function onERC1155Received(
address operator,
address from,
uint256 id,
uint256 value,
bytes calldata data
) external returns (bytes4);
/**
@dev Handles the receipt of a multiple ERC1155 token types. This function
is called at the end of a `safeBatchTransferFrom` after the balances have
been updated. To accept the transfer(s), this must return
`bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
(i.e. 0xbc197c81, or its own function selector).
@param operator The address which initiated the batch transfer (i.e. msg.sender)
@param from The address which previously owned the token
@param ids An array containing ids of each token being transferred (order and length must match values array)
@param values An array containing amounts of each token being transferred (order and length must match ids array)
@param data Additional data with no specified format
@return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
*/
function onERC1155BatchReceived(
address operator,
address from,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external returns (bytes4);
}
| 1,439
|
24
|
// Override for extensions that require an internal state to check for validity (current user contributions,etc.) beneficiary Address receiving the tokens weiAmount Value in wei involved in the purchase /
|
function _updatePurchasingState(address beneficiary, uint256 weiAmount)
internal
|
function _updatePurchasingState(address beneficiary, uint256 weiAmount)
internal
| 16,936
|
147
|
// Safely mints `quantity` tokens and transfers them to `to`. Requirements: - If `to` refers to a smart contract, it must implement
|
* {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
uint256 startTokenId = _currentIndex;
if (to == address(0)) revert MintToZeroAddress();
if (quantity == 0) revert MintZeroQuantity();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are incredibly unrealistic.
// balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1
// updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1
unchecked {
_addressData[to].balance += uint64(quantity);
_addressData[to].numberMinted += uint64(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
uint256 end = updatedIndex + quantity;
if (to.isContract()) {
do {
emit Transfer(address(0), to, updatedIndex);
if (!_checkContractOnERC721Received(address(0), to, updatedIndex++, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
} while (updatedIndex != end);
// Reentrancy protection
if (_currentIndex != startTokenId) revert();
} else {
do {
emit Transfer(address(0), to, updatedIndex++);
} while (updatedIndex != end);
}
_currentIndex = updatedIndex;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
|
* {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
uint256 startTokenId = _currentIndex;
if (to == address(0)) revert MintToZeroAddress();
if (quantity == 0) revert MintZeroQuantity();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are incredibly unrealistic.
// balance or numberMinted overflow if current value of either + quantity > 1.8e19 (2**64) - 1
// updatedIndex overflows if _currentIndex + quantity > 1.2e77 (2**256) - 1
unchecked {
_addressData[to].balance += uint64(quantity);
_addressData[to].numberMinted += uint64(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
uint256 end = updatedIndex + quantity;
if (to.isContract()) {
do {
emit Transfer(address(0), to, updatedIndex);
if (!_checkContractOnERC721Received(address(0), to, updatedIndex++, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
} while (updatedIndex != end);
// Reentrancy protection
if (_currentIndex != startTokenId) revert();
} else {
do {
emit Transfer(address(0), to, updatedIndex++);
} while (updatedIndex != end);
}
_currentIndex = updatedIndex;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
| 8,253
|
2
|
// Revert with an error when a fulfillment is provided that does not declare at least one offer component and at least one consideration component. /
|
error OfferAndConsiderationRequiredOnFulfillment();
|
error OfferAndConsiderationRequiredOnFulfillment();
| 19,912
|
3
|
// Methods to mock data on the chain
|
function storeData(uint256 data)
public
|
function storeData(uint256 data)
public
| 31,211
|
60
|
// Payout Function 1 --> Distribute Shares to Affiliates and Payees (DSAP) In addition to including this, we also modified the PaymentSplitter release() function to make it minAdmin2 (to ensure that affiliate fundswill always be paid out prior to defined shares).
|
function distributeSharesAffilsAndPayees() external minAdmin2 noReentrant {
// A. Payout affiliates:
for (uint i = 0; i < affiliateDistro.length; i++) {
// The ref name -- eg. jim, etc.
string memory affiliateRef = affiliateDistro[i];
// The wallet addr to be paid for this affiliate:
address DSAP_receiver_wallet = affiliateAccounts[affiliateRef].affiliateReceiver;
// The fee due per sale for this affiliate:
uint DSAP_fee = affiliateAccounts[affiliateRef].affiliateFee;
// The # of mints they are credited with:
uint DSAP_mintedNFTs = affiliateAccounts[affiliateRef].affiliateUnpaidSales;
// Payout calc:
uint DSAP_payout = DSAP_fee * DSAP_mintedNFTs;
if ( DSAP_payout == 0 ) { continue; }
// Require that the contract balance is enough to send out ETH:
require(address(this).balance >= DSAP_payout, "Error: Insufficient balance");
// Send payout to the affiliate:
(bool sent, bytes memory data) = payable(DSAP_receiver_wallet).call{value: DSAP_payout}("");
require(sent, "Error: Failed to send ETH to receiver");
// Update total amt earned for this person:
affiliateAccounts[affiliateRef].affiliateAmountPaid += DSAP_payout;
// Set their affiliateUnpaidSales back to 0:
affiliateAccounts[affiliateRef].affiliateUnpaidSales = 0;
}
// B. Then pay defined shareholders:
for (uint i = 0; i < _distro.length; i++) {
release(payable(_distro[i]));
}
}
|
function distributeSharesAffilsAndPayees() external minAdmin2 noReentrant {
// A. Payout affiliates:
for (uint i = 0; i < affiliateDistro.length; i++) {
// The ref name -- eg. jim, etc.
string memory affiliateRef = affiliateDistro[i];
// The wallet addr to be paid for this affiliate:
address DSAP_receiver_wallet = affiliateAccounts[affiliateRef].affiliateReceiver;
// The fee due per sale for this affiliate:
uint DSAP_fee = affiliateAccounts[affiliateRef].affiliateFee;
// The # of mints they are credited with:
uint DSAP_mintedNFTs = affiliateAccounts[affiliateRef].affiliateUnpaidSales;
// Payout calc:
uint DSAP_payout = DSAP_fee * DSAP_mintedNFTs;
if ( DSAP_payout == 0 ) { continue; }
// Require that the contract balance is enough to send out ETH:
require(address(this).balance >= DSAP_payout, "Error: Insufficient balance");
// Send payout to the affiliate:
(bool sent, bytes memory data) = payable(DSAP_receiver_wallet).call{value: DSAP_payout}("");
require(sent, "Error: Failed to send ETH to receiver");
// Update total amt earned for this person:
affiliateAccounts[affiliateRef].affiliateAmountPaid += DSAP_payout;
// Set their affiliateUnpaidSales back to 0:
affiliateAccounts[affiliateRef].affiliateUnpaidSales = 0;
}
// B. Then pay defined shareholders:
for (uint i = 0; i < _distro.length; i++) {
release(payable(_distro[i]));
}
}
| 30,774
|
16
|
// Aave v2 Helpers
|
interface AaveV2Interface {
function deposit(address _asset, uint256 _amount, address _onBehalfOf, uint16 _referralCode) external;
function withdraw(address _asset, uint256 _amount, address _to) external;
function borrow(
address _asset,
uint256 _amount,
uint256 _interestRateMode,
uint16 _referralCode,
address _onBehalfOf
) external;
function repay(address _asset, uint256 _amount, uint256 _rateMode, address _onBehalfOf) external;
function setUserUseReserveAsCollateral(address _asset, bool _useAsCollateral) external;
}
|
interface AaveV2Interface {
function deposit(address _asset, uint256 _amount, address _onBehalfOf, uint16 _referralCode) external;
function withdraw(address _asset, uint256 _amount, address _to) external;
function borrow(
address _asset,
uint256 _amount,
uint256 _interestRateMode,
uint16 _referralCode,
address _onBehalfOf
) external;
function repay(address _asset, uint256 _amount, uint256 _rateMode, address _onBehalfOf) external;
function setUserUseReserveAsCollateral(address _asset, bool _useAsCollateral) external;
}
| 51,614
|
22
|
// view function doesn't write to blockchain.
|
function getLockPeriods() external view returns(uint[] memory) {
return lockPeriods;
}
|
function getLockPeriods() external view returns(uint[] memory) {
return lockPeriods;
}
| 17,693
|
1,026
|
// https:etherscan.io/address/0x5b1b5fEa1b99D83aD479dF0C222F0492385381dD
|
LegacyTokenState public constant tokenstatesynthetix_i = LegacyTokenState(0x5b1b5fEa1b99D83aD479dF0C222F0492385381dD);
|
LegacyTokenState public constant tokenstatesynthetix_i = LegacyTokenState(0x5b1b5fEa1b99D83aD479dF0C222F0492385381dD);
| 3,981
|
1,064
|
// Ensure the ExchangeRates contract has the feed for sADA;
|
exchangerates_i.addAggregator("sADA", 0xAE48c91dF1fE419994FFDa27da09D5aC69c30f55);
|
exchangerates_i.addAggregator("sADA", 0xAE48c91dF1fE419994FFDa27da09D5aC69c30f55);
| 34,511
|
129
|
// Se nem from nem to são o Banco, eh transferencia normal
|
require(registry.isValidatedClient(from), "O endereço não pertence a um cliente ou não está validada");
require(registry.isValidatedSupplier(to), "A conta do endereço não pertence a um fornecedor ou não está validada");
_transfer(msg.sender, to, value);
emit BNDESTokenTransfer(registry.getCNPJ(from), registry.getIdLegalFinancialAgreement(from),
registry.getCNPJ(to), value);
|
require(registry.isValidatedClient(from), "O endereço não pertence a um cliente ou não está validada");
require(registry.isValidatedSupplier(to), "A conta do endereço não pertence a um fornecedor ou não está validada");
_transfer(msg.sender, to, value);
emit BNDESTokenTransfer(registry.getCNPJ(from), registry.getIdLegalFinancialAgreement(from),
registry.getCNPJ(to), value);
| 40,105
|
23
|
// Allows to update the number of required confirmations by Safe owners./This can only be done via a Safe transaction./Changes the threshold of the Safe to `_threshold`./_threshold New threshold.
|
function changeThreshold(uint256 _threshold)
public
authorized
|
function changeThreshold(uint256 _threshold)
public
authorized
| 21,948
|
75
|
// UserContract This contracts creates for easy integration to the Tellor System by allowing smart contracts to read data off Tellor/
|
contract UsingTellor{
ITellor tellor;
/*Constructor*/
/**
* @dev the constructor sets the storage address and owner
* @param _tellor is the TellorMaster address
*/
constructor(address payable _tellor) public {
tellor = ITellor(_tellor);
}
/**
* @dev Retreive value from oracle based on requestId/timestamp
* @param _requestId being requested
* @param _timestamp to retreive data/value from
* @return uint value for requestId/timestamp submitted
*/
function retrieveData(uint256 _requestId, uint256 _timestamp) public view returns(uint256){
return tellor.retrieveData(_requestId,_timestamp);
}
/**
* @dev Gets the 5 miners who mined the value for the specified requestId/_timestamp
* @param _requestId to looku p
* @param _timestamp is the timestamp to look up miners for
* @return bool true if requestId/timestamp is under dispute
*/
function isInDispute(uint256 _requestId, uint256 _timestamp) public view returns(bool){
return tellor.isInDispute(_requestId, _timestamp);
}
/**
* @dev Counts the number of values that have been submited for the request
* @param _requestId the requestId to look up
* @return uint count of the number of values received for the requestId
*/
function getNewValueCountbyRequestId(uint256 _requestId) public view returns(uint) {
return tellor.getNewValueCountbyRequestId(_requestId);
}
/**
* @dev Gets the timestamp for the value based on their index
* @param _requestId is the requestId to look up
* @param _index is the value index to look up
* @return uint timestamp
*/
function getTimestampbyRequestIDandIndex(uint256 _requestId, uint256 _index) public view returns(uint256) {
return tellor.getTimestampbyRequestIDandIndex( _requestId,_index);
}
/**
* @dev Allows the user to get the latest value for the requestId specified
* @param _requestId is the requestId to look up the value for
* @return ifRetrieve bool true if it is able to retreive a value, the value, and the value's timestamp
* @return value the value retrieved
* @return _timestampRetrieved the value's timestamp
*/
function getCurrentValue(uint256 _requestId) public view returns (bool ifRetrieve, uint256 value, uint256 _timestampRetrieved) {
uint256 _count = tellor.getNewValueCountbyRequestId(_requestId);
uint _time = tellor.getTimestampbyRequestIDandIndex(_requestId, _count - 1);
uint _value = tellor.retrieveData(_requestId, _time);
if(_value > 0) return (true, _value, _time);
return (false, 0 , _time);
}
function getIndexForDataBefore(uint _requestId, uint256 _timestamp) public view returns (bool found, uint256 index){
uint256 _count = tellor.getNewValueCountbyRequestId(_requestId);
if (_count > 0) {
uint middle;
uint start = 0;
uint end = _count - 1;
uint _time;
//Checking Boundaries to short-circuit the algorithm
_time = tellor.getTimestampbyRequestIDandIndex(_requestId, start);
if(_time >= _timestamp) return (false, 0);
_time = tellor.getTimestampbyRequestIDandIndex(_requestId, end);
if(_time < _timestamp) return (true, end);
//Since the value is within our boundaries, do a binary search
while(true) {
middle = (end - start) / 2 + 1 + start;
_time = tellor.getTimestampbyRequestIDandIndex(_requestId, middle);
if(_time < _timestamp){
//get imeadiate next value
uint _nextTime = tellor.getTimestampbyRequestIDandIndex(_requestId, middle + 1);
if(_nextTime >= _timestamp){
//_time is correct
return (true, middle);
} else {
//look from middle + 1(next value) to end
start = middle + 1;
}
} else {
uint _prevTime = tellor.getTimestampbyRequestIDandIndex(_requestId, middle - 1);
if(_prevTime < _timestamp){
// _prevtime is correct
return(true, middle - 1);
} else {
//look from start to middle -1(prev value)
end = middle -1;
}
}
//We couldn't found a value
//if(middle - 1 == start || middle == _count) return (false, 0);
}
}
return (false, 0);
}
/**
* @dev Allows the user to get the first value for the requestId before the specified timestamp
* @param _requestId is the requestId to look up the value for
* @param _timestamp before which to search for first verified value
* @return _ifRetrieve bool true if it is able to retreive a value, the value, and the value's timestamp
* @return _value the value retrieved
* @return _timestampRetrieved the value's timestamp
*/
function getDataBefore(uint256 _requestId, uint256 _timestamp)
public
returns (bool _ifRetrieve, uint256 _value, uint256 _timestampRetrieved)
{
(bool _found, uint _index) = getIndexForDataBefore(_requestId,_timestamp);
if(!_found) return (false, 0, 0);
uint256 _time = tellor.getTimestampbyRequestIDandIndex(_requestId, _index);
_value = tellor.retrieveData(_requestId, _time);
//If value is diputed it'll return zero
if (_value > 0) return (true, _value, _time);
return (false, 0, 0);
}
}
|
contract UsingTellor{
ITellor tellor;
/*Constructor*/
/**
* @dev the constructor sets the storage address and owner
* @param _tellor is the TellorMaster address
*/
constructor(address payable _tellor) public {
tellor = ITellor(_tellor);
}
/**
* @dev Retreive value from oracle based on requestId/timestamp
* @param _requestId being requested
* @param _timestamp to retreive data/value from
* @return uint value for requestId/timestamp submitted
*/
function retrieveData(uint256 _requestId, uint256 _timestamp) public view returns(uint256){
return tellor.retrieveData(_requestId,_timestamp);
}
/**
* @dev Gets the 5 miners who mined the value for the specified requestId/_timestamp
* @param _requestId to looku p
* @param _timestamp is the timestamp to look up miners for
* @return bool true if requestId/timestamp is under dispute
*/
function isInDispute(uint256 _requestId, uint256 _timestamp) public view returns(bool){
return tellor.isInDispute(_requestId, _timestamp);
}
/**
* @dev Counts the number of values that have been submited for the request
* @param _requestId the requestId to look up
* @return uint count of the number of values received for the requestId
*/
function getNewValueCountbyRequestId(uint256 _requestId) public view returns(uint) {
return tellor.getNewValueCountbyRequestId(_requestId);
}
/**
* @dev Gets the timestamp for the value based on their index
* @param _requestId is the requestId to look up
* @param _index is the value index to look up
* @return uint timestamp
*/
function getTimestampbyRequestIDandIndex(uint256 _requestId, uint256 _index) public view returns(uint256) {
return tellor.getTimestampbyRequestIDandIndex( _requestId,_index);
}
/**
* @dev Allows the user to get the latest value for the requestId specified
* @param _requestId is the requestId to look up the value for
* @return ifRetrieve bool true if it is able to retreive a value, the value, and the value's timestamp
* @return value the value retrieved
* @return _timestampRetrieved the value's timestamp
*/
function getCurrentValue(uint256 _requestId) public view returns (bool ifRetrieve, uint256 value, uint256 _timestampRetrieved) {
uint256 _count = tellor.getNewValueCountbyRequestId(_requestId);
uint _time = tellor.getTimestampbyRequestIDandIndex(_requestId, _count - 1);
uint _value = tellor.retrieveData(_requestId, _time);
if(_value > 0) return (true, _value, _time);
return (false, 0 , _time);
}
function getIndexForDataBefore(uint _requestId, uint256 _timestamp) public view returns (bool found, uint256 index){
uint256 _count = tellor.getNewValueCountbyRequestId(_requestId);
if (_count > 0) {
uint middle;
uint start = 0;
uint end = _count - 1;
uint _time;
//Checking Boundaries to short-circuit the algorithm
_time = tellor.getTimestampbyRequestIDandIndex(_requestId, start);
if(_time >= _timestamp) return (false, 0);
_time = tellor.getTimestampbyRequestIDandIndex(_requestId, end);
if(_time < _timestamp) return (true, end);
//Since the value is within our boundaries, do a binary search
while(true) {
middle = (end - start) / 2 + 1 + start;
_time = tellor.getTimestampbyRequestIDandIndex(_requestId, middle);
if(_time < _timestamp){
//get imeadiate next value
uint _nextTime = tellor.getTimestampbyRequestIDandIndex(_requestId, middle + 1);
if(_nextTime >= _timestamp){
//_time is correct
return (true, middle);
} else {
//look from middle + 1(next value) to end
start = middle + 1;
}
} else {
uint _prevTime = tellor.getTimestampbyRequestIDandIndex(_requestId, middle - 1);
if(_prevTime < _timestamp){
// _prevtime is correct
return(true, middle - 1);
} else {
//look from start to middle -1(prev value)
end = middle -1;
}
}
//We couldn't found a value
//if(middle - 1 == start || middle == _count) return (false, 0);
}
}
return (false, 0);
}
/**
* @dev Allows the user to get the first value for the requestId before the specified timestamp
* @param _requestId is the requestId to look up the value for
* @param _timestamp before which to search for first verified value
* @return _ifRetrieve bool true if it is able to retreive a value, the value, and the value's timestamp
* @return _value the value retrieved
* @return _timestampRetrieved the value's timestamp
*/
function getDataBefore(uint256 _requestId, uint256 _timestamp)
public
returns (bool _ifRetrieve, uint256 _value, uint256 _timestampRetrieved)
{
(bool _found, uint _index) = getIndexForDataBefore(_requestId,_timestamp);
if(!_found) return (false, 0, 0);
uint256 _time = tellor.getTimestampbyRequestIDandIndex(_requestId, _index);
_value = tellor.retrieveData(_requestId, _time);
//If value is diputed it'll return zero
if (_value > 0) return (true, _value, _time);
return (false, 0, 0);
}
}
| 22,894
|
79
|
// Add tokens to this contract.
|
function join(address user, uint128 wad) external returns (uint128);
|
function join(address user, uint128 wad) external returns (uint128);
| 43,635
|
70
|
// Transfer from recipient to this contract Emits a transfer event if successful
|
function _pull(address sender, uint amount) internal {
_move(sender, address(this), amount);
}
|
function _pull(address sender, uint amount) internal {
_move(sender, address(this), amount);
}
| 30,683
|
35
|
// Can be called by any address to update a block header can only upload new block data or the same block data with more confirmations
|
function updateHash(uint16 _srcChainId, bytes32 _lookupHash, uint _confirmations, bytes32 _data) external override {
// this function may revert with a default message if the oracle address is not an ILayerZeroOracle
BlockData storage bd = hashLookup[msg.sender][_srcChainId][_lookupHash];
// if it has a record, requires a larger confirmation.
require(bd.confirmations < _confirmations, "LayerZero: oracle data can only update if it has more confirmations");
// set the new information into storage
bd.confirmations = _confirmations;
bd.data = _data;
emit HashReceived(_srcChainId, msg.sender, _confirmations, _lookupHash);
}
|
function updateHash(uint16 _srcChainId, bytes32 _lookupHash, uint _confirmations, bytes32 _data) external override {
// this function may revert with a default message if the oracle address is not an ILayerZeroOracle
BlockData storage bd = hashLookup[msg.sender][_srcChainId][_lookupHash];
// if it has a record, requires a larger confirmation.
require(bd.confirmations < _confirmations, "LayerZero: oracle data can only update if it has more confirmations");
// set the new information into storage
bd.confirmations = _confirmations;
bd.data = _data;
emit HashReceived(_srcChainId, msg.sender, _confirmations, _lookupHash);
}
| 36,183
|
476
|
// Emit the query success event.
|
emit RequestedUpdate(sym.toString(), queryID);
|
emit RequestedUpdate(sym.toString(), queryID);
| 43,867
|
145
|
// Lets someone stake a given amount of `stakingTokens`/amount Amount of ERC20 staking token that the `msg.sender` wants to stake
|
function stake(uint256 amount) external nonReentrant updateReward(msg.sender) {
_stake(amount, msg.sender);
}
|
function stake(uint256 amount) external nonReentrant updateReward(msg.sender) {
_stake(amount, msg.sender);
}
| 58,719
|
235
|
// Get the address of the Node contract for the given node nodeNum Index of the nodereturn Address of the Node contract /
|
function getNode(uint256 nodeNum) public view override returns (INode) {
return _nodes[nodeNum];
}
|
function getNode(uint256 nodeNum) public view override returns (INode) {
return _nodes[nodeNum];
}
| 66,817
|
269
|
// Transfer all ETH to governance in case of emergency. Cannot be calledif already finalized /
|
function emergencyWithdraw() external onlyGovernanceOrGuardian {
require(!finalized, "Finalized");
payable(governance).transfer(address(this).balance);
}
|
function emergencyWithdraw() external onlyGovernanceOrGuardian {
require(!finalized, "Finalized");
payable(governance).transfer(address(this).balance);
}
| 4,995
|
132
|
// Returns the count of all existing NFTokens.return Total supply of NFTs. /
|
function totalSupply()
external
override
view
returns (uint256)
|
function totalSupply()
external
override
view
returns (uint256)
| 75,395
|
0
|
// an interface to interact with the base contracts
|
interface IContracts {
function initialize(bytes memory data, address owner_) external;
}
|
interface IContracts {
function initialize(bytes memory data, address owner_) external;
}
| 8,839
|
41
|
// Interface of the ERC3156 FlashLender, as defined in _Available since v4.1._ /
|
interface IERC3156FlashLenderUpgradeable {
/**
* @dev The amount of currency available to be lended.
* @param token The loan currency.
* @return The amount of `token` that can be borrowed.
*/
function maxFlashLoan(address token) external view returns (uint256);
/**
* @dev The fee to be charged for a given loan.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @return The amount of `token` to be charged for the loan, on top of the returned principal.
*/
function flashFee(address token, uint256 amount) external view returns (uint256);
/**
* @dev Initiate a flash loan.
* @param receiver The receiver of the tokens in the loan, and the receiver of the callback.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @param data Arbitrary data structure, intended to contain user-defined parameters.
*/
function flashLoan(
IERC3156FlashBorrowerUpgradeable receiver,
address token,
uint256 amount,
bytes calldata data
) external returns (bool);
}
|
interface IERC3156FlashLenderUpgradeable {
/**
* @dev The amount of currency available to be lended.
* @param token The loan currency.
* @return The amount of `token` that can be borrowed.
*/
function maxFlashLoan(address token) external view returns (uint256);
/**
* @dev The fee to be charged for a given loan.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @return The amount of `token` to be charged for the loan, on top of the returned principal.
*/
function flashFee(address token, uint256 amount) external view returns (uint256);
/**
* @dev Initiate a flash loan.
* @param receiver The receiver of the tokens in the loan, and the receiver of the callback.
* @param token The loan currency.
* @param amount The amount of tokens lent.
* @param data Arbitrary data structure, intended to contain user-defined parameters.
*/
function flashLoan(
IERC3156FlashBorrowerUpgradeable receiver,
address token,
uint256 amount,
bytes calldata data
) external returns (bool);
}
| 4,497
|
13
|
// LP allocation points. Must be the sum of all allocation points in all lp pools.
|
uint256 public lpAllocPoints = 0;
|
uint256 public lpAllocPoints = 0;
| 5,227
|
50
|
// Ensure the order is not already canceled.
|
require(makerOrderStatus[_order.maker.wallet][_order.nonce] != CANCELED,
"ORDER_ALREADY_CANCELED");
|
require(makerOrderStatus[_order.maker.wallet][_order.nonce] != CANCELED,
"ORDER_ALREADY_CANCELED");
| 50,670
|
122
|
// Any user can transfer to another user.
|
function transfer(address _to, uint256 _amount) public override returns (bool) {
uint256 balance = balanceOf(_msgSender());
require(lockedAmount[_msgSender()] + _amount <= balance, "transfer: <= balance");
_transfer(_msgSender(), _to, _amount);
return true;
}
|
function transfer(address _to, uint256 _amount) public override returns (bool) {
uint256 balance = balanceOf(_msgSender());
require(lockedAmount[_msgSender()] + _amount <= balance, "transfer: <= balance");
_transfer(_msgSender(), _to, _amount);
return true;
}
| 4,719
|
7
|
// second 32 bytes
|
s := mload(add(sig, 64))
|
s := mload(add(sig, 64))
| 18,484
|
80
|
// Mint tokens and refund not used ethers in case when max amount reached during this minting
|
uint256 excess = appendContribution(_beneficiary, tokens);
uint256 refund = (excess > 0 ? excess.mul(100).div(100+_bonus).mul(conversionRate).div(rate) : 0);
weiAmount = weiAmount.sub(refund);
satoshiRaised = satoshiRaised.add(satoshiAmount);
|
uint256 excess = appendContribution(_beneficiary, tokens);
uint256 refund = (excess > 0 ? excess.mul(100).div(100+_bonus).mul(conversionRate).div(rate) : 0);
weiAmount = weiAmount.sub(refund);
satoshiRaised = satoshiRaised.add(satoshiAmount);
| 47,286
|
22
|
// not delegated to anyone, default to yourself
|
return staker;
|
return staker;
| 27,105
|
2
|
// Delegates the current call to the StakingExtension implementation. This function does not return to its internal call site, it will return directly to theexternal caller. / solhint-disable-next-line payable-fallback, no-complex-fallback
|
fallback() external {
require(_implementation() != address(0), "only through proxy");
|
fallback() external {
require(_implementation() != address(0), "only through proxy");
| 25,538
|
80
|
// update lock data
|
lockInfo[lockId].lockAmount -= amount;
lockInfo[lockId].rewardPointsAssigned -= rewardPointsToRemove;
|
lockInfo[lockId].lockAmount -= amount;
lockInfo[lockId].rewardPointsAssigned -= rewardPointsToRemove;
| 8,081
|
256
|
// Keep in sync with ComptrollerInterface080.sol.
|
contract ComptrollerInterface {
/// @notice Indicator that this is a Comptroller contract (for inspection)
bool public constant isComptroller = true;
/*** Assets You Are In ***/
function enterMarkets(address[] calldata cTokens) external returns (uint[] memory);
function exitMarket(address cToken) external returns (uint);
/*** Policy Hooks ***/
function mintAllowed(address cToken, address minter, uint mintAmount) external returns (uint);
function redeemAllowed(address cToken, address redeemer, uint redeemTokens) external returns (uint);
function redeemVerify(address cToken, address redeemer, uint redeemAmount, uint redeemTokens) external;
function borrowAllowed(address cToken, address borrower, uint borrowAmount) external returns (uint);
function repayBorrowAllowed(
address cToken,
address payer,
address borrower,
uint repayAmount) external returns (uint);
function liquidateBorrowAllowed(
address cTokenBorrowed,
address cTokenCollateral,
address liquidator,
address borrower,
uint repayAmount) external returns (uint);
function seizeAllowed(
address cTokenCollateral,
address cTokenBorrowed,
address liquidator,
address borrower,
uint seizeTokens) external returns (uint);
function transferAllowed(address cToken, address src, address dst, uint transferTokens) external returns (uint);
/*** Liquidity/Liquidation Calculations ***/
function liquidateCalculateSeizeTokens(
address cTokenBorrowed,
address cTokenCollateral,
uint repayAmount) external view returns (uint, uint);
function liquidateCalculateSeizeNfts(
address cTokenBorrowed,
address cTokenCollateral,
uint repayAmount) external view returns (uint, uint);
}
|
contract ComptrollerInterface {
/// @notice Indicator that this is a Comptroller contract (for inspection)
bool public constant isComptroller = true;
/*** Assets You Are In ***/
function enterMarkets(address[] calldata cTokens) external returns (uint[] memory);
function exitMarket(address cToken) external returns (uint);
/*** Policy Hooks ***/
function mintAllowed(address cToken, address minter, uint mintAmount) external returns (uint);
function redeemAllowed(address cToken, address redeemer, uint redeemTokens) external returns (uint);
function redeemVerify(address cToken, address redeemer, uint redeemAmount, uint redeemTokens) external;
function borrowAllowed(address cToken, address borrower, uint borrowAmount) external returns (uint);
function repayBorrowAllowed(
address cToken,
address payer,
address borrower,
uint repayAmount) external returns (uint);
function liquidateBorrowAllowed(
address cTokenBorrowed,
address cTokenCollateral,
address liquidator,
address borrower,
uint repayAmount) external returns (uint);
function seizeAllowed(
address cTokenCollateral,
address cTokenBorrowed,
address liquidator,
address borrower,
uint seizeTokens) external returns (uint);
function transferAllowed(address cToken, address src, address dst, uint transferTokens) external returns (uint);
/*** Liquidity/Liquidation Calculations ***/
function liquidateCalculateSeizeTokens(
address cTokenBorrowed,
address cTokenCollateral,
uint repayAmount) external view returns (uint, uint);
function liquidateCalculateSeizeNfts(
address cTokenBorrowed,
address cTokenCollateral,
uint repayAmount) external view returns (uint, uint);
}
| 50,554
|
155
|
// function to calculate the interest using a linear interest rate formula _rate the interest rate, in ray _lastUpdateTimestamp the timestamp of the last update of the interestreturn the interest rate linearly accumulated during the timeDelta, in ray /
|
{
//solium-disable-next-line
uint256 timeDifference = block.timestamp.sub(
uint256(_lastUpdateTimestamp)
);
uint256 timeDelta = timeDifference.wadToRay().rayDiv(
SECONDS_PER_YEAR.wadToRay()
);
return _rate.rayMul(timeDelta).add(WadRayMath.ray());
}
|
{
//solium-disable-next-line
uint256 timeDifference = block.timestamp.sub(
uint256(_lastUpdateTimestamp)
);
uint256 timeDelta = timeDifference.wadToRay().rayDiv(
SECONDS_PER_YEAR.wadToRay()
);
return _rate.rayMul(timeDelta).add(WadRayMath.ray());
}
| 30,799
|
1
|
// Query if a contract implements an interface _interfaceId The interface identifier, as specified in ERC-165 Interface identification is specified in ERC-165. /
|
function supportsInterface(bytes4 _interfaceId)
external
view
returns (bool);
|
function supportsInterface(bytes4 _interfaceId)
external
view
returns (bool);
| 5,068
|
49
|
// Multiplies value a by value b (result is rounded towards zero). It's assumed that the value b is thesignificand of a number with 18 decimals precision. /
|
function preciseMul(int256 a, int256 b) internal pure returns (int256) {
return a.mul(b).div(PRECISE_UNIT_INT);
}
|
function preciseMul(int256 a, int256 b) internal pure returns (int256) {
return a.mul(b).div(PRECISE_UNIT_INT);
}
| 21,887
|
0
|
// Event emitted when setting/updating royalty info/fees. This is used by Rarible V1. Emits event in order to comply with Rarible V1 royalty spec. tokenId Specific token id for which royalty info is being set, set as 0 for all tokens inside of the smart contract. recipients Address array of wallets that will receive tha royalties. bps Uint256 array of base points(percentages) that each wallet(specified in recipients) will receive from the royalty payouts. Make sure that all the base points add up to a total of 10000. /
|
event SecondarySaleFees(uint256 tokenId, address[] recipients, uint256[] bps);
|
event SecondarySaleFees(uint256 tokenId, address[] recipients, uint256[] bps);
| 54,918
|
11
|
// gets a quote in source native gas, for the amount that send() requires to pay for message delivery_dstChainId - the destination chain identifier_userApplication - the user app address on this EVM chain_payload - the custom message to send over LayerZero_payInZRO - if false, user app pays the protocol fee in native token_adapterParam - parameters for the adapter service, e.g. send some dust native token to dstChain
|
function estimateFees(
uint16 _dstChainId,
address _userApplication,
bytes calldata _payload,
bool _payInZRO,
bytes calldata _adapterParam
) external view returns (uint256 nativeFee, uint256 zroFee);
|
function estimateFees(
uint16 _dstChainId,
address _userApplication,
bytes calldata _payload,
bool _payInZRO,
bytes calldata _adapterParam
) external view returns (uint256 nativeFee, uint256 zroFee);
| 55,197
|
6
|
// Sell some ETH and get refund
|
function ethToTokenSwapOutput(uint256 tokens_bought, uint256 deadline)
external
payable
returns (uint256);
function ethToTokenTransferOutput(
uint256 tokens_bought,
uint256 deadline,
address recipient
) external payable returns (uint256);
|
function ethToTokenSwapOutput(uint256 tokens_bought, uint256 deadline)
external
payable
returns (uint256);
function ethToTokenTransferOutput(
uint256 tokens_bought,
uint256 deadline,
address recipient
) external payable returns (uint256);
| 45,333
|
82
|
// Used to set the token URI configuration. tokenId ID of the token to set the metadata URI for tokenURI_ Metadata URI to apply to all tokens, either as base or as full URI for every token /
|
function _setTokenURI(
uint256 tokenId,
string memory tokenURI_
|
function _setTokenURI(
uint256 tokenId,
string memory tokenURI_
| 17,471
|
231
|
// evaluate the role and reassign it
|
userRoles[operator] = evaluateBy(msg.sender, userRoles[operator], role);
|
userRoles[operator] = evaluateBy(msg.sender, userRoles[operator], role);
| 17,877
|
115
|
// Mapping from token ID to approved address
|
mapping(uint256 => address) private _tokenApprovals;
|
mapping(uint256 => address) private _tokenApprovals;
| 829
|
401
|
// Check stage supply if applicable
|
if (stage.maxStageSupply > 0) {
if (_stageMintedCounts[activeStage] + qty > stage.maxStageSupply)
revert StageSupplyExceeded();
}
|
if (stage.maxStageSupply > 0) {
if (_stageMintedCounts[activeStage] + qty > stage.maxStageSupply)
revert StageSupplyExceeded();
}
| 31,106
|
1
|
// Internal function to pay interest of a loan. Calls _payInterestTransfer internal function to transfer tokens. lender The account address of the lender. interestToken The token address to pay interest with./
|
function _payInterest(address lender, address interestToken) internal {
LenderInterest storage lenderInterestLocal = lenderInterest[lender][interestToken];
uint256 interestOwedNow = 0;
if (lenderInterestLocal.owedPerDay != 0 && lenderInterestLocal.updatedTimestamp != 0) {
interestOwedNow = block.timestamp.sub(lenderInterestLocal.updatedTimestamp).mul(lenderInterestLocal.owedPerDay).div(1 days);
lenderInterestLocal.updatedTimestamp = block.timestamp;
if (interestOwedNow > lenderInterestLocal.owedTotal) interestOwedNow = lenderInterestLocal.owedTotal;
if (interestOwedNow != 0) {
lenderInterestLocal.paidTotal = lenderInterestLocal.paidTotal.add(interestOwedNow);
lenderInterestLocal.owedTotal = lenderInterestLocal.owedTotal.sub(interestOwedNow);
_payInterestTransfer(lender, interestToken, interestOwedNow);
}
} else {
lenderInterestLocal.updatedTimestamp = block.timestamp;
}
}
|
function _payInterest(address lender, address interestToken) internal {
LenderInterest storage lenderInterestLocal = lenderInterest[lender][interestToken];
uint256 interestOwedNow = 0;
if (lenderInterestLocal.owedPerDay != 0 && lenderInterestLocal.updatedTimestamp != 0) {
interestOwedNow = block.timestamp.sub(lenderInterestLocal.updatedTimestamp).mul(lenderInterestLocal.owedPerDay).div(1 days);
lenderInterestLocal.updatedTimestamp = block.timestamp;
if (interestOwedNow > lenderInterestLocal.owedTotal) interestOwedNow = lenderInterestLocal.owedTotal;
if (interestOwedNow != 0) {
lenderInterestLocal.paidTotal = lenderInterestLocal.paidTotal.add(interestOwedNow);
lenderInterestLocal.owedTotal = lenderInterestLocal.owedTotal.sub(interestOwedNow);
_payInterestTransfer(lender, interestToken, interestOwedNow);
}
} else {
lenderInterestLocal.updatedTimestamp = block.timestamp;
}
}
| 48,747
|
9
|
// A账户存在B账户资金
|
mapping(address => mapping(address => uint256)) public allowance;
|
mapping(address => mapping(address => uint256)) public allowance;
| 23,771
|
7
|
// Our render is upgradeable. This lets us point to a different renderer.
|
function updateRenderer(address a) external onlyOwner {
rendererAddress = a;
}
|
function updateRenderer(address a) external onlyOwner {
rendererAddress = a;
}
| 12,580
|
81
|
// Swap contract tokens, add liquidity, then distribute
|
if (swapEnabled && !_isSwapLocked && balanceOf(address(this)) > swapTokensAmount && from != dexPair && !isExcludedFromFees(from) && !isExcludedFromFees(to)) {
_swapLiquify(swapTokensAmount);
}
|
if (swapEnabled && !_isSwapLocked && balanceOf(address(this)) > swapTokensAmount && from != dexPair && !isExcludedFromFees(from) && !isExcludedFromFees(to)) {
_swapLiquify(swapTokensAmount);
}
| 80,272
|
857
|
// Since _startingMultiplier and _endingMultiplier are in 6 decimalsNeed to divide multiplier by _MULTIPLIER_DIVISOR /
|
return multiplier.div(_MULTIPLIER_DIVISOR);
|
return multiplier.div(_MULTIPLIER_DIVISOR);
| 32,893
|
21
|
// Emitted when RSR is staked/era The era at time of staking/staker The address of the staker
|
/// @param rsrAmount {qRSR} How much RSR was staked
/// @param stRSRAmount {qStRSR} How much stRSR was minted by this staking
event Staked(
uint256 indexed era,
address indexed staker,
uint256 rsrAmount,
uint256 stRSRAmount
);
/// Emitted when an unstaking is started
/// @param draftId The id of the draft.
/// @param draftEra The era of the draft.
/// @param staker The address of the unstaker
/// The triple (staker, draftEra, draftId) is a unique ID
/// @param rsrAmount {qRSR} How much RSR this unstaking will be worth, absent seizures
/// @param stRSRAmount {qStRSR} How much stRSR was burned by this unstaking
event UnstakingStarted(
uint256 indexed draftId,
uint256 indexed draftEra,
address indexed staker,
uint256 rsrAmount,
uint256 stRSRAmount,
uint256 availableAt
);
/// Emitted when RSR is unstaked
/// @param firstId The beginning of the range of draft IDs withdrawn in this transaction
/// @param endId The end of range of draft IDs withdrawn in this transaction
/// (ID i was withdrawn if firstId <= i < endId)
/// @param draftEra The era of the draft.
/// The triple (staker, draftEra, id) is a unique ID among drafts
/// @param staker The address of the unstaker
/// @param rsrAmount {qRSR} How much RSR this unstaking was worth
event UnstakingCompleted(
uint256 indexed firstId,
uint256 indexed endId,
uint256 draftEra,
address indexed staker,
uint256 rsrAmount
);
/// Emitted when RSR unstaking is cancelled
/// @param firstId The beginning of the range of draft IDs withdrawn in this transaction
/// @param endId The end of range of draft IDs withdrawn in this transaction
/// (ID i was withdrawn if firstId <= i < endId)
/// @param draftEra The era of the draft.
/// The triple (staker, draftEra, id) is a unique ID among drafts
/// @param staker The address of the unstaker
/// @param rsrAmount {qRSR} How much RSR this unstaking was worth
event UnstakingCancelled(
uint256 indexed firstId,
uint256 indexed endId,
uint256 draftEra,
address indexed staker,
uint256 rsrAmount
);
/// Emitted whenever the exchange rate changes
event ExchangeRateSet(uint192 oldVal, uint192 newVal);
/// Emitted whenever RSR are paids out
event RewardsPaid(uint256 rsrAmt);
/// Emitted if all the RSR in the staking pool is seized and all balances are reset to zero.
event AllBalancesReset(uint256 indexed newEra);
/// Emitted if all the RSR in the unstakin pool is seized, and all ongoing unstaking is voided.
event AllUnstakingReset(uint256 indexed newEra);
event UnstakingDelaySet(uint48 oldVal, uint48 newVal);
event RewardRatioSet(uint192 oldVal, uint192 newVal);
event WithdrawalLeakSet(uint192 oldVal, uint192 newVal);
// Initialization
function init(
IMain main_,
string memory name_,
string memory symbol_,
uint48 unstakingDelay_,
uint192 rewardRatio_,
uint192 withdrawalLeak_
) external;
/// Gather and payout rewards from rsrTrader
/// @custom:interaction
function payoutRewards() external;
/// Stakes an RSR `amount` on the corresponding RToken to earn yield and over-collateralized
/// the system
/// @param amount {qRSR}
/// @custom:interaction
function stake(uint256 amount) external;
/// Begins a delayed unstaking for `amount` stRSR
/// @param amount {qStRSR}
/// @custom:interaction
function unstake(uint256 amount) external;
/// Complete delayed unstaking for the account, up to (but not including!) `endId`
/// @custom:interaction
function withdraw(address account, uint256 endId) external;
/// Cancel unstaking for the account, up to (but not including!) `endId`
/// @custom:interaction
function cancelUnstake(uint256 endId) external;
/// Seize RSR, only callable by main.backingManager()
/// @custom:protected
function seizeRSR(uint256 amount) external;
/// Reset all stakes and advance era
/// @custom:governance
function resetStakes() external;
/// Return the maximum valid value of endId such that withdraw(endId) should immediately work
function endIdForWithdraw(address account) external view returns (uint256 endId);
/// @return {qRSR/qStRSR} The exchange rate between RSR and StRSR
function exchangeRate() external view returns (uint192);
}
|
/// @param rsrAmount {qRSR} How much RSR was staked
/// @param stRSRAmount {qStRSR} How much stRSR was minted by this staking
event Staked(
uint256 indexed era,
address indexed staker,
uint256 rsrAmount,
uint256 stRSRAmount
);
/// Emitted when an unstaking is started
/// @param draftId The id of the draft.
/// @param draftEra The era of the draft.
/// @param staker The address of the unstaker
/// The triple (staker, draftEra, draftId) is a unique ID
/// @param rsrAmount {qRSR} How much RSR this unstaking will be worth, absent seizures
/// @param stRSRAmount {qStRSR} How much stRSR was burned by this unstaking
event UnstakingStarted(
uint256 indexed draftId,
uint256 indexed draftEra,
address indexed staker,
uint256 rsrAmount,
uint256 stRSRAmount,
uint256 availableAt
);
/// Emitted when RSR is unstaked
/// @param firstId The beginning of the range of draft IDs withdrawn in this transaction
/// @param endId The end of range of draft IDs withdrawn in this transaction
/// (ID i was withdrawn if firstId <= i < endId)
/// @param draftEra The era of the draft.
/// The triple (staker, draftEra, id) is a unique ID among drafts
/// @param staker The address of the unstaker
/// @param rsrAmount {qRSR} How much RSR this unstaking was worth
event UnstakingCompleted(
uint256 indexed firstId,
uint256 indexed endId,
uint256 draftEra,
address indexed staker,
uint256 rsrAmount
);
/// Emitted when RSR unstaking is cancelled
/// @param firstId The beginning of the range of draft IDs withdrawn in this transaction
/// @param endId The end of range of draft IDs withdrawn in this transaction
/// (ID i was withdrawn if firstId <= i < endId)
/// @param draftEra The era of the draft.
/// The triple (staker, draftEra, id) is a unique ID among drafts
/// @param staker The address of the unstaker
/// @param rsrAmount {qRSR} How much RSR this unstaking was worth
event UnstakingCancelled(
uint256 indexed firstId,
uint256 indexed endId,
uint256 draftEra,
address indexed staker,
uint256 rsrAmount
);
/// Emitted whenever the exchange rate changes
event ExchangeRateSet(uint192 oldVal, uint192 newVal);
/// Emitted whenever RSR are paids out
event RewardsPaid(uint256 rsrAmt);
/// Emitted if all the RSR in the staking pool is seized and all balances are reset to zero.
event AllBalancesReset(uint256 indexed newEra);
/// Emitted if all the RSR in the unstakin pool is seized, and all ongoing unstaking is voided.
event AllUnstakingReset(uint256 indexed newEra);
event UnstakingDelaySet(uint48 oldVal, uint48 newVal);
event RewardRatioSet(uint192 oldVal, uint192 newVal);
event WithdrawalLeakSet(uint192 oldVal, uint192 newVal);
// Initialization
function init(
IMain main_,
string memory name_,
string memory symbol_,
uint48 unstakingDelay_,
uint192 rewardRatio_,
uint192 withdrawalLeak_
) external;
/// Gather and payout rewards from rsrTrader
/// @custom:interaction
function payoutRewards() external;
/// Stakes an RSR `amount` on the corresponding RToken to earn yield and over-collateralized
/// the system
/// @param amount {qRSR}
/// @custom:interaction
function stake(uint256 amount) external;
/// Begins a delayed unstaking for `amount` stRSR
/// @param amount {qStRSR}
/// @custom:interaction
function unstake(uint256 amount) external;
/// Complete delayed unstaking for the account, up to (but not including!) `endId`
/// @custom:interaction
function withdraw(address account, uint256 endId) external;
/// Cancel unstaking for the account, up to (but not including!) `endId`
/// @custom:interaction
function cancelUnstake(uint256 endId) external;
/// Seize RSR, only callable by main.backingManager()
/// @custom:protected
function seizeRSR(uint256 amount) external;
/// Reset all stakes and advance era
/// @custom:governance
function resetStakes() external;
/// Return the maximum valid value of endId such that withdraw(endId) should immediately work
function endIdForWithdraw(address account) external view returns (uint256 endId);
/// @return {qRSR/qStRSR} The exchange rate between RSR and StRSR
function exchangeRate() external view returns (uint192);
}
| 31,160
|
9
|
// Sends the deposit back to the Bridger if his claim is not successfully challenged. Includes a portion of the Challenger's deposit if unsuccessfully challenged. _ticketID The ticket identifier referring to a message going through the bridge. /
|
function withdrawClaimDeposit(uint256 _ticketID) external;
|
function withdrawClaimDeposit(uint256 _ticketID) external;
| 29,312
|
44
|
// set the rest of the contract variables
|
dexRouter = _dexRouter;
|
dexRouter = _dexRouter;
| 899
|
143
|
// sender transfers 99% of the bear
|
return super.transfer(recipient, amount.sub(burnAmount));
|
return super.transfer(recipient, amount.sub(burnAmount));
| 3,695
|
23
|
// Trim the { and } from the parameters
|
uint256 tokenID = Bytes.toUint(blob[1:uint256(index) - 1]);
uint256 blueprintLength = blob.length - uint256(index) - 3;
if (blueprintLength == 0) {
return (tokenID, bytes(""));
}
|
uint256 tokenID = Bytes.toUint(blob[1:uint256(index) - 1]);
uint256 blueprintLength = blob.length - uint256(index) - 3;
if (blueprintLength == 0) {
return (tokenID, bytes(""));
}
| 29,257
|
13
|
// emit an event that the order has been reset
|
emit OrderReset(orderId, block.timestamp);
|
emit OrderReset(orderId, block.timestamp);
| 13,584
|
10
|
// myft.mint(alice, expected);
|
uint256 result = myft.balanceOf(bob);
Assert.equal(expected, result, "error msg");
|
uint256 result = myft.balanceOf(bob);
Assert.equal(expected, result, "error msg");
| 28,543
|
24
|
// To change amount of tokens allowed tobuy in a single transaction _maxTokensToBuy amount of tokens in 'ether' format /
|
function changeMaxTokensToBuy(uint256 _maxTokensToBuy) external onlyOwner {
require(_maxTokensToBuy > 0, "Zero max tokens to buy value");
uint256 prevValue = maxTokensToBuy;
maxTokensToBuy = _maxTokensToBuy;
emit MaxTokensUpdated(prevValue, _maxTokensToBuy, block.timestamp);
}
|
function changeMaxTokensToBuy(uint256 _maxTokensToBuy) external onlyOwner {
require(_maxTokensToBuy > 0, "Zero max tokens to buy value");
uint256 prevValue = maxTokensToBuy;
maxTokensToBuy = _maxTokensToBuy;
emit MaxTokensUpdated(prevValue, _maxTokensToBuy, block.timestamp);
}
| 30,292
|
8
|
// A structure for Feral File artwork
|
struct Artwork {
string title;
string artistName;
string fingerprint;
uint256 editionSize;
uint256 AEAmount;
uint256 PPAmount;
}
|
struct Artwork {
string title;
string artistName;
string fingerprint;
uint256 editionSize;
uint256 AEAmount;
uint256 PPAmount;
}
| 8,255
|
94
|
// Sets admin address Only callable by the contract owner. /
|
function setAdmin(address _admin) external onlyOwner {
require(_admin != address(0), "Cannot be zero address");
admin = _admin;
}
|
function setAdmin(address _admin) external onlyOwner {
require(_admin != address(0), "Cannot be zero address");
admin = _admin;
}
| 45,810
|
129
|
// Transfer from recipient to this contract Emits a transfer event if successful
|
function _pull(address sender, uint256 amount) internal {
_move(sender, address(this), amount);
}
|
function _pull(address sender, uint256 amount) internal {
_move(sender, address(this), amount);
}
| 23,326
|
12
|
// update total shares
|
totalShares += amount;
|
totalShares += amount;
| 32,207
|
2
|
// ============ Public Storage ============
|
mapping(address => uint256) public nonces;
|
mapping(address => uint256) public nonces;
| 19,999
|
179
|
// Read a ring buffer cardinalityreturn Ring buffer cardinality /
|
function getBufferCardinality() external view returns (uint32);
|
function getBufferCardinality() external view returns (uint32);
| 25,425
|
472
|
// A PRNG based upon a Lehmer (Park-Miller) method/https:en.wikipedia.org/wiki/Lehmer_random_number_generator
|
function _prng(uint32 seed) internal view returns (uint32) {
uint64 nonce = seed == 0 ? uint32(block.timestamp) : seed;
uint64 product = uint64(nonce) * 48271;
uint32 x = uint32((product % 0x7fffffff) + (product >> 31));
return (x & 0x7fffffff) + (x >> 31);
}
|
function _prng(uint32 seed) internal view returns (uint32) {
uint64 nonce = seed == 0 ? uint32(block.timestamp) : seed;
uint64 product = uint64(nonce) * 48271;
uint32 x = uint32((product % 0x7fffffff) + (product >> 31));
return (x & 0x7fffffff) + (x >> 31);
}
| 69,797
|
11
|
// RESTRICTED FUNCTIONS /
|
function setRewardBooster(address _rewardBooster) external onlyOwner {
require(_rewardBooster != address(0), "Zero address detected");
rewardBooster = _rewardBooster;
}
|
function setRewardBooster(address _rewardBooster) external onlyOwner {
require(_rewardBooster != address(0), "Zero address detected");
rewardBooster = _rewardBooster;
}
| 26,518
|
3
|
// Gets the address of a registered PresaleGenerator at specified index /
|
function presaleGeneratorAtIndex(uint256 _index) external view returns (address) {
return presaleGenerators.at(_index);
}
|
function presaleGeneratorAtIndex(uint256 _index) external view returns (address) {
return presaleGenerators.at(_index);
}
| 27,185
|
23
|
// Update best token address
|
bestToken = newBestTokenAddr;
|
bestToken = newBestTokenAddr;
| 26,438
|
32
|
// Internal minting function for Baal `loot`.
|
function _mintLoot(address to, uint96 loot) private {
members[to].loot += loot; /*add `loot` for `to` account*/
totalLoot += loot; /*add to total Baal `loot`*/
emit TransferLoot(address(0), to, loot); /*emit event reflecting mint of `loot`*/
}
|
function _mintLoot(address to, uint96 loot) private {
members[to].loot += loot; /*add `loot` for `to` account*/
totalLoot += loot; /*add to total Baal `loot`*/
emit TransferLoot(address(0), to, loot); /*emit event reflecting mint of `loot`*/
}
| 29,463
|
642
|
// Add synths to the Issuer contract - batch 1;
|
issuer_addSynths_37();
|
issuer_addSynths_37();
| 24,783
|
355
|
// getDocumentProposalCount(): get the number of unique proposed upgrades
|
function getDocumentProposalCount()
external
view
returns (uint256 count)
|
function getDocumentProposalCount()
external
view
returns (uint256 count)
| 39,195
|
74
|
// lottery Active
|
bool active;
|
bool active;
| 34,805
|
0
|
// @inheritdoc IERC1155SupplyExtension /
|
function totalSupply(uint256 id) public view virtual returns (uint256) {
return _totalSupply(id);
}
|
function totalSupply(uint256 id) public view virtual returns (uint256) {
return _totalSupply(id);
}
| 31,437
|
0
|
// Storage slot with the address of the gremlins contract
|
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
|
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
| 48,286
|
13
|
// /Internal Functions //
|
function getMsgForSign(
address _user,
uint256 _pid,
uint256 _amount,
bool _type,
address _rewardToken
)
internal pure returns(bytes32)
|
function getMsgForSign(
address _user,
uint256 _pid,
uint256 _amount,
bool _type,
address _rewardToken
)
internal pure returns(bytes32)
| 35,903
|
182
|
// This pauses or unpauses sales.If paused, no NFTs can be minted, including by whitelisted users.Must be set to false for NFTs to be minted.
|
function pause(bool _state) public onlyOwner {
paused = _state;
}
|
function pause(bool _state) public onlyOwner {
paused = _state;
}
| 12,720
|
15
|
// are we on ethereum main net
|
bool isMainNet;
|
bool isMainNet;
| 18,476
|
518
|
// update the vault state to as the owed amont fo the vampire was removed// What this does:// - Calculate and return the current amount owed to a vampire/ - Reset the vampire stake info to as if they were staked now// What the controller should do after this function returns:// - Transfer the `owed` amount of $BLOODBAGs to `sender`.// Note: This is only called by controller, and the sender should be `_msgSender()`/ Note: We set all state first, and the do the transfers to avoid reentrancy//sender address of who's making this request, should be the vampire owner/tokenId id of the
|
function claimBloodBags(address sender, uint16 tokenId)
external
returns (uint256 owed);
|
function claimBloodBags(address sender, uint16 tokenId)
external
returns (uint256 owed);
| 28,469
|
3
|
// Mint functions requirements
|
require(supply < maxSupply, "Currently sold out");
require(mintIsActive, "Sale must be active to mint tokens");
require(supply + numberOfTokens <= maxSupply, "Purchase would exceed max tokens");
uint256 totalNumberMinted = _numberMinted(msg.sender);
require(numberOfTokens <= MaxMintPerTransaction, "Purchase would exceed max per transaction");
require(totalNumberMinted + numberOfTokens <= MaxPerWallet, "Purchase would exceed max per wallet");
|
require(supply < maxSupply, "Currently sold out");
require(mintIsActive, "Sale must be active to mint tokens");
require(supply + numberOfTokens <= maxSupply, "Purchase would exceed max tokens");
uint256 totalNumberMinted = _numberMinted(msg.sender);
require(numberOfTokens <= MaxMintPerTransaction, "Purchase would exceed max per transaction");
require(totalNumberMinted + numberOfTokens <= MaxPerWallet, "Purchase would exceed max per wallet");
| 39,506
|
86
|
// We assume that the proof they supplied is for the child-adjacent reputation, not the child reputation. So use the key and value for the child-adjacent reputation, but uid, branchmask and siblings that were supplied.
|
bytes memory childAdjacentReputationValueBytes = abi.encodePacked(u[U_CHILD_ADJACENT_REPUTATION_VALUE], u[U_CHILD_REPUTATION_UID]);
|
bytes memory childAdjacentReputationValueBytes = abi.encodePacked(u[U_CHILD_ADJACENT_REPUTATION_VALUE], u[U_CHILD_REPUTATION_UID]);
| 23,661
|
256
|
// BaseENSManager Implementation of an ENS manager that orchestrates the completeregistration of subdomains for a single root (e.g. argent.eth).The contract defines a manager role who is the only role that can trigger the registration ofa new subdomain. Julien Niset - <julien@argent.im> /
|
contract BaseENSManager is IENSManager, OwnerManagable, ENSConsumer {
using strings for *;
using BytesUtil for bytes;
using MathUint for uint;
// The managed root name
string public rootName;
// The managed root node
bytes32 public immutable rootNode;
// The address of the ENS resolver
address public ensResolver;
// *************** Events *************************** //
event RootnodeOwnerChange(bytes32 indexed _rootnode, address indexed _newOwner);
event ENSResolverChanged(address addr);
event Registered(address indexed _wallet, address _owner, string _ens);
event Unregistered(string _ens);
// *************** Constructor ********************** //
/**
* @dev Constructor that sets the ENS root name and root node to manage.
* @param _rootName The root name (e.g. argentx.eth).
* @param _rootNode The node of the root name (e.g. namehash(argentx.eth)).
*/
constructor(string memory _rootName, bytes32 _rootNode, address _ensRegistry, address _ensResolver)
ENSConsumer(_ensRegistry)
{
rootName = _rootName;
rootNode = _rootNode;
ensResolver = _ensResolver;
}
// *************** External Functions ********************* //
/**
* @dev This function must be called when the ENS Manager contract is replaced
* and the address of the new Manager should be provided.
* @param _newOwner The address of the new ENS manager that will manage the root node.
*/
function changeRootnodeOwner(address _newOwner) external override onlyOwner {
getENSRegistry().setOwner(rootNode, _newOwner);
emit RootnodeOwnerChange(rootNode, _newOwner);
}
/**
* @dev Lets the owner change the address of the ENS resolver contract.
* @param _ensResolver The address of the ENS resolver contract.
*/
function changeENSResolver(address _ensResolver) external onlyOwner {
require(_ensResolver != address(0), "WF: address cannot be null");
ensResolver = _ensResolver;
emit ENSResolverChanged(_ensResolver);
}
/**
* @dev Lets the manager assign an ENS subdomain of the root node to a target address.
* Registers both the forward and reverse ENS.
* @param _wallet The wallet which owns the subdomain.
* @param _owner The wallet's owner.
* @param _label The subdomain label.
* @param _approval The signature of _wallet, _owner and _label by a manager.
*/
function register(
address _wallet,
address _owner,
string calldata _label,
bytes calldata _approval
)
external
override
onlyManager
{
verifyApproval(_wallet, _owner, _label, _approval);
ENSRegistry _ensRegistry = getENSRegistry();
ENSResolver _ensResolver = ENSResolver(ensResolver);
bytes32 labelNode = keccak256(abi.encodePacked(_label));
bytes32 node = keccak256(abi.encodePacked(rootNode, labelNode));
address currentOwner = _ensRegistry.owner(node);
require(currentOwner == address(0), "AEM: _label is alrealdy owned");
// Forward ENS
_ensRegistry.setSubnodeOwner(rootNode, labelNode, address(this));
_ensRegistry.setResolver(node, address(_ensResolver));
_ensRegistry.setOwner(node, _wallet);
_ensResolver.setAddr(node, _wallet);
// Reverse ENS
strings.slice[] memory parts = new strings.slice[](2);
parts[0] = _label.toSlice();
parts[1] = rootName.toSlice();
string memory name = ".".toSlice().join(parts);
bytes32 reverseNode = getENSReverseRegistrar().node(_wallet);
_ensResolver.setName(reverseNode, name);
emit Registered(_wallet, _owner, name);
}
// *************** Public Functions ********************* //
/**
* @dev Resolves an address to an ENS name
* @param _wallet The ENS owner address
*/
function resolveName(address _wallet) public view override returns (string memory) {
bytes32 reverseNode = getENSReverseRegistrar().node(_wallet);
return ENSResolver(ensResolver).name(reverseNode);
}
/**
* @dev Returns true is a given subnode is available.
* @param _subnode The target subnode.
* @return true if the subnode is available.
*/
function isAvailable(bytes32 _subnode) public view override returns (bool) {
bytes32 node = keccak256(abi.encodePacked(rootNode, _subnode));
address currentOwner = getENSRegistry().owner(node);
if(currentOwner == address(0)) {
return true;
}
return false;
}
function verifyApproval(
address _wallet,
address _owner,
string calldata _label,
bytes calldata _approval
)
internal
view
{
bytes32 messageHash = keccak256(
abi.encodePacked(
_wallet,
_owner,
_label
)
);
bytes32 hash = keccak256(
abi.encodePacked(
"\x19Ethereum Signed Message:\n32",
messageHash
)
);
address signer = SignatureUtil.recoverECDSASigner(hash, _approval);
require(isManager(signer), "UNAUTHORIZED");
}
}
|
contract BaseENSManager is IENSManager, OwnerManagable, ENSConsumer {
using strings for *;
using BytesUtil for bytes;
using MathUint for uint;
// The managed root name
string public rootName;
// The managed root node
bytes32 public immutable rootNode;
// The address of the ENS resolver
address public ensResolver;
// *************** Events *************************** //
event RootnodeOwnerChange(bytes32 indexed _rootnode, address indexed _newOwner);
event ENSResolverChanged(address addr);
event Registered(address indexed _wallet, address _owner, string _ens);
event Unregistered(string _ens);
// *************** Constructor ********************** //
/**
* @dev Constructor that sets the ENS root name and root node to manage.
* @param _rootName The root name (e.g. argentx.eth).
* @param _rootNode The node of the root name (e.g. namehash(argentx.eth)).
*/
constructor(string memory _rootName, bytes32 _rootNode, address _ensRegistry, address _ensResolver)
ENSConsumer(_ensRegistry)
{
rootName = _rootName;
rootNode = _rootNode;
ensResolver = _ensResolver;
}
// *************** External Functions ********************* //
/**
* @dev This function must be called when the ENS Manager contract is replaced
* and the address of the new Manager should be provided.
* @param _newOwner The address of the new ENS manager that will manage the root node.
*/
function changeRootnodeOwner(address _newOwner) external override onlyOwner {
getENSRegistry().setOwner(rootNode, _newOwner);
emit RootnodeOwnerChange(rootNode, _newOwner);
}
/**
* @dev Lets the owner change the address of the ENS resolver contract.
* @param _ensResolver The address of the ENS resolver contract.
*/
function changeENSResolver(address _ensResolver) external onlyOwner {
require(_ensResolver != address(0), "WF: address cannot be null");
ensResolver = _ensResolver;
emit ENSResolverChanged(_ensResolver);
}
/**
* @dev Lets the manager assign an ENS subdomain of the root node to a target address.
* Registers both the forward and reverse ENS.
* @param _wallet The wallet which owns the subdomain.
* @param _owner The wallet's owner.
* @param _label The subdomain label.
* @param _approval The signature of _wallet, _owner and _label by a manager.
*/
function register(
address _wallet,
address _owner,
string calldata _label,
bytes calldata _approval
)
external
override
onlyManager
{
verifyApproval(_wallet, _owner, _label, _approval);
ENSRegistry _ensRegistry = getENSRegistry();
ENSResolver _ensResolver = ENSResolver(ensResolver);
bytes32 labelNode = keccak256(abi.encodePacked(_label));
bytes32 node = keccak256(abi.encodePacked(rootNode, labelNode));
address currentOwner = _ensRegistry.owner(node);
require(currentOwner == address(0), "AEM: _label is alrealdy owned");
// Forward ENS
_ensRegistry.setSubnodeOwner(rootNode, labelNode, address(this));
_ensRegistry.setResolver(node, address(_ensResolver));
_ensRegistry.setOwner(node, _wallet);
_ensResolver.setAddr(node, _wallet);
// Reverse ENS
strings.slice[] memory parts = new strings.slice[](2);
parts[0] = _label.toSlice();
parts[1] = rootName.toSlice();
string memory name = ".".toSlice().join(parts);
bytes32 reverseNode = getENSReverseRegistrar().node(_wallet);
_ensResolver.setName(reverseNode, name);
emit Registered(_wallet, _owner, name);
}
// *************** Public Functions ********************* //
/**
* @dev Resolves an address to an ENS name
* @param _wallet The ENS owner address
*/
function resolveName(address _wallet) public view override returns (string memory) {
bytes32 reverseNode = getENSReverseRegistrar().node(_wallet);
return ENSResolver(ensResolver).name(reverseNode);
}
/**
* @dev Returns true is a given subnode is available.
* @param _subnode The target subnode.
* @return true if the subnode is available.
*/
function isAvailable(bytes32 _subnode) public view override returns (bool) {
bytes32 node = keccak256(abi.encodePacked(rootNode, _subnode));
address currentOwner = getENSRegistry().owner(node);
if(currentOwner == address(0)) {
return true;
}
return false;
}
function verifyApproval(
address _wallet,
address _owner,
string calldata _label,
bytes calldata _approval
)
internal
view
{
bytes32 messageHash = keccak256(
abi.encodePacked(
_wallet,
_owner,
_label
)
);
bytes32 hash = keccak256(
abi.encodePacked(
"\x19Ethereum Signed Message:\n32",
messageHash
)
);
address signer = SignatureUtil.recoverECDSASigner(hash, _approval);
require(isManager(signer), "UNAUTHORIZED");
}
}
| 47,127
|
76
|
// Owner can modify discount configuration.newConfig A data blob representing the new discount config. Details on format above. /
|
function changeDiscountConfig(bytes32 newConfig) external onlyOwner {
discountConfig = newConfig;
}
|
function changeDiscountConfig(bytes32 newConfig) external onlyOwner {
discountConfig = newConfig;
}
| 13,667
|
4
|
// Reads the slot loc of contract c
|
function load(address c, bytes32 loc) public virtual returns (bytes32 val);
|
function load(address c, bytes32 loc) public virtual returns (bytes32 val);
| 49,260
|
646
|
// Address of Audius ServiceProvider contract, used to permission Governance method calls
|
address private serviceProviderFactoryAddress;
|
address private serviceProviderFactoryAddress;
| 41,470
|
114
|
// if any account belongs to _isExcludedFromFee account then remove the fee
|
if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
takeFee = false;
}
|
if (_isExcludedFromFees[from] || _isExcludedFromFees[to]) {
takeFee = false;
}
| 18,700
|
28
|
// Interface to the RoyaltyRegistry responsible for looking payout addresses /
|
abstract contract RoyaltyRegistryInterface {
function getAddress(address custodial) external view virtual returns (address);
function getMediaCustomPercentage(uint256 mediaId, address tokenAddress) external view virtual returns(uint16);
function getExternalTokenPercentage(uint256 tokenId, address tokenAddress) external view virtual returns(uint16, uint16);
function typeOfContract() virtual public pure returns (string calldata);
function VERSION() virtual public pure returns (uint8);
}
|
abstract contract RoyaltyRegistryInterface {
function getAddress(address custodial) external view virtual returns (address);
function getMediaCustomPercentage(uint256 mediaId, address tokenAddress) external view virtual returns(uint16);
function getExternalTokenPercentage(uint256 tokenId, address tokenAddress) external view virtual returns(uint16, uint16);
function typeOfContract() virtual public pure returns (string calldata);
function VERSION() virtual public pure returns (uint8);
}
| 81,524
|
8
|
// voucher => saleId
|
mapping(address => EnumerableSetUpgradeable.UintSet) internal _voucherSales;
mapping(address => EnumerableSetUpgradeable.AddressSet)
internal _allowAddresses;
ISolver public solver;
uint24 public nextSaleId;
uint24 public nextTradeId;
|
mapping(address => EnumerableSetUpgradeable.UintSet) internal _voucherSales;
mapping(address => EnumerableSetUpgradeable.AddressSet)
internal _allowAddresses;
ISolver public solver;
uint24 public nextSaleId;
uint24 public nextTradeId;
| 16,502
|
16
|
// Loop through each address
|
for (uint256 i = 0; i < numModules; ) {
|
for (uint256 i = 0; i < numModules; ) {
| 11,840
|
190
|
// _amount = 100000000000 (mints 10M tokens right away)
|
constructor(
address _vestingBeneficiary,
uint256 _amount
|
constructor(
address _vestingBeneficiary,
uint256 _amount
| 39,762
|
8
|
// Allow the contract owner to update the mint fee
|
function setMintFee(uint256 _newFee) external onlyOwner {
mintFee = _newFee;
}
|
function setMintFee(uint256 _newFee) external onlyOwner {
mintFee = _newFee;
}
| 2,858
|
5
|
// UpgradeabilityProxy This contract represents a proxy where the implementation address to which it will delegate can be upgraded /
|
contract UpgradeabilityProxy is Proxy {
/**
* @dev This event will be emitted every time the implementation gets upgraded
* @param implementation representing the address of the upgraded implementation
*/
event Upgraded(address indexed implementation);
/// @dev Storage position of the address of the current implementation
bytes32 private constant implementationPosition = keccak256("org.zeppelinos.proxy.implementation");
/**
* @dev Tells the address of the current implementation
* @return impl address of the current implementation
*/
function implementation() public view override returns (address impl) {
bytes32 position = implementationPosition;
assembly {
impl := sload(position)
}
}
/**
* @dev Sets the address of the current implementation
* @param _newImplementation address representing the new implementation to be set
*/
function setImplementation(address _newImplementation) internal {
bytes32 position = implementationPosition;
assembly {
sstore(position, _newImplementation)
}
}
/**
* @dev Upgrades the implementation address
* @param _newImplementation representing the address of the new implementation to be set
*/
function _upgradeTo(address _newImplementation) internal {
address currentImplementation = implementation();
require(currentImplementation != _newImplementation);
setImplementation(_newImplementation);
emit Upgraded(_newImplementation);
}
}
|
contract UpgradeabilityProxy is Proxy {
/**
* @dev This event will be emitted every time the implementation gets upgraded
* @param implementation representing the address of the upgraded implementation
*/
event Upgraded(address indexed implementation);
/// @dev Storage position of the address of the current implementation
bytes32 private constant implementationPosition = keccak256("org.zeppelinos.proxy.implementation");
/**
* @dev Tells the address of the current implementation
* @return impl address of the current implementation
*/
function implementation() public view override returns (address impl) {
bytes32 position = implementationPosition;
assembly {
impl := sload(position)
}
}
/**
* @dev Sets the address of the current implementation
* @param _newImplementation address representing the new implementation to be set
*/
function setImplementation(address _newImplementation) internal {
bytes32 position = implementationPosition;
assembly {
sstore(position, _newImplementation)
}
}
/**
* @dev Upgrades the implementation address
* @param _newImplementation representing the address of the new implementation to be set
*/
function _upgradeTo(address _newImplementation) internal {
address currentImplementation = implementation();
require(currentImplementation != _newImplementation);
setImplementation(_newImplementation);
emit Upgraded(_newImplementation);
}
}
| 27,529
|
8
|
// first check status extract the status field:
|
slResult.find("\"".toSlice()).beyond("\"".toSlice());
slResult.until(slResult.copy().find("\"".toSlice()));
bytes1 status = bytes(slResult.toString())[0]; // s = L
if (status == "C") {
|
slResult.find("\"".toSlice()).beyond("\"".toSlice());
slResult.until(slResult.copy().find("\"".toSlice()));
bytes1 status = bytes(slResult.toString())[0]; // s = L
if (status == "C") {
| 3,023
|
6
|
// view the amount of ETH spent by a user _user, address of the user /
|
function getETHSpent(address _user) external view returns (uint256);
|
function getETHSpent(address _user) external view returns (uint256);
| 6,533
|
106
|
// The logic of finalization. Internal @ Do I have to use the functionno @ When it is possible to call- @ When it is launched automaticallyafter end of round @ Who can call the function-
|
function finalization() internal {
// If the goal of the achievement
if (goalReached()) {
financialStrategy.setup(wallets[uint8(Roles.beneficiary)], weiRaised(), 0, 1);//Для контракта Buz деньги не возвращает.
// if there is anything to give
if (tokenReserved > 0) {
token.mint(wallets[uint8(Roles.accountant)],tokenReserved);
// Reset the counter
tokenReserved = 0;
}
// If the finalization is Round 1
if (TokenSale == TokenSaleType.round1) {
// Reset settings
isInitialized = false;
isFinalized = false;
// Switch to the second round (to Round2)
TokenSale = TokenSaleType.round2;
// Reset the collection counter
weiRound1 = weiRaised();
ethWeiRaised = 0;
nonEthWeiRaised = 0;
}
else // If the second round is finalized
{
// Permission to collect tokens to those who can pick them up
chargeBonuses = true;
totalSaledToken = token.totalSupply();
//partners = true;
}
}
else // If they failed round
{
financialStrategy.setup(wallets[uint8(Roles.beneficiary)], weiRaised(), 0, 3);
}
}
|
function finalization() internal {
// If the goal of the achievement
if (goalReached()) {
financialStrategy.setup(wallets[uint8(Roles.beneficiary)], weiRaised(), 0, 1);//Для контракта Buz деньги не возвращает.
// if there is anything to give
if (tokenReserved > 0) {
token.mint(wallets[uint8(Roles.accountant)],tokenReserved);
// Reset the counter
tokenReserved = 0;
}
// If the finalization is Round 1
if (TokenSale == TokenSaleType.round1) {
// Reset settings
isInitialized = false;
isFinalized = false;
// Switch to the second round (to Round2)
TokenSale = TokenSaleType.round2;
// Reset the collection counter
weiRound1 = weiRaised();
ethWeiRaised = 0;
nonEthWeiRaised = 0;
}
else // If the second round is finalized
{
// Permission to collect tokens to those who can pick them up
chargeBonuses = true;
totalSaledToken = token.totalSupply();
//partners = true;
}
}
else // If they failed round
{
financialStrategy.setup(wallets[uint8(Roles.beneficiary)], weiRaised(), 0, 3);
}
}
| 78,486
|
18
|
// balance mapping and transfer allowance array
|
mapping(address => uint256) balances;
mapping(address => mapping (address => uint256)) allowed;
event Buy(address indexed _sender, uint256 _eth, uint256 _ARX);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Burn(address _from, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
event Refund(address indexed _refunder, uint256 _value);
|
mapping(address => uint256) balances;
mapping(address => mapping (address => uint256)) allowed;
event Buy(address indexed _sender, uint256 _eth, uint256 _ARX);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Burn(address _from, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
event Refund(address indexed _refunder, uint256 _value);
| 11,993
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.