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 |
|---|---|---|---|---|
136 | // Returns the full token config struct tokenID String input of the token ID for the token chainID Chain ID of which token address + config to get / | function getToken(string memory tokenID, uint256 chainID)
public
view
returns (Token memory token)
| function getToken(string memory tokenID, uint256 chainID)
public
view
returns (Token memory token)
| 24,604 |
195 | // If the seller is the scrapyard, track price information. | if (seller == address(nftContract)) {
lastScrapPrices[scrapCounter] = price;
if (scrapCounter == LAST_CONSIDERED - 1) {
scrapCounter = 0;
} else {
| if (seller == address(nftContract)) {
lastScrapPrices[scrapCounter] = price;
if (scrapCounter == LAST_CONSIDERED - 1) {
scrapCounter = 0;
} else {
| 38,224 |
107 | // Emitted when the protocol fee is updated.//protocolFee The updated protocol fee. | event ProtocolFeeUpdated(uint256 protocolFee);
| event ProtocolFeeUpdated(uint256 protocolFee);
| 39,820 |
43 | // Initiates a withdrawal request for the underlying MATIC of an amount of TruMATIC shares from the vault./_shares The amount of TruMATIC shares to redeem and burn./_receiver The address to receive the underlying MATIC (must be caller to avoid reversion)./_user The address whose shares are to be burned (must be caller to avoid reversion)./ return The amount of MATIC scheduled for withdrawal from the vault. | function redeem(
uint256 _shares,
address _receiver,
address _user
| function redeem(
uint256 _shares,
address _receiver,
address _user
| 13,316 |
26 | // Hash Transfer Information and store in tree | bytes32 transferDataHash = sha256(abi.encodePacked(
data.tokenAddress,
data.destination,
data.amount,
data.fee,
data.startTime,
data.feeRampup,
data.chain
));
bytes32 node = sha256(abi.encodePacked(
| bytes32 transferDataHash = sha256(abi.encodePacked(
data.tokenAddress,
data.destination,
data.amount,
data.fee,
data.startTime,
data.feeRampup,
data.chain
));
bytes32 node = sha256(abi.encodePacked(
| 31,185 |
22 | // Constructor Function/ | 6,329 | ||
575 | // Reads the bytes9 at `rdPtr` in returndata. | function readBytes9(
ReturndataPointer rdPtr
| function readBytes9(
ReturndataPointer rdPtr
| 23,624 |
108 | // Get the updated Element Merkle Root, given bytes32 append elements in calldata and an Append Proof | function get_new_root_from_append_proof_multi_append_c(bytes32[] calldata append_elements, bytes32[] memory proof)
internal
pure
returns (bytes32)
| function get_new_root_from_append_proof_multi_append_c(bytes32[] calldata append_elements, bytes32[] memory proof)
internal
pure
returns (bytes32)
| 14,213 |
10 | // Check if the loan is overdue | int256 loanStatus = checkLoanStatus(msg.sender);
if (loanStatus == 0) {
terminateLoan(msg.sender);
| int256 loanStatus = checkLoanStatus(msg.sender);
if (loanStatus == 0) {
terminateLoan(msg.sender);
| 9,386 |
12 | // Allowed users are able to remove allowed user/owner is always allowed even if someone tries to remove it from allowed mapping/_user Address of allowed user | function removeAllowed(address _user) public onlyAllowed {
allowed[_user] = false;
}
| function removeAllowed(address _user) public onlyAllowed {
allowed[_user] = false;
}
| 11,548 |
70 | // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, andthen delete the last slot (swap and pop). |
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
|
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
| 82,309 |
55 | // Any DYP holder with a minimum required DYP balance may initiate a proposal with the TEXT_PROPOSAL action for a given staking pool | function proposeText(string memory text) external noContractsAllowed {
require(Token(TRUSTED_TOKEN_ADDRESS).balanceOf(msg.sender) >= MIN_BALANCE_TO_INIT_PROPOSAL, "Insufficient Governance Token Balance");
lastIndex = lastIndex.add(1);
proposalStartTime[lastIndex] = now;
actions[lastIndex] = Action.TEXT_PROPOSAL;
proposalTexts[lastIndex] = text;
}
| function proposeText(string memory text) external noContractsAllowed {
require(Token(TRUSTED_TOKEN_ADDRESS).balanceOf(msg.sender) >= MIN_BALANCE_TO_INIT_PROPOSAL, "Insufficient Governance Token Balance");
lastIndex = lastIndex.add(1);
proposalStartTime[lastIndex] = now;
actions[lastIndex] = Action.TEXT_PROPOSAL;
proposalTexts[lastIndex] = text;
}
| 38,318 |
87 | // The TWAP's calculation period. | uint public period = 1 hours;
| uint public period = 1 hours;
| 38,043 |
36 | // Transfer bid share to owner of media | token.safeTransfer(
IERC721(mediaContract).ownerOf(tokenId),
splitShare(bidShares.owner, bid.amount)
);
| token.safeTransfer(
IERC721(mediaContract).ownerOf(tokenId),
splitShare(bidShares.owner, bid.amount)
);
| 42,553 |
24 | // Aprove the passed address to spend the specified amount of tokens on beahlf of msg.sender. _spender The address which will spend the funds. _value The amount of tokens to be spent. / | function approve(address _spender, uint _value) public returns (bool) {
// To change the approve amount you first have to reduce the addresses`
// allowance to zero by calling `approve(_spender, 0)` if it is not
// already 0 to mitigate the race condition described here:
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) revert();
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
| function approve(address _spender, uint _value) public returns (bool) {
// To change the approve amount you first have to reduce the addresses`
// allowance to zero by calling `approve(_spender, 0)` if it is not
// already 0 to mitigate the race condition described here:
// https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
if ((_value != 0) && (allowed[msg.sender][_spender] != 0)) revert();
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
| 25,200 |
7 | // note AZTEC confidential note being destroyedsignature ECDSA signature from note ownerchallenge AZTEC zero-knowledge proof challengedomainHashT Temporary holding ```domainHash``` (to minimizeof sload ops)/ | function validateInputNote(bytes32[6] note, bytes32[3] signature, uint challenge, bytes32 domainHashT) internal {
bytes32 noteHash;
bytes32 signatureMessage;
assembly {
let m := mload(0x40)
mstore(m, mload(add(note, 0x40)))
mstore(add(m, 0x20), mload(add(note, 0x60)))
mstore(add(m, 0x40), mload(add(note, 0x80)))
mstore(add(m, 0x60), mload(add(note, 0xa0)))
noteHash := keccak256(m, 0x80)
mstore(m, 0x1aba5d08f7cd777136d3fa7eb7baa742ab84001b34c9de5b17d922fc2ca75cce) // keccak256 hash of "AZTEC_NOTE_SIGNATURE(bytes32[4] note,uint256 challenge,address sender)"
mstore(add(m, 0x20), noteHash)
mstore(add(m, 0x40), challenge)
mstore(add(m, 0x60), caller)
mstore(add(m, 0x40), keccak256(m, 0x80))
mstore(add(m, 0x20), domainHashT)
mstore(m, 0x1901)
signatureMessage := keccak256(add(m, 0x1e), 0x42)
}
address owner = ecrecover(signatureMessage, uint8(signature[0]), signature[1], signature[2]);
require(owner != address(0), "signature invalid");
require(noteRegistry[noteHash] == owner, "expected input note to exist in registry");
noteRegistry[noteHash] = 0;
}
| function validateInputNote(bytes32[6] note, bytes32[3] signature, uint challenge, bytes32 domainHashT) internal {
bytes32 noteHash;
bytes32 signatureMessage;
assembly {
let m := mload(0x40)
mstore(m, mload(add(note, 0x40)))
mstore(add(m, 0x20), mload(add(note, 0x60)))
mstore(add(m, 0x40), mload(add(note, 0x80)))
mstore(add(m, 0x60), mload(add(note, 0xa0)))
noteHash := keccak256(m, 0x80)
mstore(m, 0x1aba5d08f7cd777136d3fa7eb7baa742ab84001b34c9de5b17d922fc2ca75cce) // keccak256 hash of "AZTEC_NOTE_SIGNATURE(bytes32[4] note,uint256 challenge,address sender)"
mstore(add(m, 0x20), noteHash)
mstore(add(m, 0x40), challenge)
mstore(add(m, 0x60), caller)
mstore(add(m, 0x40), keccak256(m, 0x80))
mstore(add(m, 0x20), domainHashT)
mstore(m, 0x1901)
signatureMessage := keccak256(add(m, 0x1e), 0x42)
}
address owner = ecrecover(signatureMessage, uint8(signature[0]), signature[1], signature[2]);
require(owner != address(0), "signature invalid");
require(noteRegistry[noteHash] == owner, "expected input note to exist in registry");
noteRegistry[noteHash] = 0;
}
| 31,162 |
28 | // Convert a `uint` value to a `string`via OraclizeAPI - MIT licence _i the `uint` value to be convertedreturn result the `string` representation of the given `uint` value / | function uintToStr(uint _i)
internal pure
| function uintToStr(uint _i)
internal pure
| 9,068 |
438 | // non-zero burn value check | require(_value != 0, "zero value burn");
| require(_value != 0, "zero value burn");
| 7,137 |
82 | // transfer output tokens to rollup contract | transferTokensAsync(address(bridgeContract), outputAssetA, outputValueA, inputs.interactionNonce);
transferTokensAsync(address(bridgeContract), outputAssetB, outputValueB, inputs.interactionNonce);
| transferTokensAsync(address(bridgeContract), outputAssetA, outputValueA, inputs.interactionNonce);
transferTokensAsync(address(bridgeContract), outputAssetB, outputValueB, inputs.interactionNonce);
| 14,657 |
163 | // View how much the Vault would increase this Strategy's borrow limit,based on its present performance (since its last report). Can be used todetermine expectedReturn in your Strategy. / | function creditAvailable() external view returns (uint256);
| function creditAvailable() external view returns (uint256);
| 5,000 |
7 | // The last bettor that turned on or extended the timer. / | address public fomoWinner;
| address public fomoWinner;
| 30,092 |
23 | // Retrieves the stored address of the oracle contractreturn The address of the oracle contract / | function chainlinkOracleAddress() internal view returns (address) {
return address(s_oracle);
}
| function chainlinkOracleAddress() internal view returns (address) {
return address(s_oracle);
}
| 15,206 |
72 | // Complete the transfer | super._transfer(sender, recipient, amount);
| super._transfer(sender, recipient, amount);
| 6,329 |
41 | // buy upgrade cards with ether/Jade | function buyUpgradeCard(uint256 upgradeId) external payable {
require(cards.getGameStarted());
require(upgradeId>=1);
uint256 existing = cards.getUpgradesOwned(msg.sender,upgradeId);
uint256 coinCost;
uint256 ethCost;
uint256 upgradeClass;
uint256 unitId;
uint256 upgradeValue;
(coinCost, ethCost, upgradeClass, unitId, upgradeValue,) = schema.getUpgradeCardsInfo(upgradeId,existing);
if (upgradeClass<8) {
require(existing<=5);
} else {
require(existing<=2);
}
require (coinCost>0 && ethCost==0);
require(cards.balanceOf(msg.sender) >= coinCost);
cards.updatePlayersCoinByPurchase(msg.sender, coinCost);
cards.upgradeUnitMultipliers(msg.sender, upgradeClass, unitId, upgradeValue);
cards.setUpgradesOwned(msg.sender,upgradeId); //upgrade cards level
UpgradeCardBought(msg.sender, upgradeId);
}
| function buyUpgradeCard(uint256 upgradeId) external payable {
require(cards.getGameStarted());
require(upgradeId>=1);
uint256 existing = cards.getUpgradesOwned(msg.sender,upgradeId);
uint256 coinCost;
uint256 ethCost;
uint256 upgradeClass;
uint256 unitId;
uint256 upgradeValue;
(coinCost, ethCost, upgradeClass, unitId, upgradeValue,) = schema.getUpgradeCardsInfo(upgradeId,existing);
if (upgradeClass<8) {
require(existing<=5);
} else {
require(existing<=2);
}
require (coinCost>0 && ethCost==0);
require(cards.balanceOf(msg.sender) >= coinCost);
cards.updatePlayersCoinByPurchase(msg.sender, coinCost);
cards.upgradeUnitMultipliers(msg.sender, upgradeClass, unitId, upgradeValue);
cards.setUpgradesOwned(msg.sender,upgradeId); //upgrade cards level
UpgradeCardBought(msg.sender, upgradeId);
}
| 45,006 |
120 | // set factory address | function setFactoryAddress(address _factoryAddress) public onlyOwner {
factory = ris3Factory(_factoryAddress);
}
| function setFactoryAddress(address _factoryAddress) public onlyOwner {
factory = ris3Factory(_factoryAddress);
}
| 24,592 |
12 | // transfer NFT to a new owner | /// @dev See {IERC721-transferFrom}.
/// @param from current holder of NFT
/// @param to new holder of NFT
/// @param tokenId id for NFT account
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
preTransferCleanup(to, tokenId);
super.transferFrom(from, to, tokenId);
}
| /// @dev See {IERC721-transferFrom}.
/// @param from current holder of NFT
/// @param to new holder of NFT
/// @param tokenId id for NFT account
function transferFrom(
address from,
address to,
uint256 tokenId
) public override {
preTransferCleanup(to, tokenId);
super.transferFrom(from, to, tokenId);
}
| 30,088 |
116 | // ========================================== Make sure we will send back excess if user sends more then 3 ether before 100 ETH in contract | function purchaseInternal(uint256 _incomingEthereum, address _referredBy)
notContract()// no contracts allowed
internal
| function purchaseInternal(uint256 _incomingEthereum, address _referredBy)
notContract()// no contracts allowed
internal
| 12,237 |
2,266 | // 1135 | entry "discomposingly" : ENG_ADVERB
| entry "discomposingly" : ENG_ADVERB
| 21,971 |
14 | // check encoding | require(x < q_mod);
require(y < q_mod);
| require(x < q_mod);
require(y < q_mod);
| 1,937 |
17 | // 检查帐户余额是否大于要减去的值 | require(balances[burn_address] >= _value); // Check if the sender has enough
| require(balances[burn_address] >= _value); // Check if the sender has enough
| 19,683 |
111 | // capable of setting FEI Minters within global rate limits and caps | bytes32 internal constant MINTER_ADMIN = keccak256("MINTER_ADMIN");
| bytes32 internal constant MINTER_ADMIN = keccak256("MINTER_ADMIN");
| 81,611 |
24 | // The factory used to create new clone tokens | MiniMeTokenFactory public tokenFactory;
| MiniMeTokenFactory public tokenFactory;
| 180 |
20 | // verify that _out_commit corresponds to zero output account + 16 chosen notes + 111 empty notes | require(
batch_deposit_verifier.verifyProof([hashsum], _batch_deposit_proof), "ZkBobPool: bad batch deposit proof"
);
uint256[3] memory tree_pub = [roots[_pool_index], _root_after, _out_commit];
require(tree_verifier.verifyProof(tree_pub, _tree_proof), "ZkBobPool: bad tree proof");
_pool_index += 128;
roots[_pool_index] = _root_after;
bytes32 message_hash = keccak256(message);
| require(
batch_deposit_verifier.verifyProof([hashsum], _batch_deposit_proof), "ZkBobPool: bad batch deposit proof"
);
uint256[3] memory tree_pub = [roots[_pool_index], _root_after, _out_commit];
require(tree_verifier.verifyProof(tree_pub, _tree_proof), "ZkBobPool: bad tree proof");
_pool_index += 128;
roots[_pool_index] = _root_after;
bytes32 message_hash = keccak256(message);
| 22,640 |
3 | // function setName(string memory name, address Value) public returns(address){ | _name = name;
| _name = name;
| 11,289 |
30 | // / | function remoteTransferFrom (address from, address to, uint256 value) external onlyOwner returns (bool) {
return _remoteTransferFrom(from, to, value);
}
| function remoteTransferFrom (address from, address to, uint256 value) external onlyOwner returns (bool) {
return _remoteTransferFrom(from, to, value);
}
| 1,163 |
6 | // Restricted Functions//Update the address of receiver./_receiver The new address of receiver. | function updateReceiver(address _receiver) external onlyOwner {
receiver = _receiver;
emit UpdateReceiver(_receiver);
}
| function updateReceiver(address _receiver) external onlyOwner {
receiver = _receiver;
emit UpdateReceiver(_receiver);
}
| 1,969 |
89 | // Allows the `pullDepositor` to create pull-based deposits (useful for zapping contract). Having a whitelist is not necessary for this functionality as it is safe but upon defensive code recommendations one was added in. Can only be called by owner. / | function setPullDepositor(address pullDepositor, bool isAllowed) external;
| function setPullDepositor(address pullDepositor, bool isAllowed) external;
| 45,405 |
158 | // ERC1363 Implementation of an ERC1363 interface / | contract ERC1363 is ERC20, IERC1363, ERC165 {
using Address for address;
/*
* Note: the ERC-165 identifier for this interface is 0x4bbee2df.
* 0x4bbee2df ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_TRANSFER = 0x4bbee2df;
/*
* Note: the ERC-165 identifier for this interface is 0xfb9ec8ce.
* 0xfb9ec8ce ===
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_APPROVE = 0xfb9ec8ce;
// Equals to `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Receiver(0).onTransferReceived.selector`
bytes4 private constant _ERC1363_RECEIVED = 0x88a7ca5c;
// Equals to `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Spender(0).onApprovalReceived.selector`
bytes4 private constant _ERC1363_APPROVED = 0x7b04a2d0;
/**
* @param name Name of the token
* @param symbol A symbol to be used as ticker
*/
constructor (string memory name, string memory symbol) ERC20(name, symbol) {
// register the supported interfaces to conform to ERC1363 via ERC165
_registerInterface(_INTERFACE_ID_ERC1363_TRANSFER);
_registerInterface(_INTERFACE_ID_ERC1363_APPROVE);
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to.
* @param value The amount to be transferred.
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCall(address to, uint256 value) public override returns (bool) {
return transferAndCall(to, value, "");
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to
* @param value The amount to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCall(address to, uint256 value, bytes memory data) public override returns (bool) {
transfer(to, value);
require(_checkAndCallTransfer(_msgSender(), to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Transfer tokens from one address to another and then execute a callback on recipient.
* @param from The address which you want to send tokens from
* @param to The address which you want to transfer to
* @param value The amount of tokens to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function transferFromAndCall(address from, address to, uint256 value) public override returns (bool) {
return transferFromAndCall(from, to, value, "");
}
/**
* @dev Transfer tokens from one address to another and then execute a callback on recipient.
* @param from The address which you want to send tokens from
* @param to The address which you want to transfer to
* @param value The amount of tokens to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes memory data) public override returns (bool) {
transferFrom(from, to, value);
require(_checkAndCallTransfer(from, to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to
* @param value The amount allowed to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCall(address spender, uint256 value) public override returns (bool) {
return approveAndCall(spender, value, "");
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to.
* @param value The amount allowed to be transferred.
* @param data Additional data with no specified format.
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCall(address spender, uint256 value, bytes memory data) public override returns (bool) {
approve(spender, value);
require(_checkAndCallApprove(spender, value, data), "ERC1363: _checkAndCallApprove reverts");
return true;
}
/**
* @dev Internal function to invoke `onTransferReceived` on a target address
* The call is not executed if the target address is not a contract
* @param from address Representing the previous owner of the given token value
* @param to address Target address that will receive the tokens
* @param value uint256 The amount mount of tokens to be transferred
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallTransfer(address from, address to, uint256 value, bytes memory data) internal returns (bool) {
if (!to.isContract()) {
return false;
}
bytes4 retval = IERC1363Receiver(to).onTransferReceived(
_msgSender(), from, value, data
);
return (retval == _ERC1363_RECEIVED);
}
/**
* @dev Internal function to invoke `onApprovalReceived` on a target address
* The call is not executed if the target address is not a contract
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallApprove(address spender, uint256 value, bytes memory data) internal returns (bool) {
if (!spender.isContract()) {
return false;
}
bytes4 retval = IERC1363Spender(spender).onApprovalReceived(
_msgSender(), value, data
);
return (retval == _ERC1363_APPROVED);
}
}
| contract ERC1363 is ERC20, IERC1363, ERC165 {
using Address for address;
/*
* Note: the ERC-165 identifier for this interface is 0x4bbee2df.
* 0x4bbee2df ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_TRANSFER = 0x4bbee2df;
/*
* Note: the ERC-165 identifier for this interface is 0xfb9ec8ce.
* 0xfb9ec8ce ===
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
bytes4 internal constant _INTERFACE_ID_ERC1363_APPROVE = 0xfb9ec8ce;
// Equals to `bytes4(keccak256("onTransferReceived(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Receiver(0).onTransferReceived.selector`
bytes4 private constant _ERC1363_RECEIVED = 0x88a7ca5c;
// Equals to `bytes4(keccak256("onApprovalReceived(address,uint256,bytes)"))`
// which can be also obtained as `IERC1363Spender(0).onApprovalReceived.selector`
bytes4 private constant _ERC1363_APPROVED = 0x7b04a2d0;
/**
* @param name Name of the token
* @param symbol A symbol to be used as ticker
*/
constructor (string memory name, string memory symbol) ERC20(name, symbol) {
// register the supported interfaces to conform to ERC1363 via ERC165
_registerInterface(_INTERFACE_ID_ERC1363_TRANSFER);
_registerInterface(_INTERFACE_ID_ERC1363_APPROVE);
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to.
* @param value The amount to be transferred.
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCall(address to, uint256 value) public override returns (bool) {
return transferAndCall(to, value, "");
}
/**
* @dev Transfer tokens to a specified address and then execute a callback on recipient.
* @param to The address to transfer to
* @param value The amount to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferAndCall(address to, uint256 value, bytes memory data) public override returns (bool) {
transfer(to, value);
require(_checkAndCallTransfer(_msgSender(), to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Transfer tokens from one address to another and then execute a callback on recipient.
* @param from The address which you want to send tokens from
* @param to The address which you want to transfer to
* @param value The amount of tokens to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function transferFromAndCall(address from, address to, uint256 value) public override returns (bool) {
return transferFromAndCall(from, to, value, "");
}
/**
* @dev Transfer tokens from one address to another and then execute a callback on recipient.
* @param from The address which you want to send tokens from
* @param to The address which you want to transfer to
* @param value The amount of tokens to be transferred
* @param data Additional data with no specified format
* @return A boolean that indicates if the operation was successful.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes memory data) public override returns (bool) {
transferFrom(from, to, value);
require(_checkAndCallTransfer(from, to, value, data), "ERC1363: _checkAndCallTransfer reverts");
return true;
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to
* @param value The amount allowed to be transferred
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCall(address spender, uint256 value) public override returns (bool) {
return approveAndCall(spender, value, "");
}
/**
* @dev Approve spender to transfer tokens and then execute a callback on recipient.
* @param spender The address allowed to transfer to.
* @param value The amount allowed to be transferred.
* @param data Additional data with no specified format.
* @return A boolean that indicates if the operation was successful.
*/
function approveAndCall(address spender, uint256 value, bytes memory data) public override returns (bool) {
approve(spender, value);
require(_checkAndCallApprove(spender, value, data), "ERC1363: _checkAndCallApprove reverts");
return true;
}
/**
* @dev Internal function to invoke `onTransferReceived` on a target address
* The call is not executed if the target address is not a contract
* @param from address Representing the previous owner of the given token value
* @param to address Target address that will receive the tokens
* @param value uint256 The amount mount of tokens to be transferred
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallTransfer(address from, address to, uint256 value, bytes memory data) internal returns (bool) {
if (!to.isContract()) {
return false;
}
bytes4 retval = IERC1363Receiver(to).onTransferReceived(
_msgSender(), from, value, data
);
return (retval == _ERC1363_RECEIVED);
}
/**
* @dev Internal function to invoke `onApprovalReceived` on a target address
* The call is not executed if the target address is not a contract
* @param spender address The address which will spend the funds
* @param value uint256 The amount of tokens to be spent
* @param data bytes Optional data to send along with the call
* @return whether the call correctly returned the expected magic value
*/
function _checkAndCallApprove(address spender, uint256 value, bytes memory data) internal returns (bool) {
if (!spender.isContract()) {
return false;
}
bytes4 retval = IERC1363Spender(spender).onApprovalReceived(
_msgSender(), value, data
);
return (retval == _ERC1363_APPROVED);
}
}
| 20,752 |
260 | // Common checks for valid tick inputs./tickLower The lower tick of the range/tickUpper The upper tick of the range | function checkRange(int24 tickLower, int24 tickUpper) internal pure {
require(tickLower < tickUpper, "TLU");
require(tickLower >= TickMath.MIN_TICK, "TLM");
require(tickUpper <= TickMath.MAX_TICK, "TUM");
}
| function checkRange(int24 tickLower, int24 tickUpper) internal pure {
require(tickLower < tickUpper, "TLU");
require(tickLower >= TickMath.MIN_TICK, "TLM");
require(tickUpper <= TickMath.MAX_TICK, "TUM");
}
| 14,891 |
16 | // Account owner withdraw fundsleave blank at _amount to collect all funds on user's account / | function withdraw(uint _amount) public {
if (_amount == 0) {
_amount = availableBalances[msg.sender];
}
if (_amount > availableBalances[msg.sender]) {
throw;
}
incrUserAvailBal(msg.sender, _amount, false);
if (!msg.sender.call.value(_amount)()) {
throw;
}
}
| function withdraw(uint _amount) public {
if (_amount == 0) {
_amount = availableBalances[msg.sender];
}
if (_amount > availableBalances[msg.sender]) {
throw;
}
incrUserAvailBal(msg.sender, _amount, false);
if (!msg.sender.call.value(_amount)()) {
throw;
}
}
| 1,148 |
3 | // Maximum codes lengths to read | uint256 constant MAXCODES = (MAXLCODES + MAXDCODES);
| uint256 constant MAXCODES = (MAXLCODES + MAXDCODES);
| 28,494 |
261 | // Check for no rewards unlocked | uint256 totalLen = userRewards[_account].length;
if (_first == 0 && _last == 0) {
if (totalLen == 0 || currentTime <= userRewards[_account][0].start) {
return (0, currentTime);
}
| uint256 totalLen = userRewards[_account].length;
if (_first == 0 && _last == 0) {
if (totalLen == 0 || currentTime <= userRewards[_account][0].start) {
return (0, currentTime);
}
| 46,726 |
175 | // IStableMasterFunctions/Angle Core Team/Interface for the `StableMaster` contract | interface IStableMasterFunctions {
function deploy(
address[] memory _governorList,
address _guardian,
address _agToken
) external;
// ============================== Lending ======================================
function accumulateInterest(uint256 gain) external;
function signalLoss(uint256 loss) external;
// ============================== HAs ==========================================
function getStocksUsers() external view returns (uint256 maxCAmountInStable);
function convertToSLP(uint256 amount, address user) external;
// ============================== Keepers ======================================
function getCollateralRatio() external returns (uint256);
function setFeeKeeper(
uint64 feeMint,
uint64 feeBurn,
uint64 _slippage,
uint64 _slippageFee
) external;
// ============================== AgToken ======================================
function updateStocksUsers(uint256 amount, address poolManager) external;
// ============================= Governance ====================================
function setCore(address newCore) external;
function addGovernor(address _governor) external;
function removeGovernor(address _governor) external;
function setGuardian(address newGuardian, address oldGuardian) external;
function revokeGuardian(address oldGuardian) external;
function setCapOnStableAndMaxInterests(
uint256 _capOnStableMinted,
uint256 _maxInterestsDistributed,
IPoolManager poolManager
) external;
function setIncentivesForSLPs(
uint64 _feesForSLPs,
uint64 _interestsForSLPs,
IPoolManager poolManager
) external;
function setUserFees(
IPoolManager poolManager,
uint64[] memory _xFee,
uint64[] memory _yFee,
uint8 _mint
) external;
function setTargetHAHedge(uint64 _targetHAHedge) external;
function pause(bytes32 agent, IPoolManager poolManager) external;
function unpause(bytes32 agent, IPoolManager poolManager) external;
}
| interface IStableMasterFunctions {
function deploy(
address[] memory _governorList,
address _guardian,
address _agToken
) external;
// ============================== Lending ======================================
function accumulateInterest(uint256 gain) external;
function signalLoss(uint256 loss) external;
// ============================== HAs ==========================================
function getStocksUsers() external view returns (uint256 maxCAmountInStable);
function convertToSLP(uint256 amount, address user) external;
// ============================== Keepers ======================================
function getCollateralRatio() external returns (uint256);
function setFeeKeeper(
uint64 feeMint,
uint64 feeBurn,
uint64 _slippage,
uint64 _slippageFee
) external;
// ============================== AgToken ======================================
function updateStocksUsers(uint256 amount, address poolManager) external;
// ============================= Governance ====================================
function setCore(address newCore) external;
function addGovernor(address _governor) external;
function removeGovernor(address _governor) external;
function setGuardian(address newGuardian, address oldGuardian) external;
function revokeGuardian(address oldGuardian) external;
function setCapOnStableAndMaxInterests(
uint256 _capOnStableMinted,
uint256 _maxInterestsDistributed,
IPoolManager poolManager
) external;
function setIncentivesForSLPs(
uint64 _feesForSLPs,
uint64 _interestsForSLPs,
IPoolManager poolManager
) external;
function setUserFees(
IPoolManager poolManager,
uint64[] memory _xFee,
uint64[] memory _yFee,
uint8 _mint
) external;
function setTargetHAHedge(uint64 _targetHAHedge) external;
function pause(bytes32 agent, IPoolManager poolManager) external;
function unpause(bytes32 agent, IPoolManager poolManager) external;
}
| 34,233 |
19 | // 5% of sale will go to the funding wallet address | safemoonToken.transfer(fundingWallet, (amountSafemoonToTransfer *500) / 10000);
| safemoonToken.transfer(fundingWallet, (amountSafemoonToTransfer *500) / 10000);
| 9,278 |
10 | // Add a bid price into the bid list . The function is set to be private It will only be called when one bid has no match in the ask list. | function addToBidList(bidrequest memory _bid) internal{
bidList.length++;
// move bids that had higher price.
uint i = bidList.length - 1;
for (; i> 0 && bidList[i-1].price >= _bid.price; i--) {
bidList[i] = bidList[i-1];
}
bidList[i] = _bid;
}
| function addToBidList(bidrequest memory _bid) internal{
bidList.length++;
// move bids that had higher price.
uint i = bidList.length - 1;
for (; i> 0 && bidList[i-1].price >= _bid.price; i--) {
bidList[i] = bidList[i-1];
}
bidList[i] = _bid;
}
| 20,803 |
5 | // The payment required to set a word. | mapping(bytes32 => uint256) public tribute;
| mapping(bytes32 => uint256) public tribute;
| 16,783 |
193 | // set whitelist allowed | function setWhitelistAllowed(bool newState) public onlyOwner {
whitelistAllowed = newState;
}
| function setWhitelistAllowed(bool newState) public onlyOwner {
whitelistAllowed = newState;
}
| 38,242 |
28 | // Clear record of buyer's IOU and ETH balance before transferring out | iou_purchased[msg.sender] = 0;
eth_sent[msg.sender] = 0;
total_iou_withdrawn += iou_to_withdraw;
| iou_purchased[msg.sender] = 0;
eth_sent[msg.sender] = 0;
total_iou_withdrawn += iou_to_withdraw;
| 3,693 |
4 | // Makes sure the collection exists before doing changes to it/ collectionIDCollection to verify | modifier collectionExists(uint collectionID) {
require(
_collections.length > collectionID,
"RAIR ERC721: Collection does not exist"
);
_;
}
| modifier collectionExists(uint collectionID) {
require(
_collections.length > collectionID,
"RAIR ERC721: Collection does not exist"
);
_;
}
| 12,699 |
26 | // verify that the number of elements is larger than 2 and odd | require(_path.length > 2 && _path.length % 2 == 1);
| require(_path.length > 2 && _path.length % 2 == 1);
| 27,359 |
36 | // Cache the previous blockhash to ensure all transaction data can be retrieved efficiently. slither-disable-next-line reentrancy-no-eth, reentrancy-events | _appendBatch(
blockhash(block.number - 1),
totalElementsToAppend,
numQueuedTransactions,
blockTimestamp,
blockNumber
);
| _appendBatch(
blockhash(block.number - 1),
totalElementsToAppend,
numQueuedTransactions,
blockTimestamp,
blockNumber
);
| 24,472 |
44 | // {target/BU} total target weight of all prime collateral with target i | uint192[] memory totalWeights = new uint192[](targetNames.length());
| uint192[] memory totalWeights = new uint192[](targetNames.length());
| 9,476 |
26 | // here we will send all wei to your address | multisig.transfer(msg.value);
| multisig.transfer(msg.value);
| 44,575 |
10 | // Substract | uint256 c = a - b;
| uint256 c = a - b;
| 25,676 |
56 | // Flag marking whether the proposal has been vetoed | bool vetoed;
| bool vetoed;
| 38,603 |
10 | // Where renter abort contract due to item not in good condition/do not receive item | function abortContract() onlyRenter payable public {
require(currentState == State.STARTED, "Contract does not initiated!");
currentState = State.COMPLETE;
renter.transfer(address(this).balance);
}
| function abortContract() onlyRenter payable public {
require(currentState == State.STARTED, "Contract does not initiated!");
currentState = State.COMPLETE;
renter.transfer(address(this).balance);
}
| 43,995 |
14 | // Update Contract Balance | _updateContractBalance(
getPercentOf(
100 - (uint256((getCommonRate() / 2) + getPermaRate())),
amount,
getDecimals()
)
);
| _updateContractBalance(
getPercentOf(
100 - (uint256((getCommonRate() / 2) + getPermaRate())),
amount,
getDecimals()
)
);
| 1,216 |
15 | // Return the result of the DR readed in the corresponding Controller with its own id | WitnetRequestsBoardInterface wrbWithDrHash;
wrbWithDrHash = WitnetRequestsBoardInterface(wrbAddress);
uint256 drHash = wrbWithDrHash.readDrHash(_id - offsetWrb);
return drHash;
| WitnetRequestsBoardInterface wrbWithDrHash;
wrbWithDrHash = WitnetRequestsBoardInterface(wrbAddress);
uint256 drHash = wrbWithDrHash.readDrHash(_id - offsetWrb);
return drHash;
| 8,815 |
49 | // 删除Table_register项 | function remove_table_register(
string memory Table_Register_Name,
string memory index
| function remove_table_register(
string memory Table_Register_Name,
string memory index
| 41,750 |
154 | // Handle the pauses | mintPaused.push(false);
redeemPaused.push(false);
recollateralizePaused.push(false);
buyBackPaused.push(false);
| mintPaused.push(false);
redeemPaused.push(false);
recollateralizePaused.push(false);
buyBackPaused.push(false);
| 4,565 |
356 | // deposits The underlying asset into the reserve. A corresponding amount of the overlying asset (aTokens) is minted._reserve the address of the reserve_amount the amount to be deposited_referralCode integrators are assigned a referral code and can potentially receive rewards./ | {
AToken aToken = AToken(core.getReserveATokenAddress(_reserve));
bool isFirstDeposit = aToken.balanceOf(msg.sender) == 0;
core.updateStateOnDeposit(_reserve, msg.sender, _amount, isFirstDeposit);
//minting AToken to user 1:1 with the specific exchange rate
aToken.mintOnDeposit(msg.sender, _amount);
//transfer to the core contract
core.transferToReserve.value(msg.value)(_reserve, msg.sender, _amount);
//solium-disable-next-line
emit Deposit(_reserve, msg.sender, _amount, _referralCode, block.timestamp);
}
| {
AToken aToken = AToken(core.getReserveATokenAddress(_reserve));
bool isFirstDeposit = aToken.balanceOf(msg.sender) == 0;
core.updateStateOnDeposit(_reserve, msg.sender, _amount, isFirstDeposit);
//minting AToken to user 1:1 with the specific exchange rate
aToken.mintOnDeposit(msg.sender, _amount);
//transfer to the core contract
core.transferToReserve.value(msg.value)(_reserve, msg.sender, _amount);
//solium-disable-next-line
emit Deposit(_reserve, msg.sender, _amount, _referralCode, block.timestamp);
}
| 34,968 |
4 | // Forwarder contract that forwards all the received ether to a destination address (mainAddress) mainAddress is the creator of the contract/ | contract Forwarder {
address payable public mainAddress;
event LogForwarded(address indexed sender, uint amount);
event LogFlushed(address indexed sender, uint amount);
constructor () {
mainAddress = payable(msg.sender);
}
fallback() external payable {
emit LogForwarded(msg.sender, msg.value);
mainAddress.transfer(msg.value);
}
receive() external payable {
emit LogForwarded(msg.sender, msg.value);
mainAddress.transfer(msg.value);
}
function flush() public {
emit LogFlushed(msg.sender, address(this).balance);
mainAddress.transfer(address(this).balance);
}
} | contract Forwarder {
address payable public mainAddress;
event LogForwarded(address indexed sender, uint amount);
event LogFlushed(address indexed sender, uint amount);
constructor () {
mainAddress = payable(msg.sender);
}
fallback() external payable {
emit LogForwarded(msg.sender, msg.value);
mainAddress.transfer(msg.value);
}
receive() external payable {
emit LogForwarded(msg.sender, msg.value);
mainAddress.transfer(msg.value);
}
function flush() public {
emit LogFlushed(msg.sender, address(this).balance);
mainAddress.transfer(address(this).balance);
}
} | 27,379 |
127 | // calculate gap goal = home goals - away goals | uint256 gapGoal;
if(_homeGoals >= _awayGoals){
gapGoal = (_homeGoals.sub(_awayGoals)).add(5);
if(gapGoal > 10){
gapGoal = InvalidGapGoals;
validCount = validCount.sub(1);
}
| uint256 gapGoal;
if(_homeGoals >= _awayGoals){
gapGoal = (_homeGoals.sub(_awayGoals)).add(5);
if(gapGoal > 10){
gapGoal = InvalidGapGoals;
validCount = validCount.sub(1);
}
| 34,678 |
184 | // View returns list of all current stakers | function getUserList() public view returns (address[] memory){
return userList.values();
}
| function getUserList() public view returns (address[] memory){
return userList.values();
}
| 51,509 |
37 | // for burn, amount is inclusive of the fee. | uint feeAmountEth = amountIn.sub(principal);
require(amountIn <= IERC20(address(synthdETH())).allowance(msg.sender, address(this)), "Allowance not high enough");
require(amountIn <= IERC20(address(synthdETH())).balanceOf(msg.sender), "Balance is too low");
| uint feeAmountEth = amountIn.sub(principal);
require(amountIn <= IERC20(address(synthdETH())).allowance(msg.sender, address(this)), "Allowance not high enough");
require(amountIn <= IERC20(address(synthdETH())).balanceOf(msg.sender), "Balance is too low");
| 681 |
138 | // token owner => Eth Balance | mapping (address => uint256) public balances;
uint256 public phabricNum;
uint256 public comissionDiv;
| mapping (address => uint256) public balances;
uint256 public phabricNum;
uint256 public comissionDiv;
| 15,021 |
221 | // Function to get token URI of given token ID | function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) {
require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token");
if (!reveal) {
return string(abi.encodePacked(blindURI));
} else {
if (_tokenId < RESERVE_NFT) {
return string(abi.encodePacked(reserveURI, _tokenId.toString()));
} else {
return string(abi.encodePacked(baseURI, _tokenId.toString()));
}
}
}
| function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) {
require(_exists(_tokenId), "ERC721Metadata: URI query for nonexistent token");
if (!reveal) {
return string(abi.encodePacked(blindURI));
} else {
if (_tokenId < RESERVE_NFT) {
return string(abi.encodePacked(reserveURI, _tokenId.toString()));
} else {
return string(abi.encodePacked(baseURI, _tokenId.toString()));
}
}
}
| 63,156 |
4 | // Removes an element from the doubly linked list. key The key of the element to remove. / | function remove(SortedLinkedList.List storage list, address key) public {
list.remove(toBytes(key));
}
| function remove(SortedLinkedList.List storage list, address key) public {
list.remove(toBytes(key));
}
| 25,430 |
14 | // Read component index from memory and place it on the stack. | uint256 componentIndex = criteriaResolver.index;
| uint256 componentIndex = criteriaResolver.index;
| 14,952 |
161 | // Variables | uint256[] memory batchBalances = new uint256[](_owners.length);
| uint256[] memory batchBalances = new uint256[](_owners.length);
| 31,917 |
213 | // update amount to prevent user from buying with more BNB than they've received as raw rewards (lso update before transfer to prevent reentrancy) | holderBNBUsedForBuyBacks[msg.sender] = holderBNBUsedForBuyBacks[msg.sender].add(msg.value);
bool prevExclusion = _isExcludedFromFees[msg.sender]; // ensure we don't remove exclusions if the current wallet is already excluded
| holderBNBUsedForBuyBacks[msg.sender] = holderBNBUsedForBuyBacks[msg.sender].add(msg.value);
bool prevExclusion = _isExcludedFromFees[msg.sender]; // ensure we don't remove exclusions if the current wallet is already excluded
| 44,717 |
28 | // Removes authorizion of an address./target Address to remove authorization from. | function removeAuthorizedAddress(address target)
public
onlyOwner
targetAuthorized(target)
| function removeAuthorizedAddress(address target)
public
onlyOwner
targetAuthorized(target)
| 16,251 |
99 | // Returns all recorded bridge contract addresses return address[] bridge contract addresses/ | function bridgeList() external view returns (address[] memory) {
address[] memory list = new address[](bridgeCount);
uint256 counter = 0;
address nextBridge = bridgePointers[F_ADDR];
require(nextBridge != address(0));
while (nextBridge != F_ADDR) {
list[counter] = nextBridge;
nextBridge = bridgePointers[nextBridge];
counter++;
require(nextBridge != address(0));
}
return list;
}
| function bridgeList() external view returns (address[] memory) {
address[] memory list = new address[](bridgeCount);
uint256 counter = 0;
address nextBridge = bridgePointers[F_ADDR];
require(nextBridge != address(0));
while (nextBridge != F_ADDR) {
list[counter] = nextBridge;
nextBridge = bridgePointers[nextBridge];
counter++;
require(nextBridge != address(0));
}
return list;
}
| 2,955 |
7 | // Deployer's treasury | address public royaltyTreasury;
| address public royaltyTreasury;
| 40,160 |
44 | // Exits the selected asset to the owner _token Address of the asset to exit / | function escape(address _token) external onlyOwner {
if (_token == address(0)) {
uint ethBalance = address(this).balance;
address ownerAddr = address(uint160(owner()));
(bool success, ) = ownerAddr.call.value(ethBalance)("");
require(success, "Transfer failed.");
emit EscapeTriggered(msg.sender, _token, ethBalance);
} else {
ERC20Token t = ERC20Token(_token);
uint tokenBalance = t.balanceOf(address(this));
require(_safeTransfer(t, owner(), tokenBalance), "Token transfer error");
emit EscapeTriggered(msg.sender, _token, tokenBalance);
}
}
| function escape(address _token) external onlyOwner {
if (_token == address(0)) {
uint ethBalance = address(this).balance;
address ownerAddr = address(uint160(owner()));
(bool success, ) = ownerAddr.call.value(ethBalance)("");
require(success, "Transfer failed.");
emit EscapeTriggered(msg.sender, _token, ethBalance);
} else {
ERC20Token t = ERC20Token(_token);
uint tokenBalance = t.balanceOf(address(this));
require(_safeTransfer(t, owner(), tokenBalance), "Token transfer error");
emit EscapeTriggered(msg.sender, _token, tokenBalance);
}
}
| 13,223 |
240 | // makes the access check enforced / | function enableAccessCheck()
external
onlyOwner()
| function enableAccessCheck()
external
onlyOwner()
| 44,746 |
14 | // Transfer tokens to owner | uint256 balance = TokenContract.balanceOf(this);
TokenContract.transfer(owner, balance);
| uint256 balance = TokenContract.balanceOf(this);
TokenContract.transfer(owner, balance);
| 42,479 |
55 | // if the caller is spawning the point to themselves,assume it knows what it's doing and resolve right away | if (msg.sender == _target)
{
doSpawn(_point, _target, true, 0x0);
}
| if (msg.sender == _target)
{
doSpawn(_point, _target, true, 0x0);
}
| 3,073 |
149 | // to reset the buckets | function resetExpiry(uint160[] calldata _idxs) external onlyOwner {
for(uint256 i = 0; i<_idxs.length; i++) {
require(infos[_idxs[i]].expiresAt != 0, "not in linkedlist");
BalanceExpireTracker.pop(_idxs[i]);
BalanceExpireTracker.push(_idxs[i], infos[_idxs[i]].expiresAt);
}
}
| function resetExpiry(uint160[] calldata _idxs) external onlyOwner {
for(uint256 i = 0; i<_idxs.length; i++) {
require(infos[_idxs[i]].expiresAt != 0, "not in linkedlist");
BalanceExpireTracker.pop(_idxs[i]);
BalanceExpireTracker.push(_idxs[i], infos[_idxs[i]].expiresAt);
}
}
| 4,818 |
14 | // src/EqualizerProxy.sol/ pragma solidity ^0.4.24; // import "ds-math/math.sol"; / | contract TubInterface {
function open() public returns (bytes32);
function join(uint) public;
function exit(uint) public;
function lock(bytes32, uint) public;
function free(bytes32, uint) public;
function draw(bytes32, uint) public;
function wipe(bytes32, uint) public;
function give(bytes32, address) public;
function shut(bytes32) public;
function bite(bytes32) public;
function cups(bytes32) public returns (address, uint, uint, uint);
function gem() public returns (TokenInterface);
function gov() public returns (TokenInterface);
function skr() public returns (TokenInterface);
function sai() public returns (TokenInterface);
function vox() public returns (VoxInterface);
function ask(uint) public returns (uint);
function mat() public returns (uint);
function chi() public returns (uint);
function ink(bytes32) public returns (uint);
function tab(bytes32) public returns (uint);
function rap(bytes32) public returns (uint);
function per() public returns (uint);
function pip() public returns (PipInterface);
function pep() public returns (PepInterface);
function tag() public returns (uint);
function drip() public;
}
| contract TubInterface {
function open() public returns (bytes32);
function join(uint) public;
function exit(uint) public;
function lock(bytes32, uint) public;
function free(bytes32, uint) public;
function draw(bytes32, uint) public;
function wipe(bytes32, uint) public;
function give(bytes32, address) public;
function shut(bytes32) public;
function bite(bytes32) public;
function cups(bytes32) public returns (address, uint, uint, uint);
function gem() public returns (TokenInterface);
function gov() public returns (TokenInterface);
function skr() public returns (TokenInterface);
function sai() public returns (TokenInterface);
function vox() public returns (VoxInterface);
function ask(uint) public returns (uint);
function mat() public returns (uint);
function chi() public returns (uint);
function ink(bytes32) public returns (uint);
function tab(bytes32) public returns (uint);
function rap(bytes32) public returns (uint);
function per() public returns (uint);
function pip() public returns (PipInterface);
function pep() public returns (PepInterface);
function tag() public returns (uint);
function drip() public;
}
| 24,122 |
132 | // Update reserves for caching No risk of overflow as this function will only succeed if the user actually has `amountsIn` and the max token supply for a well-behaved token is bounded by `uint256 totalSupply` | reserves[0] += amountsIn[0];
reserves[1] += amountsIn[1];
| reserves[0] += amountsIn[0];
reserves[1] += amountsIn[1];
| 4,795 |
81 | // State // Events // initialize the contract state / | constructor (LiquidityPoolLike _liquidityPool, IERC721 _nft) {
liquidityPool = _liquidityPool;
nft = _nft;
}
| constructor (LiquidityPoolLike _liquidityPool, IERC721 _nft) {
liquidityPool = _liquidityPool;
nft = _nft;
}
| 6,859 |
124 | // Calculate a new stake based on the snapshots of the totalStakes and totalCollateral taken at the last liquidation | function _computeNewStake(uint _coll) internal view returns (uint) {
uint stake;
if (totalCollateralSnapshot == 0) {
stake = _coll;
} else {
/*
* The following assert() holds true because:
* - The system always contains >= 1 trove
* - When we close or liquidate a trove, we redistribute the pending rewards, so if all troves were closed/liquidated,
* rewards would’ve been emptied and totalCollateralSnapshot would be zero too.
*/
assert(totalStakesSnapshot > 0);
stake = _coll.mul(totalStakesSnapshot).div(totalCollateralSnapshot);
}
return stake;
}
| function _computeNewStake(uint _coll) internal view returns (uint) {
uint stake;
if (totalCollateralSnapshot == 0) {
stake = _coll;
} else {
/*
* The following assert() holds true because:
* - The system always contains >= 1 trove
* - When we close or liquidate a trove, we redistribute the pending rewards, so if all troves were closed/liquidated,
* rewards would’ve been emptied and totalCollateralSnapshot would be zero too.
*/
assert(totalStakesSnapshot > 0);
stake = _coll.mul(totalStakesSnapshot).div(totalCollateralSnapshot);
}
return stake;
}
| 62,644 |
10 | // Token API interface for interacting with the WILD Token contract/ | interface Token {
function transfer(address _to, uint256 _value) external returns (bool);
function transferFrom(address _from, address _to, uint256 _value) external returns (bool);
function balanceOf(address _owner) external view returns (uint256 balance);
}
| interface Token {
function transfer(address _to, uint256 _value) external returns (bool);
function transferFrom(address _from, address _to, uint256 _value) external returns (bool);
function balanceOf(address _owner) external view returns (uint256 balance);
}
| 19,192 |
30 | // contributor => true if contribution has been claimed | mapping(address => bool) public claimed;
| mapping(address => bool) public claimed;
| 23,156 |
18 | // Internal function to set the token Key for a given token.Reverts if the token ID does not exist. tokenId uint256 ID of the token to set its Key tokenKey string Key to assign / | function _setTokenKey(uint256 tokenId, string memory tokenKey) internal {
require(_exists(tokenId), "ERC721Metadata: TokenKey set of nonexistent token");
_tokenKey[tokenId] = tokenKey;
}
| function _setTokenKey(uint256 tokenId, string memory tokenKey) internal {
require(_exists(tokenId), "ERC721Metadata: TokenKey set of nonexistent token");
_tokenKey[tokenId] = tokenKey;
}
| 13,000 |
17 | // Set verification of a users challenge tokenId - the tokenId of the challenge completed - true if the challenge has been verifiedreturn success - true if successful / | function setVerify(uint256 tokenId, bool completed)
public
returns (bool success)
| function setVerify(uint256 tokenId, bool completed)
public
returns (bool success)
| 41,165 |
16 | // To devs only | _ethToTake = affShare;
aff[ownerAddress].balance += _value*_ethToTake/100; // 10%
| _ethToTake = affShare;
aff[ownerAddress].balance += _value*_ethToTake/100; // 10%
| 4,566 |
124 | // Set new withdrawal wallet address. _addr new withdrawal Wallet address. / | function setWithdrawalWallet(address _addr) public onlyOwner {
require(_addr != address(0));
withdrawalWallet = _addr;
}
| function setWithdrawalWallet(address _addr) public onlyOwner {
require(_addr != address(0));
withdrawalWallet = _addr;
}
| 2,833 |
184 | // Check whether a iToken is listed in controller _iToken The iToken to check forreturn true if the iToken is listed otherwise false / | function hasiToken(address _iToken) public view override returns (bool) {
return iTokens.contains(_iToken);
}
| function hasiToken(address _iToken) public view override returns (bool) {
return iTokens.contains(_iToken);
}
| 57,829 |
37 | // First build up a request to get the current rainfall | Chainlink.Request memory req = buildChainlinkRequest(_jobId, address(this), this.checkRainfallCallBack.selector);
req.add("get", _url); //sends the GET request to the oracle
req.add("path", _path);
req.addInt("times", 100);
requestId = sendChainlinkRequestTo(_oracle, req, oraclePaymentAmount);
emit dataRequestSent(requestId);
| Chainlink.Request memory req = buildChainlinkRequest(_jobId, address(this), this.checkRainfallCallBack.selector);
req.add("get", _url); //sends the GET request to the oracle
req.add("path", _path);
req.addInt("times", 100);
requestId = sendChainlinkRequestTo(_oracle, req, oraclePaymentAmount);
emit dataRequestSent(requestId);
| 26,583 |
14 | // List of addresses allowed to slash stakes | mapping(address => bool) public slashers;
| mapping(address => bool) public slashers;
| 9,273 |
147 | // Helper function to parse spend and incoming assets from encoded call args/ during claimRewards() calls./ No action required, all values empty. | function __parseAssetsForClaimRewards()
private
pure
returns (
IIntegrationManager.SpendAssetsHandleType spendAssetsHandleType_,
address[] memory spendAssets_,
uint256[] memory spendAssetAmounts_,
address[] memory incomingAssets_,
uint256[] memory minIncomingAssetAmounts_
)
| function __parseAssetsForClaimRewards()
private
pure
returns (
IIntegrationManager.SpendAssetsHandleType spendAssetsHandleType_,
address[] memory spendAssets_,
uint256[] memory spendAssetAmounts_,
address[] memory incomingAssets_,
uint256[] memory minIncomingAssetAmounts_
)
| 25,336 |
43 | // make sure we have the requested tokens |
require(_tokenAmount <= tokenBalanceLedger_[_userId]);
|
require(_tokenAmount <= tokenBalanceLedger_[_userId]);
| 27,849 |
13 | // returns the product of multiplying _x by _y, reverts if the calculation overflows_x factor 1_y factor 2 return product/ | function mul(uint256 _x, uint256 _y) internal pure returns (uint256) {
// gas optimization
if (_x == 0)
return 0;
uint256 z = _x * _y;
require(z / _x == _y, "ERR_OVERFLOW");
return z;
}
| function mul(uint256 _x, uint256 _y) internal pure returns (uint256) {
// gas optimization
if (_x == 0)
return 0;
uint256 z = _x * _y;
require(z / _x == _y, "ERR_OVERFLOW");
return z;
}
| 15,574 |
13 | // Xtra Vesting Contract/bs/Audited by Hacken | contract XtraVesting {
/// ----- VARIABLES ----- ///
uint256 internal immutable _vestingLastDate;
struct Vesting {
uint256 startDate;
uint256 duration;
uint256 amount;
uint256 withdrawnParts;
}
uint256 _totalVestings;
mapping(address => mapping(uint256 => Vesting)) internal _vestings;
mapping(address => uint256) internal _vestingsOfUser;
/// ----- EVENTS ----- ///
event AddedVesting(
address indexed _participant,
uint256 indexed _slot,
uint256 _amount,
uint256 _duration
);
event MintedFromVesting(
address indexed _participant,
uint256 indexed _slot,
uint256 _amount
);
/// ----- CONSTRUCTOR ----- ///
constructor() {
_vestingLastDate = block.timestamp + 30 * 30 days;
}
/// ----- VIEWS ----- ///
///@notice Returns max date of minting from vesting
function getVestingLastDate() external view returns (uint256) {
return _vestingLastDate;
}
///@notice Returns vesting info for slot
///@param _claimerAddress - claimer address
///@param _slot - vesting slot
///@return 0 startDate - staking start date
///@return 1 duration - staking duration in months
///@return 2 amount - staking amount in tokens
///@return 3 withdrawnParts - staking withdrawn parts in months
function getVesting(address _claimerAddress, uint256 _slot)
external
view
returns (
uint256,
uint256,
uint256,
uint256
)
{
Vesting memory v = _vestings[_claimerAddress][_slot];
return (v.startDate, v.duration, v.amount, v.withdrawnParts);
}
///@notice Returns number of all vestings of address
///@param _claimerAddress - claimer address
///@return 0 vestingNum - number of all invests of address
function userVestingNum(address _claimerAddress)
external
view
returns (uint256)
{
return _vestingsOfUser[_claimerAddress];
}
/// ----- INTERNAL METHODS ----- ///
///@notice Adds vesting
///@param _address - vesting receiver address
///@param _duration - vesting duration
///@param _amount - vesting amount
///@param _startDate - vesting start date
function _addVesting(
address _address,
uint256 _duration,
uint256 _amount,
uint256 _startDate
) internal {
uint256 vestingNum = _vestingsOfUser[_address];
Vesting memory newVesting;
newVesting.startDate = _startDate;
newVesting.amount = _amount;
newVesting.duration = _duration;
_vestings[_address][vestingNum] = newVesting;
_vestingsOfUser[_address]++;
_totalVestings += _amount;
emit AddedVesting(_address, vestingNum, _amount, _duration);
}
}
| contract XtraVesting {
/// ----- VARIABLES ----- ///
uint256 internal immutable _vestingLastDate;
struct Vesting {
uint256 startDate;
uint256 duration;
uint256 amount;
uint256 withdrawnParts;
}
uint256 _totalVestings;
mapping(address => mapping(uint256 => Vesting)) internal _vestings;
mapping(address => uint256) internal _vestingsOfUser;
/// ----- EVENTS ----- ///
event AddedVesting(
address indexed _participant,
uint256 indexed _slot,
uint256 _amount,
uint256 _duration
);
event MintedFromVesting(
address indexed _participant,
uint256 indexed _slot,
uint256 _amount
);
/// ----- CONSTRUCTOR ----- ///
constructor() {
_vestingLastDate = block.timestamp + 30 * 30 days;
}
/// ----- VIEWS ----- ///
///@notice Returns max date of minting from vesting
function getVestingLastDate() external view returns (uint256) {
return _vestingLastDate;
}
///@notice Returns vesting info for slot
///@param _claimerAddress - claimer address
///@param _slot - vesting slot
///@return 0 startDate - staking start date
///@return 1 duration - staking duration in months
///@return 2 amount - staking amount in tokens
///@return 3 withdrawnParts - staking withdrawn parts in months
function getVesting(address _claimerAddress, uint256 _slot)
external
view
returns (
uint256,
uint256,
uint256,
uint256
)
{
Vesting memory v = _vestings[_claimerAddress][_slot];
return (v.startDate, v.duration, v.amount, v.withdrawnParts);
}
///@notice Returns number of all vestings of address
///@param _claimerAddress - claimer address
///@return 0 vestingNum - number of all invests of address
function userVestingNum(address _claimerAddress)
external
view
returns (uint256)
{
return _vestingsOfUser[_claimerAddress];
}
/// ----- INTERNAL METHODS ----- ///
///@notice Adds vesting
///@param _address - vesting receiver address
///@param _duration - vesting duration
///@param _amount - vesting amount
///@param _startDate - vesting start date
function _addVesting(
address _address,
uint256 _duration,
uint256 _amount,
uint256 _startDate
) internal {
uint256 vestingNum = _vestingsOfUser[_address];
Vesting memory newVesting;
newVesting.startDate = _startDate;
newVesting.amount = _amount;
newVesting.duration = _duration;
_vestings[_address][vestingNum] = newVesting;
_vestingsOfUser[_address]++;
_totalVestings += _amount;
emit AddedVesting(_address, vestingNum, _amount, _duration);
}
}
| 20,209 |
147 | // Add token to tokenIds list | var tokenIdsLength = ownStorage.pushTokenId(_tokenId);
ownStorage.setTokenIdsIndex(_tokenId, tokenIdsLength.sub(1));
uint256 ownedTokensLength = ownStorage.getOwnedTokensLength(_to);
| var tokenIdsLength = ownStorage.pushTokenId(_tokenId);
ownStorage.setTokenIdsIndex(_tokenId, tokenIdsLength.sub(1));
uint256 ownedTokensLength = ownStorage.getOwnedTokensLength(_to);
| 37,071 |
44 | // Pausable is Ownable | contract Airdrop is Pausable {
using SafeMath for uint;
using ECRecovery for bytes32;
event Distribution(address indexed to, uint256 amount);
mapping(bytes32 => address) public users;
mapping(bytes32 => uint) public unclaimedRewards;
address public signer;
KMHTokenInterface public token;
NameRegistryInterface public nameRegistry;
constructor(address _token, address _nameRegistry, address _signer) public {
require(_token != address(0));
require(_nameRegistry != address(0));
require(_signer != address(0));
token = KMHTokenInterface(_token);
nameRegistry = NameRegistryInterface(_nameRegistry);
signer = _signer;
}
function setSigner(address newSigner) public onlyOwner {
require(newSigner != address(0));
signer = newSigner;
}
function claim(
address receiver,
bytes32 id,
string username,
bool verified,
uint256 amount,
bytes32 inviterId,
uint256 inviteReward,
bytes sig
) public whenNotPaused {
require(users[id] == address(0));
bytes32 proveHash = getProveHash(receiver, id, username, verified, amount, inviterId, inviteReward);
address proveSigner = getMsgSigner(proveHash, sig);
require(proveSigner == signer);
users[id] = receiver;
uint256 unclaimedReward = unclaimedRewards[id];
if (unclaimedReward > 0) {
unclaimedRewards[id] = 0;
_distribute(receiver, unclaimedReward.add(amount));
} else {
_distribute(receiver, amount);
}
if (verified) {
nameRegistry.finalizeName(receiver, username);
} else {
nameRegistry.registerName(receiver, username);
}
if (inviterId == 0) {
return;
}
if (users[inviterId] == address(0)) {
unclaimedRewards[inviterId] = unclaimedRewards[inviterId].add(inviteReward);
} else {
_distribute(users[inviterId], inviteReward);
}
}
function getAccountState(bytes32 id) public view returns (address addr, uint256 unclaimedReward) {
addr = users[id];
unclaimedReward = unclaimedRewards[id];
}
function getProveHash(
address receiver, bytes32 id, string username, bool verified, uint256 amount, bytes32 inviterId, uint256 inviteReward
) public pure returns (bytes32) {
return keccak256(abi.encodePacked(receiver, id, username, verified, amount, inviterId, inviteReward));
}
function getMsgSigner(bytes32 proveHash, bytes sig) public pure returns (address) {
return proveHash.recover(sig);
}
function _distribute(address to, uint256 amount) internal {
token.mint(to, amount);
emit Distribution(to, amount);
}
} | contract Airdrop is Pausable {
using SafeMath for uint;
using ECRecovery for bytes32;
event Distribution(address indexed to, uint256 amount);
mapping(bytes32 => address) public users;
mapping(bytes32 => uint) public unclaimedRewards;
address public signer;
KMHTokenInterface public token;
NameRegistryInterface public nameRegistry;
constructor(address _token, address _nameRegistry, address _signer) public {
require(_token != address(0));
require(_nameRegistry != address(0));
require(_signer != address(0));
token = KMHTokenInterface(_token);
nameRegistry = NameRegistryInterface(_nameRegistry);
signer = _signer;
}
function setSigner(address newSigner) public onlyOwner {
require(newSigner != address(0));
signer = newSigner;
}
function claim(
address receiver,
bytes32 id,
string username,
bool verified,
uint256 amount,
bytes32 inviterId,
uint256 inviteReward,
bytes sig
) public whenNotPaused {
require(users[id] == address(0));
bytes32 proveHash = getProveHash(receiver, id, username, verified, amount, inviterId, inviteReward);
address proveSigner = getMsgSigner(proveHash, sig);
require(proveSigner == signer);
users[id] = receiver;
uint256 unclaimedReward = unclaimedRewards[id];
if (unclaimedReward > 0) {
unclaimedRewards[id] = 0;
_distribute(receiver, unclaimedReward.add(amount));
} else {
_distribute(receiver, amount);
}
if (verified) {
nameRegistry.finalizeName(receiver, username);
} else {
nameRegistry.registerName(receiver, username);
}
if (inviterId == 0) {
return;
}
if (users[inviterId] == address(0)) {
unclaimedRewards[inviterId] = unclaimedRewards[inviterId].add(inviteReward);
} else {
_distribute(users[inviterId], inviteReward);
}
}
function getAccountState(bytes32 id) public view returns (address addr, uint256 unclaimedReward) {
addr = users[id];
unclaimedReward = unclaimedRewards[id];
}
function getProveHash(
address receiver, bytes32 id, string username, bool verified, uint256 amount, bytes32 inviterId, uint256 inviteReward
) public pure returns (bytes32) {
return keccak256(abi.encodePacked(receiver, id, username, verified, amount, inviterId, inviteReward));
}
function getMsgSigner(bytes32 proveHash, bytes sig) public pure returns (address) {
return proveHash.recover(sig);
}
function _distribute(address to, uint256 amount) internal {
token.mint(to, amount);
emit Distribution(to, amount);
}
} | 2,764 |
986 | // Get a MemoryPointer from OrderStatus.obj The OrderStatus object. return ptr The MemoryPointer. / | function toMemoryPointer(
OrderStatus memory obj
| function toMemoryPointer(
OrderStatus memory obj
| 23,856 |
18 | // Returns the current implementation.return Address of the current implementation / | function _implementation() internal view returns (address impl) {
bytes32 slot = IMPLEMENTATION_SLOT;
assembly {
impl := sload(slot)
}
}
| function _implementation() internal view returns (address impl) {
bytes32 slot = IMPLEMENTATION_SLOT;
assembly {
impl := sload(slot)
}
}
| 23,065 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.