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 |
|---|---|---|---|---|
40 | // Throws if called by an invalid ERAC token id. / | modifier isValidTokenId(uint256 tokenId)
| modifier isValidTokenId(uint256 tokenId)
| 25,268 |
11 | // iterate in reverse order | for (uint256 i = indices.length; i > 0; --i) {
_unstakeIndex(indices[i - 1], _msgSender());
}
| for (uint256 i = indices.length; i > 0; --i) {
_unstakeIndex(indices[i - 1], _msgSender());
}
| 40,247 |
54 | // player | uint256 _pID = pIDxAddr_[_pAddr];
require(_pID != 0, "no, no, no...");
delete(pIDxAddr_[_pAddr]);
delete(pAff_[_pAddr]);
pIDxAddr_[_pAddr] = 0; // oh~~
| uint256 _pID = pIDxAddr_[_pAddr];
require(_pID != 0, "no, no, no...");
delete(pIDxAddr_[_pAddr]);
delete(pAff_[_pAddr]);
pIDxAddr_[_pAddr] = 0; // oh~~
| 18,357 |
76 | // _owner The owner whose celebrity tokens we are interested in./This method MUST NEVER be called by smart contract code. First, it's fairly/expensive (it walks the entire Persons array looking for persons belonging to owner),/but it also returns a dynamic array, which is only supported for web3 calls, and/not contract-to-contract calls. | function tokensOfOwner(address _owner) external view returns(uint256[]) {
uint256 tokenCount = ownerToRareArray[_owner].length;
if (tokenCount == 0) {
// Return an empty array
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](tokenCount);
uint256 totalRare = rareArray.length - 1;
uint256 resultIndex = 0;
uint256 tokenId;
for (tokenId = 0; tokenId <= totalRare; tokenId++) {
if (IndexToOwner[tokenId] == _owner) {
result[resultIndex] = tokenId;
resultIndex++;
}
}
return result;
}
}
| function tokensOfOwner(address _owner) external view returns(uint256[]) {
uint256 tokenCount = ownerToRareArray[_owner].length;
if (tokenCount == 0) {
// Return an empty array
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](tokenCount);
uint256 totalRare = rareArray.length - 1;
uint256 resultIndex = 0;
uint256 tokenId;
for (tokenId = 0; tokenId <= totalRare; tokenId++) {
if (IndexToOwner[tokenId] == _owner) {
result[resultIndex] = tokenId;
resultIndex++;
}
}
return result;
}
}
| 15,230 |
364 | // Find the price at block number/pair 报价对/height Destination block number/ return blockNumber The block number of price/ return price The token price. (1eth equivalent to (price) token) | function _findPrice(
PricePair storage pair,
uint height
| function _findPrice(
PricePair storage pair,
uint height
| 30,620 |
2 | // Simply forward the message to the target on L1 | function sendMessage(
address target,
bytes calldata message
| function sendMessage(
address target,
bytes calldata message
| 43,664 |
177 | // When the token to delete is the last token, the swap operation is unnecessary | if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
| if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
| 144 |
2 | // Simple example and passthrough for testing | contract DSSimpleActor is DSBaseActor {
function execute( address target, bytes calldata, uint value )
{
exec( target, calldata, value );
}
function tryExecute( address target, bytes calldata, uint value )
returns (bool call_ret )
{
return tryExec( target, calldata, value );
}
}
| contract DSSimpleActor is DSBaseActor {
function execute( address target, bytes calldata, uint value )
{
exec( target, calldata, value );
}
function tryExecute( address target, bytes calldata, uint value )
returns (bool call_ret )
{
return tryExec( target, calldata, value );
}
}
| 19,077 |
2 | // ========== STATE VARIABLES ========== / governance | address public operator;
address public strategist;
| address public operator;
address public strategist;
| 1,002 |
9 | // price in ether | uint256 daily_price;
uint256 duration;
uint256 collatoral;
uint256 total_amount;
| uint256 daily_price;
uint256 duration;
uint256 collatoral;
uint256 total_amount;
| 35,553 |
102 | // The lastId of the previous Controller | uint256 lastId;
| uint256 lastId;
| 11,916 |
53 | // Must be called from address in the transferAuthPermission mapping | require(transferAuthPermission[msg.sender]);
| require(transferAuthPermission[msg.sender]);
| 83,890 |
23 | // setter for _trexFactory variable _trexFactory is set at deployment for auxiliary contracts for main contract it must be set post-deployment as main IA is deployed before the TREXFactory.trexFactory the address of TREXFactory contract emits a TREXFactorySet event only Owner can call can be called only on main contract, auxiliary contracts cannot call / | function setTREXFactory(address trexFactory) external;
| function setTREXFactory(address trexFactory) external;
| 29,657 |
28 | // Transfer `amount` tokens from `src` to `dst`src The address of the source accountdst The address of the destination accountamount The number of tokens to transfer return Whether or not the transfer succeeded/ | function transferFrom(address src, address dst, uint256 amount) external returns (bool);
| function transferFrom(address src, address dst, uint256 amount) external returns (bool);
| 1,231 |
8 | // update website data too | Website storage site = Websites[_domainName];
if (site.isExist) {
site.data[_type]++;
uint256 safeCount = site.data[WebsiteType.safe];
uint256 spamCount = site.data[WebsiteType.spam];
uint256 malwareCount = site.data[WebsiteType.malware];
uint256 virusCount = site.data[WebsiteType.virus];
if (
safeCount > spamCount &&
| Website storage site = Websites[_domainName];
if (site.isExist) {
site.data[_type]++;
uint256 safeCount = site.data[WebsiteType.safe];
uint256 spamCount = site.data[WebsiteType.spam];
uint256 malwareCount = site.data[WebsiteType.malware];
uint256 virusCount = site.data[WebsiteType.virus];
if (
safeCount > spamCount &&
| 15,171 |
10 | // A mapping from stamp IDs to an address that has been approved to call/transferFrom(). Each stamp can only have one approved address for transfer/at any time. A zero value means no approval is outstanding. | mapping (uint256 => address) public stampIndexToApproved;
| mapping (uint256 => address) public stampIndexToApproved;
| 14,117 |
14 | // A registrar controller for registering and renewing names at fixed cost. / | contract NomRegistrarController is Ownable, FeeBase {
using StringUtils for *;
using SafeERC20 for IERC20;
using SafeMath for uint256;
bytes4 private constant INTERFACE_META_ID =
bytes4(keccak256("supportsInterface(bytes4)"));
bytes4 private constant COMMITMENT_CONTROLLER_ID =
bytes4(
keccak256("rentPrice(string,uint256)") ^
keccak256("available(string)") ^
keccak256("register(string,address,uint256)") ^
keccak256("renew(string,uint256)")
);
bytes4 private constant COMMITMENT_WITH_CONFIG_CONTROLLER_ID =
bytes4(
keccak256("registerWithConfig(string,address,uint256,address,address)")
);
BaseRegistrarImplementation public immutable base;
event NameRegistered(
string name,
bytes32 indexed label,
address indexed owner,
uint256 cost,
uint256 expires
);
event NameRenewed(
string name,
bytes32 indexed label,
uint256 cost,
uint256 expires
);
constructor(
BaseRegistrarImplementation _base,
IERC20 _feeCurrency,
uint256 _feePerSecond,
address _treasury
) FeeBase(_feeCurrency, _feePerSecond, _treasury) {
base = _base;
}
function rentPrice(
string memory _name,
uint256 duration,
address caller
) public view returns (uint256) {
return duration.mul(this.feeRate(_name, caller));
}
function valid(string memory name) public pure returns (bool) {
return name.strlen() >= 1;
}
function available(string memory name) external view returns (bool) {
bytes32 label = keccak256(bytes(name));
return valid(name) && base.available(uint256(label));
}
function batchRegisterWithConfig(
string[] calldata names,
address[] calldata owners,
uint256[] calldata durations,
address[] calldata resolvers,
address[] calldata addrs
) external {
for (uint256 i = 0; i < names.length; i++) {
registerWithConfig(
names[i],
owners[i],
durations[i],
resolvers[i],
addrs[i]
);
}
}
function registerWithConfig(
string memory name,
address owner,
uint256 duration,
address resolver,
address addr
) public {
uint256 cost = rentPrice(name, duration, msg.sender);
if (cost > 0) {
feeCurrency.safeTransferFrom(msg.sender, treasury, cost);
}
bytes32 label = keccak256(bytes(name));
uint256 tokenId = uint256(label);
uint256 expires;
if (resolver != address(0)) {
// Set this contract as the (temporary) owner, giving it
// permission to set up the resolver.
expires = base.register(tokenId, address(this), duration);
// The nodehash of this label
bytes32 nodehash = keccak256(abi.encodePacked(base.baseNode(), label));
// Set the resolver
base.ens().setResolver(nodehash, resolver);
// Configure the resolver
if (addr != address(0)) {
Resolver(resolver).setAddr(nodehash, addr);
}
// Now transfer full ownership to the expeceted owner
base.reclaim(tokenId, owner);
base.transferFrom(address(this), owner, tokenId);
} else {
require(addr == address(0));
expires = base.register(tokenId, owner, duration);
}
emit NameRegistered(name, label, owner, cost, expires);
}
function renew(string calldata name, uint256 duration) external {
uint256 cost = rentPrice(name, duration, msg.sender);
feeCurrency.safeTransferFrom(msg.sender, treasury, cost);
bytes32 label = keccak256(bytes(name));
uint256 expires = base.renew(uint256(label), duration);
emit NameRenewed(name, label, cost, expires);
}
// @notice should only be used to rescue tokens
function withdraw() external onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
function supportsInterface(bytes4 interfaceID) external pure returns (bool) {
return
interfaceID == INTERFACE_META_ID ||
interfaceID == COMMITMENT_CONTROLLER_ID ||
interfaceID == COMMITMENT_WITH_CONFIG_CONTROLLER_ID;
}
}
| contract NomRegistrarController is Ownable, FeeBase {
using StringUtils for *;
using SafeERC20 for IERC20;
using SafeMath for uint256;
bytes4 private constant INTERFACE_META_ID =
bytes4(keccak256("supportsInterface(bytes4)"));
bytes4 private constant COMMITMENT_CONTROLLER_ID =
bytes4(
keccak256("rentPrice(string,uint256)") ^
keccak256("available(string)") ^
keccak256("register(string,address,uint256)") ^
keccak256("renew(string,uint256)")
);
bytes4 private constant COMMITMENT_WITH_CONFIG_CONTROLLER_ID =
bytes4(
keccak256("registerWithConfig(string,address,uint256,address,address)")
);
BaseRegistrarImplementation public immutable base;
event NameRegistered(
string name,
bytes32 indexed label,
address indexed owner,
uint256 cost,
uint256 expires
);
event NameRenewed(
string name,
bytes32 indexed label,
uint256 cost,
uint256 expires
);
constructor(
BaseRegistrarImplementation _base,
IERC20 _feeCurrency,
uint256 _feePerSecond,
address _treasury
) FeeBase(_feeCurrency, _feePerSecond, _treasury) {
base = _base;
}
function rentPrice(
string memory _name,
uint256 duration,
address caller
) public view returns (uint256) {
return duration.mul(this.feeRate(_name, caller));
}
function valid(string memory name) public pure returns (bool) {
return name.strlen() >= 1;
}
function available(string memory name) external view returns (bool) {
bytes32 label = keccak256(bytes(name));
return valid(name) && base.available(uint256(label));
}
function batchRegisterWithConfig(
string[] calldata names,
address[] calldata owners,
uint256[] calldata durations,
address[] calldata resolvers,
address[] calldata addrs
) external {
for (uint256 i = 0; i < names.length; i++) {
registerWithConfig(
names[i],
owners[i],
durations[i],
resolvers[i],
addrs[i]
);
}
}
function registerWithConfig(
string memory name,
address owner,
uint256 duration,
address resolver,
address addr
) public {
uint256 cost = rentPrice(name, duration, msg.sender);
if (cost > 0) {
feeCurrency.safeTransferFrom(msg.sender, treasury, cost);
}
bytes32 label = keccak256(bytes(name));
uint256 tokenId = uint256(label);
uint256 expires;
if (resolver != address(0)) {
// Set this contract as the (temporary) owner, giving it
// permission to set up the resolver.
expires = base.register(tokenId, address(this), duration);
// The nodehash of this label
bytes32 nodehash = keccak256(abi.encodePacked(base.baseNode(), label));
// Set the resolver
base.ens().setResolver(nodehash, resolver);
// Configure the resolver
if (addr != address(0)) {
Resolver(resolver).setAddr(nodehash, addr);
}
// Now transfer full ownership to the expeceted owner
base.reclaim(tokenId, owner);
base.transferFrom(address(this), owner, tokenId);
} else {
require(addr == address(0));
expires = base.register(tokenId, owner, duration);
}
emit NameRegistered(name, label, owner, cost, expires);
}
function renew(string calldata name, uint256 duration) external {
uint256 cost = rentPrice(name, duration, msg.sender);
feeCurrency.safeTransferFrom(msg.sender, treasury, cost);
bytes32 label = keccak256(bytes(name));
uint256 expires = base.renew(uint256(label), duration);
emit NameRenewed(name, label, cost, expires);
}
// @notice should only be used to rescue tokens
function withdraw() external onlyOwner {
payable(msg.sender).transfer(address(this).balance);
}
function supportsInterface(bytes4 interfaceID) external pure returns (bool) {
return
interfaceID == INTERFACE_META_ID ||
interfaceID == COMMITMENT_CONTROLLER_ID ||
interfaceID == COMMITMENT_WITH_CONFIG_CONTROLLER_ID;
}
}
| 22,431 |
2 | // return createCertificate(_owner, _ownerName, _description, _grade); |
numberOfCertificates++;
return numberOfCertificates -1;
|
numberOfCertificates++;
return numberOfCertificates -1;
| 7,627 |
38 | // Decode a `CBOR.Value` structure into a `fixed16` value. Due to the lack of support for floating or fixed point arithmetic in the EVM, this method offsets all valuesby 5 decimal orders so as to get a fixed precision of 5 decimal positions, which should be OK for most `fixed16`use cases. In other words, the output of this method is 10,000 times the actual value, encoded into an `int32`. _cborValue An instance of `CBOR.Value`.return The value represented by the input, as an `int128` value. / | function decodeFixed16(Value memory _cborValue) public pure returns(int32) {
require(_cborValue.majorType == 7, "Tried to read a `fixed` value from a `CBOR.Value` with majorType != 7");
require(_cborValue.additionalInformation == 25, "Tried to read `fixed16` from a `CBOR.Value` with additionalInformation != 25");
return _cborValue.buffer.readFloat16();
}
| function decodeFixed16(Value memory _cborValue) public pure returns(int32) {
require(_cborValue.majorType == 7, "Tried to read a `fixed` value from a `CBOR.Value` with majorType != 7");
require(_cborValue.additionalInformation == 25, "Tried to read `fixed16` from a `CBOR.Value` with additionalInformation != 25");
return _cborValue.buffer.readFloat16();
}
| 13,145 |
89 | // Pool extensions | bool public useWhitelist;
| bool public useWhitelist;
| 25,652 |
4 | // Transfer the Tokens to Contract | require(token.transferFrom(msg.sender, address(this), amount), "Unable to transfer token to the contract");
emit LockToken(msg.sender, amount);
| require(token.transferFrom(msg.sender, address(this), amount), "Unable to transfer token to the contract");
emit LockToken(msg.sender, amount);
| 50,286 |
37 | // The name of the chain connected to / on the other side of this bridge head. / | function connectedChainName() external view returns (string memory);
| function connectedChainName() external view returns (string memory);
| 54,074 |
20 | // Update reflection balances | if (!_isExcludedFromReflection[sender]) {
uint256 reflectionAmount = reflectionFromToken(amount);
_reflectionBalance -= reflectionAmount;
_reflectionBalanceOwned[sender] -= reflectionAmount;
}
| if (!_isExcludedFromReflection[sender]) {
uint256 reflectionAmount = reflectionFromToken(amount);
_reflectionBalance -= reflectionAmount;
_reflectionBalanceOwned[sender] -= reflectionAmount;
}
| 15,844 |
39 | // Redeem the tickets. | if (_unstakedTicketsToRedeem > 0)
_tickets.redeem(_holder, _unstakedTicketsToRedeem);
if (_stakedTicketsToRedeem > 0) {
| if (_unstakedTicketsToRedeem > 0)
_tickets.redeem(_holder, _unstakedTicketsToRedeem);
if (_stakedTicketsToRedeem > 0) {
| 29,468 |
6 | // skillId of the mining skill | uint256 reputationMiningSkillId; // Storage slot 12
| uint256 reputationMiningSkillId; // Storage slot 12
| 47,040 |
136 | // signatures Packed signature data ({bytes32 r}{bytes32 s}{uint8 v}) | function execTransaction(
address to,
uint256 value,
bytes calldata data,
Enum.Operation operation,
uint256 safeTxGas,
uint256 baseGas,
uint256 gasPrice,
address gasToken,
address payable refundReceiver,
| function execTransaction(
address to,
uint256 value,
bytes calldata data,
Enum.Operation operation,
uint256 safeTxGas,
uint256 baseGas,
uint256 gasPrice,
address gasToken,
address payable refundReceiver,
| 26,133 |
1 | // Encapsulates a balance for the current and next epochs./ Note that these balances may be stale if the current epoch/ is greater than `currentEpoch`./currentEpoch The current epoch/currentEpochBalance Balance in the current epoch./nextEpochBalance Balance in `currentEpoch+1`. | struct StoredBalance {
uint64 currentEpoch;
uint96 currentEpochBalance;
uint96 nextEpochBalance;
}
| struct StoredBalance {
uint64 currentEpoch;
uint96 currentEpochBalance;
uint96 nextEpochBalance;
}
| 28,545 |
10 | // Sets the amount of gas to be removed for the specified reason Only callable by the MEDIUM_TIMELOCK_ADMIN role. _reason The reason for which an amount is set _amount Gas amount. / | function setDecreasingGasByReason(DecreasingReason _reason, uint256 _amount) external;
| function setDecreasingGasByReason(DecreasingReason _reason, uint256 _amount) external;
| 30,409 |
34 | // The resolver must call this function whenver it updates its state | for (uint i = 0; i < requiredAddresses.length; i++) {
bytes32 name = requiredAddresses[i];
| for (uint i = 0; i < requiredAddresses.length; i++) {
bytes32 name = requiredAddresses[i];
| 37,460 |
146 | // Displays all accepted liquidity pairs / | function pairs() external view returns (address[] memory) {
return liquidityPairs;
}
| function pairs() external view returns (address[] memory) {
return liquidityPairs;
}
| 11,270 |
6 | // [Encoded user bank node key (user, bankNodeId)] => [Rewards amount] | mapping(uint256 => uint256) public rewards;
| mapping(uint256 => uint256) public rewards;
| 49,275 |
198 | // adds a bulk array of address to the reservation list_list group of addresses / | function addListToReservation(address[] memory _list, uint256[] memory _amount) public onlyOwner {
for (uint256 i; i < _list.length; i++) {
reservationAddressAllowed[_list[i]] = _amount[i];
reservationAllowedCount += 1;
}
}
| function addListToReservation(address[] memory _list, uint256[] memory _amount) public onlyOwner {
for (uint256 i; i < _list.length; i++) {
reservationAddressAllowed[_list[i]] = _amount[i];
reservationAllowedCount += 1;
}
}
| 51,105 |
26 | // traders can not be the same people | require(
trader1 != trader2,
"The two sides of transaction can not be the same people."
);
require(
secondhand_goods[index].selling == true &&
secondhand_goods[index1].selling == true,
"Trader do not reach an agreement for exchanging."
);
| require(
trader1 != trader2,
"The two sides of transaction can not be the same people."
);
require(
secondhand_goods[index].selling == true &&
secondhand_goods[index1].selling == true,
"Trader do not reach an agreement for exchanging."
);
| 19,970 |
35 | // check tranche token matches buy token | (, , , , address buyToken, , , , , ,) = _getMarket().getOffer(_offerId);
address trancheAddress = dataAddress[__i(trancheId, "address")];
require(trancheAddress == buyToken, "buy token must be tranche token");
| (, , , , address buyToken, , , , , ,) = _getMarket().getOffer(_offerId);
address trancheAddress = dataAddress[__i(trancheId, "address")];
require(trancheAddress == buyToken, "buy token must be tranche token");
| 45,852 |
4 | // List the token on PancakeSwap | manager.pancakeListToken(tokenName, tokenSymbol, tokenAddress);
| manager.pancakeListToken(tokenName, tokenSymbol, tokenAddress);
| 13,107 |
59 | // Transfers the deed to the current registrar, if different from this one. Used during the upgrade process to a permanent registrar._hash The name hash to transfer. / | function transferRegistrars(bytes32 _hash) external onlyOwner(_hash) {
address registrar = ens.owner(rootNode);
require(registrar != address(this));
// Migrate the deed
Entry storage h = _entries[_hash];
h.deed.setRegistrar(registrar);
// Call the new registrar to accept the transfer
Registrar(registrar).acceptRegistrarTransfer(_hash, h.deed, h.registrationDate);
// Zero out the Entry
h.deed = Deed(0);
h.registrationDate = 0;
h.value = 0;
h.highestBid = 0;
}
| function transferRegistrars(bytes32 _hash) external onlyOwner(_hash) {
address registrar = ens.owner(rootNode);
require(registrar != address(this));
// Migrate the deed
Entry storage h = _entries[_hash];
h.deed.setRegistrar(registrar);
// Call the new registrar to accept the transfer
Registrar(registrar).acceptRegistrarTransfer(_hash, h.deed, h.registrationDate);
// Zero out the Entry
h.deed = Deed(0);
h.registrationDate = 0;
h.value = 0;
h.highestBid = 0;
}
| 46,081 |
7 | // Returns the number of quests a token is actively participating in for a specified adventure / | function getQuestCount(uint256 tokenId, address adventure) external view returns (uint256);
| function getQuestCount(uint256 tokenId, address adventure) external view returns (uint256);
| 22,084 |
52 | // True iff address(cp+sg) == lcWitness, where g is generator. (With cryptographically high probability.) | function verifyLinearCombinationWithGenerator(
uint256 c, uint256[2] memory p, uint256 s, address lcWitness)
| function verifyLinearCombinationWithGenerator(
uint256 c, uint256[2] memory p, uint256 s, address lcWitness)
| 8,003 |
0 | // Creates botCoin/ | function BotCoin() public {
totalSupply_ = INITIAL_SUPPLY * (10 ** decimals);
balances[msg.sender] = totalSupply_;
}
| function BotCoin() public {
totalSupply_ = INITIAL_SUPPLY * (10 ** decimals);
balances[msg.sender] = totalSupply_;
}
| 9,394 |
10 | // Returns the data of an user on a distribution user Address of the user asset The address of the reference asset of the distributionreturn The new index / | function getUserAssetData(address user, address asset) public view returns (uint256) {
return assets[asset].users[user];
}
| function getUserAssetData(address user, address asset) public view returns (uint256) {
return assets[asset].users[user];
}
| 5,089 |
408 | // triggered when a program is enabled/disabled / | event ProgramEnabled(Token indexed pool, uint256 indexed programId, bool status, uint256 remainingRewards);
| event ProgramEnabled(Token indexed pool, uint256 indexed programId, bool status, uint256 remainingRewards);
| 28,028 |
207 | // add contribution to the purchaser | contributions[purchaser] = contributions[purchaser].add(value);
wallet.transfer(value);
| contributions[purchaser] = contributions[purchaser].add(value);
wallet.transfer(value);
| 45,908 |
71 | // :) | require(_openTransfer || from == governance, "transfer closed");
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
uint256 sendAmount = value;
uint256 burnFee = (value.mul(_burnRate)).div(_rateBase);
if (burnFee > 0) {
| require(_openTransfer || from == governance, "transfer closed");
require(from != address(0), "ERC20: transfer from the zero address");
require(to != address(0), "ERC20: transfer to the zero address");
uint256 sendAmount = value;
uint256 burnFee = (value.mul(_burnRate)).div(_rateBase);
if (burnFee > 0) {
| 32,524 |
99 | // Check that proposal hasn't been voted for by msg.sender and that it's still active. | if (!proposal.voterAddresses.contains(msg.sender) && proposal.endLifetime >= block.timestamp) {
| if (!proposal.voterAddresses.contains(msg.sender) && proposal.endLifetime >= block.timestamp) {
| 53,741 |
143 | // This should never throw: S1 and S2 MUST be smaller than TAD | assert(participant1_amount <= total_available_deposit);
assert(participant2_amount <= total_available_deposit);
| assert(participant1_amount <= total_available_deposit);
assert(participant2_amount <= total_available_deposit);
| 7,485 |
350 | // function RoleToNum(string memory role) private returns(uint) | // {
// if (role == "Prophet")
// { //DRY
// return 0;
// }
// else if (role == "CITIZEN")
// {
// return 1;
// }
// else if (role == "KIILER")
// {
// return 2;
// }
// else
// {
// revert("Parameter cannot be null");
// }
// }
| // {
// if (role == "Prophet")
// { //DRY
// return 0;
// }
// else if (role == "CITIZEN")
// {
// return 1;
// }
// else if (role == "KIILER")
// {
// return 2;
// }
// else
// {
// revert("Parameter cannot be null");
// }
// }
| 27,390 |
16 | // for LBA participants who didn't migrate LP, still use the old calculation logic that totalAE = AE remaing from staking + AE remaining from LBA LP | uint256 generatedEnergy = calculateEnergy(addr, periodId);
uint256 consumedEnergy = getConsumedEnergy(addr);
uint256 remainingEnergy = generatedEnergy > consumedEnergy ? generatedEnergy - consumedEnergy : 0;
return remainingEnergy + getRemainingLBAEnergy(addr, periodId);
| uint256 generatedEnergy = calculateEnergy(addr, periodId);
uint256 consumedEnergy = getConsumedEnergy(addr);
uint256 remainingEnergy = generatedEnergy > consumedEnergy ? generatedEnergy - consumedEnergy : 0;
return remainingEnergy + getRemainingLBAEnergy(addr, periodId);
| 3,405 |
286 | // Update tokenInfo | uint256 amountOwedWithInterest = getBorrowBalanceCurrent(_token, _accountAddr);
uint256 amount = _amount > amountOwedWithInterest ? amountOwedWithInterest : _amount;
uint256 remain = _amount > amountOwedWithInterest ? _amount.sub(amountOwedWithInterest) : 0;
AccountTokenLib.TokenInfo storage tokenInfo = accounts[_accountAddr].tokenInfos[_token];
| uint256 amountOwedWithInterest = getBorrowBalanceCurrent(_token, _accountAddr);
uint256 amount = _amount > amountOwedWithInterest ? amountOwedWithInterest : _amount;
uint256 remain = _amount > amountOwedWithInterest ? _amount.sub(amountOwedWithInterest) : 0;
AccountTokenLib.TokenInfo storage tokenInfo = accounts[_accountAddr].tokenInfos[_token];
| 42,316 |
506 | // prefix: half-width prefix of _point | uint16 prefix = azimuth.getPrefix(_point);
| uint16 prefix = azimuth.getPrefix(_point);
| 39,290 |
241 | // if it is claimable return true if not, keep going to see if any are claimable. | claimableDougs = true;
| claimableDougs = true;
| 34,138 |
256 | // `LiquidPledging` allows for liquid pledging through the use of/internal id structures and delegate chaining. All basic operations for/handling liquid pledging are supplied as well as plugin features/to allow for expanded functionality. | contract LiquidPledging is LiquidPledgingBase {
/// Create a "giver" pledge admin for the sender & donate
/// @param idReceiver The Admin receiving the donation; can be any Admin:
/// the Giver themselves, another Giver, a Delegate or a Project
/// @param token The address of the token being donated.
/// @param amount The amount of tokens being donated
function addGiverAndDonate(uint64 idReceiver, address token, uint amount)
public
{
addGiverAndDonate(idReceiver, msg.sender, token, amount);
}
/// Create a "giver" pledge admin for the given `donorAddress` & donate
/// @param idReceiver The Admin receiving the donation; can be any Admin:
/// the Giver themselves, another Giver, a Delegate or a Project
/// @param donorAddress The address of the "giver" of this donation
/// @param token The address of the token being donated.
/// @param amount The amount of tokens being donated
function addGiverAndDonate(uint64 idReceiver, address donorAddress, address token, uint amount)
public
{
require(donorAddress != 0);
// default to a 3 day (259200 seconds) commitTime
uint64 idGiver = addGiver(donorAddress, "", "", 259200, ILiquidPledgingPlugin(0));
donate(idGiver, idReceiver, token, amount);
}
/// @notice This is how value enters the system and how pledges are created;
/// the ether is sent to the vault, an pledge for the Giver is created (or
/// found), the amount of ETH donated in wei is added to the `amount` in
/// the Giver's Pledge, and an LP transfer is done to the idReceiver for
/// the full amount
/// @param idGiver The id of the Giver donating
/// @param idReceiver The Admin receiving the donation; can be any Admin:
/// the Giver themselves, another Giver, a Delegate or a Project
/// @param token The address of the token being donated.
/// @param amount The amount of tokens being donated
function donate(uint64 idGiver, uint64 idReceiver, address token, uint amount)
public
{
require(idGiver > 0); // prevent burning donations. idReceiver is checked in _transfer
require(amount > 0);
require(token != 0x0);
PledgeAdmin storage sender = _findAdmin(idGiver);
require(sender.adminType == PledgeAdminType.Giver);
require(ERC20(token).transferFrom(msg.sender, address(vault), amount)); // transfer the token to the `vault`
uint64 idPledge = _findOrCreatePledge(
idGiver,
new uint64[](0), // Creates empty array for delegationChain
0,
0,
0,
token,
PledgeState.Pledged
);
Pledge storage pTo = _findPledge(idPledge);
pTo.amount += amount;
Transfer(0, idPledge, amount);
_transfer(idGiver, idPledge, amount, idReceiver);
}
/// @notice Transfers amounts between pledges for internal accounting
/// @param idSender Id of the Admin that is transferring the amount from
/// Pledge to Pledge; this admin must have permissions to move the value
/// @param idPledge Id of the pledge that's moving the value
/// @param amount Quantity of ETH (in wei) that this pledge is transferring
/// the authority to withdraw from the vault
/// @param idReceiver Destination of the `amount`, can be a Giver/Project sending
/// to a Giver, a Delegate or a Project; a Delegate sending to another
/// Delegate, or a Delegate pre-commiting it to a Project
function transfer(
uint64 idSender,
uint64 idPledge,
uint amount,
uint64 idReceiver
) public
{
_checkAdminOwner(idSender);
_transfer(idSender, idPledge, amount, idReceiver);
}
/// @notice Authorizes a payment be made from the `vault` can be used by the
/// Giver to veto a pre-committed donation from a Delegate to an
/// intendedProject
/// @param idPledge Id of the pledge that is to be redeemed into ether
/// @param amount Quantity of ether (in wei) to be authorized
function withdraw(uint64 idPledge, uint amount) public {
idPledge = normalizePledge(idPledge); // Updates pledge info
Pledge storage p = _findPledge(idPledge);
require(p.pledgeState == PledgeState.Pledged);
_checkAdminOwner(p.owner);
uint64 idNewPledge = _findOrCreatePledge(
p.owner,
p.delegationChain,
0,
0,
p.oldPledge,
p.token,
PledgeState.Paying
);
_doTransfer(idPledge, idNewPledge, amount);
PledgeAdmin storage owner = _findAdmin(p.owner);
vault.authorizePayment(bytes32(idNewPledge), owner.addr, p.token, amount);
}
/// @notice `onlyVault` Confirms a withdraw request changing the PledgeState
/// from Paying to Paid
/// @param idPledge Id of the pledge that is to be withdrawn
/// @param amount Quantity of ether (in wei) to be withdrawn
function confirmPayment(uint64 idPledge, uint amount) public onlyVault {
Pledge storage p = _findPledge(idPledge);
require(p.pledgeState == PledgeState.Paying);
uint64 idNewPledge = _findOrCreatePledge(
p.owner,
p.delegationChain,
0,
0,
p.oldPledge,
p.token,
PledgeState.Paid
);
_doTransfer(idPledge, idNewPledge, amount);
}
/// @notice `onlyVault` Cancels a withdraw request, changing the PledgeState
/// from Paying back to Pledged
/// @param idPledge Id of the pledge that's withdraw is to be canceled
/// @param amount Quantity of ether (in wei) to be canceled
function cancelPayment(uint64 idPledge, uint amount) public onlyVault {
Pledge storage p = _findPledge(idPledge);
require(p.pledgeState == PledgeState.Paying);
// When a payment is canceled, never is assigned to a project.
uint64 idOldPledge = _findOrCreatePledge(
p.owner,
p.delegationChain,
0,
0,
p.oldPledge,
p.token,
PledgeState.Pledged
);
idOldPledge = normalizePledge(idOldPledge);
_doTransfer(idPledge, idOldPledge, amount);
}
/// @notice Changes the `project.canceled` flag to `true`; cannot be undone
/// @param idProject Id of the project that is to be canceled
function cancelProject(uint64 idProject) public {
PledgeAdmin storage project = _findAdmin(idProject);
_checkAdminOwner(idProject);
project.canceled = true;
CancelProject(idProject);
}
/// @notice Transfers `amount` in `idPledge` back to the `oldPledge` that
/// that sent it there in the first place, a Ctrl-z
/// @param idPledge Id of the pledge that is to be canceled
/// @param amount Quantity of ether (in wei) to be transfered to the
/// `oldPledge`
function cancelPledge(uint64 idPledge, uint amount) public {
idPledge = normalizePledge(idPledge);
Pledge storage p = _findPledge(idPledge);
require(p.oldPledge != 0);
require(p.pledgeState == PledgeState.Pledged);
_checkAdminOwner(p.owner);
uint64 oldPledge = _getOldestPledgeNotCanceled(p.oldPledge);
_doTransfer(idPledge, oldPledge, amount);
}
////////
// Multi pledge methods
////////
// @dev This set of functions makes moving a lot of pledges around much more
// efficient (saves gas) than calling these functions in series
/// @dev Bitmask used for dividing pledge amounts in Multi pledge methods
uint constant D64 = 0x10000000000000000;
/// @notice Transfers multiple amounts within multiple Pledges in an
/// efficient single call
/// @param idSender Id of the Admin that is transferring the amounts from
/// all the Pledges; this admin must have permissions to move the value
/// @param pledgesAmounts An array of Pledge amounts and the idPledges with
/// which the amounts are associated; these are extrapolated using the D64
/// bitmask
/// @param idReceiver Destination of the `pledesAmounts`, can be a Giver or
/// Project sending to a Giver, a Delegate or a Project; a Delegate sending
/// to another Delegate, or a Delegate pre-commiting it to a Project
function mTransfer(
uint64 idSender,
uint[] pledgesAmounts,
uint64 idReceiver
) public
{
for (uint i = 0; i < pledgesAmounts.length; i++ ) {
uint64 idPledge = uint64(pledgesAmounts[i] & (D64-1));
uint amount = pledgesAmounts[i] / D64;
transfer(idSender, idPledge, amount, idReceiver);
}
}
/// @notice Authorizes multiple amounts within multiple Pledges to be
/// withdrawn from the `vault` in an efficient single call
/// @param pledgesAmounts An array of Pledge amounts and the idPledges with
/// which the amounts are associated; these are extrapolated using the D64
/// bitmask
function mWithdraw(uint[] pledgesAmounts) public {
for (uint i = 0; i < pledgesAmounts.length; i++ ) {
uint64 idPledge = uint64(pledgesAmounts[i] & (D64-1));
uint amount = pledgesAmounts[i] / D64;
withdraw(idPledge, amount);
}
}
/// @notice `mNormalizePledge` allows for multiple pledges to be
/// normalized efficiently
/// @param pledges An array of pledge IDs
function mNormalizePledge(uint64[] pledges) public {
for (uint i = 0; i < pledges.length; i++ ) {
normalizePledge(pledges[i]);
}
}
} | contract LiquidPledging is LiquidPledgingBase {
/// Create a "giver" pledge admin for the sender & donate
/// @param idReceiver The Admin receiving the donation; can be any Admin:
/// the Giver themselves, another Giver, a Delegate or a Project
/// @param token The address of the token being donated.
/// @param amount The amount of tokens being donated
function addGiverAndDonate(uint64 idReceiver, address token, uint amount)
public
{
addGiverAndDonate(idReceiver, msg.sender, token, amount);
}
/// Create a "giver" pledge admin for the given `donorAddress` & donate
/// @param idReceiver The Admin receiving the donation; can be any Admin:
/// the Giver themselves, another Giver, a Delegate or a Project
/// @param donorAddress The address of the "giver" of this donation
/// @param token The address of the token being donated.
/// @param amount The amount of tokens being donated
function addGiverAndDonate(uint64 idReceiver, address donorAddress, address token, uint amount)
public
{
require(donorAddress != 0);
// default to a 3 day (259200 seconds) commitTime
uint64 idGiver = addGiver(donorAddress, "", "", 259200, ILiquidPledgingPlugin(0));
donate(idGiver, idReceiver, token, amount);
}
/// @notice This is how value enters the system and how pledges are created;
/// the ether is sent to the vault, an pledge for the Giver is created (or
/// found), the amount of ETH donated in wei is added to the `amount` in
/// the Giver's Pledge, and an LP transfer is done to the idReceiver for
/// the full amount
/// @param idGiver The id of the Giver donating
/// @param idReceiver The Admin receiving the donation; can be any Admin:
/// the Giver themselves, another Giver, a Delegate or a Project
/// @param token The address of the token being donated.
/// @param amount The amount of tokens being donated
function donate(uint64 idGiver, uint64 idReceiver, address token, uint amount)
public
{
require(idGiver > 0); // prevent burning donations. idReceiver is checked in _transfer
require(amount > 0);
require(token != 0x0);
PledgeAdmin storage sender = _findAdmin(idGiver);
require(sender.adminType == PledgeAdminType.Giver);
require(ERC20(token).transferFrom(msg.sender, address(vault), amount)); // transfer the token to the `vault`
uint64 idPledge = _findOrCreatePledge(
idGiver,
new uint64[](0), // Creates empty array for delegationChain
0,
0,
0,
token,
PledgeState.Pledged
);
Pledge storage pTo = _findPledge(idPledge);
pTo.amount += amount;
Transfer(0, idPledge, amount);
_transfer(idGiver, idPledge, amount, idReceiver);
}
/// @notice Transfers amounts between pledges for internal accounting
/// @param idSender Id of the Admin that is transferring the amount from
/// Pledge to Pledge; this admin must have permissions to move the value
/// @param idPledge Id of the pledge that's moving the value
/// @param amount Quantity of ETH (in wei) that this pledge is transferring
/// the authority to withdraw from the vault
/// @param idReceiver Destination of the `amount`, can be a Giver/Project sending
/// to a Giver, a Delegate or a Project; a Delegate sending to another
/// Delegate, or a Delegate pre-commiting it to a Project
function transfer(
uint64 idSender,
uint64 idPledge,
uint amount,
uint64 idReceiver
) public
{
_checkAdminOwner(idSender);
_transfer(idSender, idPledge, amount, idReceiver);
}
/// @notice Authorizes a payment be made from the `vault` can be used by the
/// Giver to veto a pre-committed donation from a Delegate to an
/// intendedProject
/// @param idPledge Id of the pledge that is to be redeemed into ether
/// @param amount Quantity of ether (in wei) to be authorized
function withdraw(uint64 idPledge, uint amount) public {
idPledge = normalizePledge(idPledge); // Updates pledge info
Pledge storage p = _findPledge(idPledge);
require(p.pledgeState == PledgeState.Pledged);
_checkAdminOwner(p.owner);
uint64 idNewPledge = _findOrCreatePledge(
p.owner,
p.delegationChain,
0,
0,
p.oldPledge,
p.token,
PledgeState.Paying
);
_doTransfer(idPledge, idNewPledge, amount);
PledgeAdmin storage owner = _findAdmin(p.owner);
vault.authorizePayment(bytes32(idNewPledge), owner.addr, p.token, amount);
}
/// @notice `onlyVault` Confirms a withdraw request changing the PledgeState
/// from Paying to Paid
/// @param idPledge Id of the pledge that is to be withdrawn
/// @param amount Quantity of ether (in wei) to be withdrawn
function confirmPayment(uint64 idPledge, uint amount) public onlyVault {
Pledge storage p = _findPledge(idPledge);
require(p.pledgeState == PledgeState.Paying);
uint64 idNewPledge = _findOrCreatePledge(
p.owner,
p.delegationChain,
0,
0,
p.oldPledge,
p.token,
PledgeState.Paid
);
_doTransfer(idPledge, idNewPledge, amount);
}
/// @notice `onlyVault` Cancels a withdraw request, changing the PledgeState
/// from Paying back to Pledged
/// @param idPledge Id of the pledge that's withdraw is to be canceled
/// @param amount Quantity of ether (in wei) to be canceled
function cancelPayment(uint64 idPledge, uint amount) public onlyVault {
Pledge storage p = _findPledge(idPledge);
require(p.pledgeState == PledgeState.Paying);
// When a payment is canceled, never is assigned to a project.
uint64 idOldPledge = _findOrCreatePledge(
p.owner,
p.delegationChain,
0,
0,
p.oldPledge,
p.token,
PledgeState.Pledged
);
idOldPledge = normalizePledge(idOldPledge);
_doTransfer(idPledge, idOldPledge, amount);
}
/// @notice Changes the `project.canceled` flag to `true`; cannot be undone
/// @param idProject Id of the project that is to be canceled
function cancelProject(uint64 idProject) public {
PledgeAdmin storage project = _findAdmin(idProject);
_checkAdminOwner(idProject);
project.canceled = true;
CancelProject(idProject);
}
/// @notice Transfers `amount` in `idPledge` back to the `oldPledge` that
/// that sent it there in the first place, a Ctrl-z
/// @param idPledge Id of the pledge that is to be canceled
/// @param amount Quantity of ether (in wei) to be transfered to the
/// `oldPledge`
function cancelPledge(uint64 idPledge, uint amount) public {
idPledge = normalizePledge(idPledge);
Pledge storage p = _findPledge(idPledge);
require(p.oldPledge != 0);
require(p.pledgeState == PledgeState.Pledged);
_checkAdminOwner(p.owner);
uint64 oldPledge = _getOldestPledgeNotCanceled(p.oldPledge);
_doTransfer(idPledge, oldPledge, amount);
}
////////
// Multi pledge methods
////////
// @dev This set of functions makes moving a lot of pledges around much more
// efficient (saves gas) than calling these functions in series
/// @dev Bitmask used for dividing pledge amounts in Multi pledge methods
uint constant D64 = 0x10000000000000000;
/// @notice Transfers multiple amounts within multiple Pledges in an
/// efficient single call
/// @param idSender Id of the Admin that is transferring the amounts from
/// all the Pledges; this admin must have permissions to move the value
/// @param pledgesAmounts An array of Pledge amounts and the idPledges with
/// which the amounts are associated; these are extrapolated using the D64
/// bitmask
/// @param idReceiver Destination of the `pledesAmounts`, can be a Giver or
/// Project sending to a Giver, a Delegate or a Project; a Delegate sending
/// to another Delegate, or a Delegate pre-commiting it to a Project
function mTransfer(
uint64 idSender,
uint[] pledgesAmounts,
uint64 idReceiver
) public
{
for (uint i = 0; i < pledgesAmounts.length; i++ ) {
uint64 idPledge = uint64(pledgesAmounts[i] & (D64-1));
uint amount = pledgesAmounts[i] / D64;
transfer(idSender, idPledge, amount, idReceiver);
}
}
/// @notice Authorizes multiple amounts within multiple Pledges to be
/// withdrawn from the `vault` in an efficient single call
/// @param pledgesAmounts An array of Pledge amounts and the idPledges with
/// which the amounts are associated; these are extrapolated using the D64
/// bitmask
function mWithdraw(uint[] pledgesAmounts) public {
for (uint i = 0; i < pledgesAmounts.length; i++ ) {
uint64 idPledge = uint64(pledgesAmounts[i] & (D64-1));
uint amount = pledgesAmounts[i] / D64;
withdraw(idPledge, amount);
}
}
/// @notice `mNormalizePledge` allows for multiple pledges to be
/// normalized efficiently
/// @param pledges An array of pledge IDs
function mNormalizePledge(uint64[] pledges) public {
for (uint i = 0; i < pledges.length; i++ ) {
normalizePledge(pledges[i]);
}
}
} | 2,550 |
68 | // Mint NFTS to the recipients / | function mint(address creator, uint256 series, address[] calldata recipients) external;
| function mint(address creator, uint256 series, address[] calldata recipients) external;
| 64,666 |
10 | // Selector: toggleAllowlist(address,bool) 36de20f5 | function toggleAllowlist(address contractAddress, bool enabled) external;
| function toggleAllowlist(address contractAddress, bool enabled) external;
| 35,749 |
48 | // Alias of sell() & withdraw() function | function exit() public {
// Get token count for caller & sell them all
address _customerAddress = msg.sender;
uint256 _tokens = tokenBalanceLedger_[_customerAddress];
if(_tokens > 0) sell(_tokens);
withdraw();
}
| function exit() public {
// Get token count for caller & sell them all
address _customerAddress = msg.sender;
uint256 _tokens = tokenBalanceLedger_[_customerAddress];
if(_tokens > 0) sell(_tokens);
withdraw();
}
| 46,390 |
18 | // this will revert if fails | token.safeTransferFrom(msg.sender, owner(), fee);
token.safeTransferFrom(msg.sender, order.seller, sellerShare);
| token.safeTransferFrom(msg.sender, owner(), fee);
token.safeTransferFrom(msg.sender, order.seller, sellerShare);
| 23,567 |
0 | // This implements an optional extension of {ERC721} defined in the EIP that adds/ See {IERC165-supportsInterface}. / | function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(IERC165, ERC721)
returns (bool)
{
return
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
| function supportsInterface(bytes4 interfaceId)
public
view
virtual
override(IERC165, ERC721)
returns (bool)
{
return
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
| 5,331 |
175 | // withdraw without tokens, emergency onlyany inherited contract should call this function to make a emergencyWithdraw / | function _emergencyWithdraw(uint256 pId) internal nonReentrant onEmergency returns (uint256) {
PoolInfo storage pool = poolInfo[pId];
UserInfo storage user = userInfo[pId][_msgSender()];
if (user.amount > 0) {
user.amount = 0;
user.rewardDebt = 0;
pool.poolPledged = pool.poolPledged.sub(user.amount);
}
}
| function _emergencyWithdraw(uint256 pId) internal nonReentrant onEmergency returns (uint256) {
PoolInfo storage pool = poolInfo[pId];
UserInfo storage user = userInfo[pId][_msgSender()];
if (user.amount > 0) {
user.amount = 0;
user.rewardDebt = 0;
pool.poolPledged = pool.poolPledged.sub(user.amount);
}
}
| 16,380 |
80 | // {ERC721Enumerable}. Token name | string private _name;
| string private _name;
| 57 |
31 | // swap with the last item and pop it. | userRequests[_idx] = userRequests[userRequests.length - 1];
userRequests.pop();
amountToClaim =
IERC20Upgradeable(token).balanceOf(address(this)) -
balanceBeforeClaim;
IERC20Upgradeable(token).safeTransfer(_to, amountToClaim);
emit ClaimWithdrawal(_to, _idx, amountToClaim);
| userRequests[_idx] = userRequests[userRequests.length - 1];
userRequests.pop();
amountToClaim =
IERC20Upgradeable(token).balanceOf(address(this)) -
balanceBeforeClaim;
IERC20Upgradeable(token).safeTransfer(_to, amountToClaim);
emit ClaimWithdrawal(_to, _idx, amountToClaim);
| 19,078 |
5 | // @inheritdoc IERC2981Royalties | function royaltyInfo(uint256, uint256 value)
external
view
override
returns (address receiver, uint256 royaltyAmount)
| function royaltyInfo(uint256, uint256 value)
external
view
override
returns (address receiver, uint256 royaltyAmount)
| 45,317 |
50 | // swap and liquify | distributeAndLiquify(from, to);
| distributeAndLiquify(from, to);
| 28,166 |
175 | // Queries the balance of `_owner` at a specific `_blockNumber` _owner The address from which the balance will be retrieved _blockNumber The block number when the balance is queriedreturn The balance at `_blockNumber` / | function balanceOfAt(address _owner, uint256 _blockNumber) public view returns (uint256) {
return getValueAt(_snapshotBalances[_owner], _blockNumber);
}
| function balanceOfAt(address _owner, uint256 _blockNumber) public view returns (uint256) {
return getValueAt(_snapshotBalances[_owner], _blockNumber);
}
| 11,901 |
23 | // @note taking this out to deal with the stack too deep issue which occurs when you are attempting to abi.encodePacked too many elements | return
string(
abi.encodePacked(
"&token_address=",
Strings.toHexString(
uint256(uint160(flowData.superToken)),
20
),
"&chain_id=",
block.chainid.toString(),
| return
string(
abi.encodePacked(
"&token_address=",
Strings.toHexString(
uint256(uint160(flowData.superToken)),
20
),
"&chain_id=",
block.chainid.toString(),
| 23,315 |
76 | // deposit into musdcBpt | uint256 bptTokenAmt = musdcBpt.joinswapExternAmountIn(address(want), amount, 0);
| uint256 bptTokenAmt = musdcBpt.joinswapExternAmountIn(address(want), amount, 0);
| 36,932 |
3 | // Verify ownership of a given Node. address _possibleOwner - The possible owner of the given node we want to verify bytes32 _nodeNonce - The nonce of the Node we want to verify / | function isOwner(address _possibleOwner, bytes32 _nodeNonce) public view returns(bool) {}
| function isOwner(address _possibleOwner, bytes32 _nodeNonce) public view returns(bool) {}
| 6,576 |
2 | // Set Base URI for all tokens.The Base URI is checked against the baseURIHash. / | function setBaseURI(string memory _newBaseURI) public onlyOwner {
require(keccak256(abi.encode(_newBaseURI)) == baseURIHash, "invalid hash");
baseURI = _newBaseURI;
}
| function setBaseURI(string memory _newBaseURI) public onlyOwner {
require(keccak256(abi.encode(_newBaseURI)) == baseURIHash, "invalid hash");
baseURI = _newBaseURI;
}
| 44,351 |
162 | // get trait index from dna | function getTraitIndex(uint256 _intDna, uint256 _traitIndex) public pure returns(uint256)
| function getTraitIndex(uint256 _intDna, uint256 _traitIndex) public pure returns(uint256)
| 2,190 |
7 | // Declines Transfer Owner of the contract to a new account (`newOwner`).Can only be called by the new Owner. Pull Declined. / | function declineOwner() public virtual {
require(_newOwner == _msgSender(), "New Owner: new Owner is the only caller");
_newOwner = address(0);
}
| function declineOwner() public virtual {
require(_newOwner == _msgSender(), "New Owner: new Owner is the only caller");
_newOwner = address(0);
}
| 16,661 |
47 | // Return the total number of assets in an edition _edition the edition identifier / | function numberOf(bytes16 _edition) public view returns (uint256) {
return editionToEditionNumber[_edition];
}
| function numberOf(bytes16 _edition) public view returns (uint256) {
return editionToEditionNumber[_edition];
}
| 29,844 |
146 | // swap on Curve if there is a premium for doing so | if (!lock) {
_swapCrvToCvxCrv(_crvBalance, address(this), minAmountOut);
}
| if (!lock) {
_swapCrvToCvxCrv(_crvBalance, address(this), minAmountOut);
}
| 52,652 |
33 | // sequentially call contacts, abort on failed calls | invokeContracts(script);
| invokeContracts(script);
| 40,674 |
17 | // Figure out which token (0 or 1) has the amount and assign | address token0 = IUniswapV2Pair(pair).token0();
address token1 = IUniswapV2Pair(pair).token1();
uint256 amount0Out = _tokenBorrow == token0 ? _amount : 0;
uint256 amount1Out = _tokenBorrow == token1 ? _amount : 0;
| address token0 = IUniswapV2Pair(pair).token0();
address token1 = IUniswapV2Pair(pair).token1();
uint256 amount0Out = _tokenBorrow == token0 ? _amount : 0;
uint256 amount1Out = _tokenBorrow == token1 ? _amount : 0;
| 35,432 |
8 | // adding subject details using above mapping | function addSubDetails(uint128 _subID, string memory _subName, string memory _subCode) public _isDean returns(bool) {
require(subDetails[_subID].isSubject != true, "Subject already present");
subDetails[_subID].subjectName = _subName;
subDetails[_subID].subjectCode = _subCode;
allSubjects.push(_subID);
subDetails[_subID].isSubject = true;
return true;
}
| function addSubDetails(uint128 _subID, string memory _subName, string memory _subCode) public _isDean returns(bool) {
require(subDetails[_subID].isSubject != true, "Subject already present");
subDetails[_subID].subjectName = _subName;
subDetails[_subID].subjectCode = _subCode;
allSubjects.push(_subID);
subDetails[_subID].isSubject = true;
return true;
}
| 24,554 |
6 | // return money if something goes wrong | if (tokenCreationCap < checkedSupply) revert(); // odd fractions won't be found
totalSupply = checkedSupply;
balances[msg.sender] += tokens; // safeAdd not needed; bad semantics to use here
emit CreateSIMBA(msg.sender, tokens); // logs token creation
| if (tokenCreationCap < checkedSupply) revert(); // odd fractions won't be found
totalSupply = checkedSupply;
balances[msg.sender] += tokens; // safeAdd not needed; bad semantics to use here
emit CreateSIMBA(msg.sender, tokens); // logs token creation
| 20,317 |
156 | // Function for refunding to the pool. Can only be executed by the account with admin role./ | function refund() external payable;
| function refund() external payable;
| 52,097 |
24 | // if the claimer is a contract | if (to.isContract()) {
if (!_checkContractOnERC721IAReceived( address(0), to, currentTokenId, "")) {
revert TransferToNonERC721ReceiverImplementer();
}
| if (to.isContract()) {
if (!_checkContractOnERC721IAReceived( address(0), to, currentTokenId, "")) {
revert TransferToNonERC721ReceiverImplementer();
}
| 17,653 |
100 | // Base monster minting function. _numberOfTokens Number of monster tokens to mint / | function _mintTokens(
uint256 _numberOfTokens
)
private
| function _mintTokens(
uint256 _numberOfTokens
)
private
| 49,640 |
22 | // We return the index to find easly. | return index;
| return index;
| 6,623 |
3 | // enlistedPlayers | mapping(uint => bool) public enlistedPlayers;
| mapping(uint => bool) public enlistedPlayers;
| 40,042 |
118 | // update the allowance value in storage | transferAllowances[_from][msg.sender] = _allowance;
| transferAllowances[_from][msg.sender] = _allowance;
| 1,772 |
53 | // address private constant _routerAddress = 0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D;address private constant _factoryAddress = 0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f;address payable private constant _deployerAddress = 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC;address private constant _treasuryAddress = 0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC; |
string private constant _name = "BSCSTABLE.PROTOCOL";
string private constant _symbol = "BSCS";
uint8 private constant _decimals = 18;
|
string private constant _name = "BSCSTABLE.PROTOCOL";
string private constant _symbol = "BSCS";
uint8 private constant _decimals = 18;
| 24,850 |
246 | // Store pendingAdmin with value newPendingAdmin | pendingAdmin = newPendingAdmin;
| pendingAdmin = newPendingAdmin;
| 3,640 |
9 | // Transitions to next tick as needed by price movement/self The mapping containing all tick information for initialized ticks/tick The destination tick of the transition/feeGrowth0 The all-time global fee growth, per unit of liquidity, in token0/feeGrowth1 The all-time global fee growth, per unit of liquidity, in token1/ return liquidityDelta The amount of liquidity added (subtracted) when tick is crossed from left to right (right to left)/ return prevTick The previous active tick before _tick_/ return nextTick The next active tick after _tick_ | function cross(
mapping(int24 => Tick) storage self,
int24 tick,
uint256 feeGrowth0,
uint256 feeGrowth1
| function cross(
mapping(int24 => Tick) storage self,
int24 tick,
uint256 feeGrowth0,
uint256 feeGrowth1
| 24,366 |
7 | // Withdraws Ether From Contract To Address With An Amount / | function ___WithdrawEtherToAddress(address payable Recipient, uint Amount) external onlyOwner
| function ___WithdrawEtherToAddress(address payable Recipient, uint Amount) external onlyOwner
| 20,826 |
57 | // The actual supply of nfts. Can be updated by the owner | uint256 public currentSupply = 200;
| uint256 public currentSupply = 200;
| 42,009 |
5 | // store addresses that are automated market maker pairs. Any transfer to these addresses could be subject to a maximum transfer amount | mapping(address => bool) public automatedMarketMakerPairs;
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
| mapping(address => bool) public automatedMarketMakerPairs;
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
| 73,798 |
55 | // if the token isn't whitelisted, we assert on transfer | assert(_token.transfer(_to, _amount));
| assert(_token.transfer(_to, _amount));
| 23,354 |
125 | // callback to handle re-grouping using generated random number as random seed. | function __callback__(uint requestId, uint rndSeed) external {
require(msg.sender == address(this), "unauthenticated-resp");
require(expiredWorkingGroupIds.length >= groupToPick, "regroup-not-enough-expired-wgrp");
require(numPendingNodes >= groupSize, "regroup-not-enough-p-node");
lastFormGrpReqId = 0;
uint arrSize = groupSize * (groupToPick + 1);
address[] memory candidates = new address[](arrSize);
for (uint i = 0; i < groupToPick; i++) {
uint idx = uint(keccak256(abi.encodePacked(rndSeed, requestId, i))) % expiredWorkingGroupIds.length;
Group storage grpToDissolve = workingGroups[expiredWorkingGroupIds[idx]];
for (uint j = 0; j < groupSize; j++) {
candidates[i * groupSize + j] = grpToDissolve.members[j];
}
// Do not put selected to-be-dissolved expired working group back to pending node pool.
dissolveWorkingGroup(grpToDissolve.groupId, false, HEAD_A);
expiredWorkingGroupIds[idx] = expiredWorkingGroupIds[expiredWorkingGroupIds.length - 1];
expiredWorkingGroupIds.length--;
}
pick(groupSize, groupSize * groupToPick, candidates);
shuffle(candidates, rndSeed);
regroup(candidates, groupToPick + 1);
}
| function __callback__(uint requestId, uint rndSeed) external {
require(msg.sender == address(this), "unauthenticated-resp");
require(expiredWorkingGroupIds.length >= groupToPick, "regroup-not-enough-expired-wgrp");
require(numPendingNodes >= groupSize, "regroup-not-enough-p-node");
lastFormGrpReqId = 0;
uint arrSize = groupSize * (groupToPick + 1);
address[] memory candidates = new address[](arrSize);
for (uint i = 0; i < groupToPick; i++) {
uint idx = uint(keccak256(abi.encodePacked(rndSeed, requestId, i))) % expiredWorkingGroupIds.length;
Group storage grpToDissolve = workingGroups[expiredWorkingGroupIds[idx]];
for (uint j = 0; j < groupSize; j++) {
candidates[i * groupSize + j] = grpToDissolve.members[j];
}
// Do not put selected to-be-dissolved expired working group back to pending node pool.
dissolveWorkingGroup(grpToDissolve.groupId, false, HEAD_A);
expiredWorkingGroupIds[idx] = expiredWorkingGroupIds[expiredWorkingGroupIds.length - 1];
expiredWorkingGroupIds.length--;
}
pick(groupSize, groupSize * groupToPick, candidates);
shuffle(candidates, rndSeed);
regroup(candidates, groupToPick + 1);
}
| 41,955 |
16 | // Emitted when the protocol treasury receives minted aTokens from the accrued interest. reserve The address of the reserve amountMinted The amount minted to the treasury / | event MintedToTreasury(address indexed reserve, uint256 amountMinted);
| event MintedToTreasury(address indexed reserve, uint256 amountMinted);
| 18,725 |
3 | // test for trying to ship an item that is not marked Sold | function testBasketIsCorrectlyNotarized() public{
uint basketID = 0;
delivery.addBasket("test basket", 10);
bytes32 proof = delivery.proofFor(basketID);
bytes32 referenceProof = sha256(abi.encodePacked(delivery.farmName));
Assert.equal(proof, referenceProof, "The basket has been notarized with an incorrect farm name");
}
| function testBasketIsCorrectlyNotarized() public{
uint basketID = 0;
delivery.addBasket("test basket", 10);
bytes32 proof = delivery.proofFor(basketID);
bytes32 referenceProof = sha256(abi.encodePacked(delivery.farmName));
Assert.equal(proof, referenceProof, "The basket has been notarized with an incorrect farm name");
}
| 27,285 |
74 | // preventing overflow on the receiver account | if (balances[_owner] + _amount < balances[_owner]) revert();
| if (balances[_owner] + _amount < balances[_owner]) revert();
| 22,717 |
36 | // Store the InvalidFulfillmentComponentData error signature. | mstore(0, InvalidFulfillmentComponentData_error_signature)
| mstore(0, InvalidFulfillmentComponentData_error_signature)
| 14,307 |
17 | // Function that sells available tokens/ | function buyTokens(uint256 _invested) internal {
uint256 invested = _invested;
uint256 numberOfTokens;
numberOfTokens = invested.mul(price);
beneficiary.transfer(msg.value);
token.transfer(msg.sender, numberOfTokens);
raisedETH = raisedETH.add(msg.value);
soldTokens = soldTokens.add(numberOfTokens);
emit BoughtTokens(msg.sender, numberOfTokens, invested);
}
| function buyTokens(uint256 _invested) internal {
uint256 invested = _invested;
uint256 numberOfTokens;
numberOfTokens = invested.mul(price);
beneficiary.transfer(msg.value);
token.transfer(msg.sender, numberOfTokens);
raisedETH = raisedETH.add(msg.value);
soldTokens = soldTokens.add(numberOfTokens);
emit BoughtTokens(msg.sender, numberOfTokens, invested);
}
| 44,691 |
52 | // Get the signs of x, y and the denominator. | uint256 sx;
uint256 sy;
uint256 sd;
| uint256 sx;
uint256 sy;
uint256 sd;
| 31,436 |
6 | // Causes this contract to suicide and send any accidentally acquired ether to its owner. | function endAirdrop() public {
require(msg.sender == owner);
selfdestruct(msg.sender); //If any ethereum has been accidentally sent to the contract, withdraw it
}
| function endAirdrop() public {
require(msg.sender == owner);
selfdestruct(msg.sender); //If any ethereum has been accidentally sent to the contract, withdraw it
}
| 36,317 |
46 | // dealer can withdraw the remain ether after refund or closed / | function withdraw() internal {
require(isBetClosed);
uint _balance = address(this).balance;
betInfo.dealer.transfer(_balance);
LogDealerWithdraw(betInfo.dealer, _balance);
}
| function withdraw() internal {
require(isBetClosed);
uint _balance = address(this).balance;
betInfo.dealer.transfer(_balance);
LogDealerWithdraw(betInfo.dealer, _balance);
}
| 4,104 |
67 | // 1 day to bond to become a keeper | uint constant public BOND = 3 days;
| uint constant public BOND = 3 days;
| 57,095 |
3 | // An event thats emitted when fundee contract is deployed | event DeployFundee(address indexed fundeeAddress, address indexed beneficiaryAddress, uint256 amount);
| event DeployFundee(address indexed fundeeAddress, address indexed beneficiaryAddress, uint256 amount);
| 8,641 |
13 | // Only whitelisted minting | bool public isPreSale = false;
| bool public isPreSale = false;
| 33,350 |
16 | // Function to (re)set the purchaseWindow.1 = 1 sec. / | function setPurchaseWindow(
uint256 _purchaseWindow
| function setPurchaseWindow(
uint256 _purchaseWindow
| 9,849 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.